From 0f2574a887b3ec47ce82b6f86b5bcd7701cde946 Mon Sep 17 00:00:00 2001 From: FollieHiyuki Date: Sat, 16 Oct 2021 23:29:17 +0700 Subject: [PATCH] neovim + system neovim: - highlight: + adjust treesitter groups for nord (TSField as fg doesn't look good in yaml files). Also add highlight for TSNote, TSWarning, TSDanger (notes such as 'TODO', 'FIXME', ...) + rewrite the way theme is set (now 'g:colors_name' is used properly instead of a hacky variable 'g:global_theme'). Also make setting theme more modular + add 'highlight_languages' groups for other syntaxes (html, markdown) that are not covered with treesitter - mappings: properly move ':Telescope lsp_range_code_action' to visual block + avoid mappings for and (number decrement/increment) - null-ls.nvim: add basic config, load before nvim-lspconfig - plugins: add nvim-treesitter/playground - feline.nvim: lazy loaded on VimEnter - nvim-lightbulb: only refresh on CursorHold (previously stopped working after entering INSERT mode) system: - tlp: update config for v1.4.0 setup: add ani-cli to scripts.sh --- README.md | 2 +- home/.config/nvim/colors/nord.lua | 1 + home/.config/nvim/colors/onedark.lua | 1 + home/.config/nvim/init.lua | 1 - home/.config/nvim/lua/mappings.lua | 19 +- home/.config/nvim/lua/modules/editor.lua | 27 +- home/.config/nvim/lua/modules/lsp.lua | 54 +++- home/.config/nvim/lua/modules/tools.lua | 6 +- home/.config/nvim/lua/modules/ui.lua | 2 +- home/.config/nvim/lua/options.lua | 6 +- home/.config/nvim/lua/plugins.lua | 22 +- home/.config/nvim/lua/themes/init.lua | 29 ++ home/.config/nvim/lua/themes/nord/colors.lua | 22 ++ .../{colors/nord.lua => themes/nord/init.lua} | 266 +++++++++--------- .../onedark.lua => themes/onedark/colors.lua} | 22 +- home/.config/nvim/lua/themes/onedark/init.lua | 10 + home/.config/nvim/lua/themes/util.lua | 13 + home/.config/nvim/scripts/lsp/sumneko_lua | 2 +- setup/scripts.sh | 3 + system/etc/tlp.d/00-custom.conf | 12 +- 20 files changed, 311 insertions(+), 209 deletions(-) create mode 100644 home/.config/nvim/colors/nord.lua create mode 100644 home/.config/nvim/colors/onedark.lua create mode 100644 home/.config/nvim/lua/themes/init.lua create mode 100644 home/.config/nvim/lua/themes/nord/colors.lua rename home/.config/nvim/lua/{colors/nord.lua => themes/nord/init.lua} (65%) rename home/.config/nvim/lua/{colors/onedark.lua => themes/onedark/colors.lua} (50%) create mode 100644 home/.config/nvim/lua/themes/onedark/init.lua create mode 100644 home/.config/nvim/lua/themes/util.lua diff --git a/README.md b/README.md index 099ed21..6d0efb6 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ ### :star2: Credits -- [@glepnir](https://github.com/glepnir/nvim)'s Neovim config, and also [NvChad](https://github.com/NvChad/NvChad) +- [@glepnir](https://github.com/glepnir/nvim)'s Neovim config, also [NvChad](https://github.com/NvChad/NvChad) and [nord.nvim](https://github.com/shaunsingh/nord.nvim) - [@novakane](https://git.sr.ht/~novakane/) for git aliases - [@hlissner](https://github.com/hlissner)'s zsh config - [@daviwil](https://github.com/daviwil)'s/[@tecosaur](https://tecosaur.github.io/emacs-config/config.html)'s Emacs configurations diff --git a/home/.config/nvim/colors/nord.lua b/home/.config/nvim/colors/nord.lua new file mode 100644 index 0000000..07cb489 --- /dev/null +++ b/home/.config/nvim/colors/nord.lua @@ -0,0 +1 @@ +require('themes').set('nord') diff --git a/home/.config/nvim/colors/onedark.lua b/home/.config/nvim/colors/onedark.lua new file mode 100644 index 0000000..ade657c --- /dev/null +++ b/home/.config/nvim/colors/onedark.lua @@ -0,0 +1 @@ +require('themes').set('onedark') diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua index 1b365f4..81d1bf5 100644 --- a/home/.config/nvim/init.lua +++ b/home/.config/nvim/init.lua @@ -10,5 +10,4 @@ local options = require('options') options.disable_default_plugins() options.load_options() -require('colors.' .. vim.g.global_theme).highlight() async:send() diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index 4a179e2..f2e20fc 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -47,11 +47,11 @@ wk.register({ -- Close a window [''] = {'q', 'Quit current window'}, - -- Copy the whole buffer - [''] = {':%y+', 'Copy whole buffer'}, + -- Close current buffer + [''] = {':bdelete', 'Close current buffer'}, - -- Close buffer - [''] = {':bdelete', 'Close current buffer'}, + -- Copy the whole buffer + [''] = {':%y+', 'Copy whole buffer'}, -- Remove trailing whitespace [''] = {':%s/\\s\\+$//e', 'Remove trailing'}, @@ -215,6 +215,7 @@ wk.register({ name = 'Editor', a = {':EasyAlign', 'Align elements'}, g = 'Generate annotations', + h = {':TSHighlightCapturesUnderCursor', 'Syntax groups under cursor'}, s = {':ISwapWith', 'Swap elements'}, t = {':Twilight', 'Twilight mode'}, z = {':ZenMode', 'Zen mode'} @@ -294,7 +295,6 @@ wk.register({ f = { name = 'Telescope', a = {':Telescope lsp_code_actions', 'Code actions'}, - A = {':Telescope lsp_range_code_actions', 'Range code actions'}, d = {':Telescope lsp_document_diagnostics', 'Buffer diagnostics'}, D = {':Telescope lsp_workspace_diagnostics', 'Workspace diagnostics'}, e = {':Telescope lsp_dynamic_workspace_symbols', 'Dynamic workspace symbols'}, @@ -390,6 +390,15 @@ wk.register({ c = {'c=system(\'trans -brief -no-ansi :\', getreg(""))[:-2]', 'Translate and replace with direction'} }, + l = { + name = 'LSP', + f = { + name = 'Telescope', + a = {':Telescope lsp_range_code_actions', 'Range code actions'} + }, + o = 'Range format' + }, + p = 'Find/Replace' }, {mode = 'v', prefix = ''}) diff --git a/home/.config/nvim/lua/modules/editor.lua b/home/.config/nvim/lua/modules/editor.lua index 95ec7fc..fe89cd5 100644 --- a/home/.config/nvim/lua/modules/editor.lua +++ b/home/.config/nvim/lua/modules/editor.lua @@ -107,7 +107,30 @@ function M.treesitter_conf() } } }, - matchup = {enable = true} + matchup = {enable = true}, + playground = { + enable = true, + disable = {}, + updatetime = 25, + persist_queries = false, + keybindings = { + toggle_query_editor = 'o', + toggle_hl_groups = 'i', + toggle_injected_languages = 't', + toggle_anonymous_nodes = 'a', + toggle_language_display = 'I', + focus_language = 'f', + unfocus_language = 'F', + update = 'R', + goto_node = '', + show_help = '?' + } + }, + query_linter = { + enable = true, + use_virtual_text = true, + lint_events = {'BufWrite', 'CursorHold'} + } } -- tree-sitter based folding @@ -254,7 +277,7 @@ end function M.project_conf() require('project_nvim').setup { manual_mode = false, - detection_methods = {'pattern', 'lsp'}, + detection_methods = {'lsp', 'pattern'}, patterns = {'.git', '_darcs', '.hg', '.bzr', '.svn', 'Makefile', 'package.json', '*.pro', 'Dockerfile', '>Code'}, show_hidden = true, silent_chdir = true, diff --git a/home/.config/nvim/lua/modules/lsp.lua b/home/.config/nvim/lua/modules/lsp.lua index 530fe20..cb4e091 100644 --- a/home/.config/nvim/lua/modules/lsp.lua +++ b/home/.config/nvim/lua/modules/lsp.lua @@ -29,8 +29,11 @@ function M.lsp_conf() if client.resolved_capabilities.document_formatting then buf_set_keymap('n', 'lo', ':lua vim.lsp.buf.formatting()', opts) + -- vim.api.nvim_command('autocmd BufWritePre lua vim.lsp.buf.formatting_sync()') elseif client.resolved_capabilities.document_range_formatting then buf_set_keymap('n', 'lo', ':lua vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})', opts) + buf_set_keymap('v', 'lo', ':lua vim.lsp.buf.range_formatting()', opts) + -- vim.api.nvim_command('autocmd BufWritePre lua vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})') end -- Attach lsp_signature.nvim @@ -38,7 +41,7 @@ function M.lsp_conf() bind = true, -- This is mandatory, otherwise border config doesn't work floating_window = true, fix_pos = true, - hint_prefix = '🐬 ', + hint_prefix = ' ', transpancy = 5, handler_opts = {border = 'none'}, zindex = 50, -- set to 200 to make the float window on top of others @@ -66,6 +69,12 @@ function M.lsp_conf() } } + -- Replace the default lsp diagnostic letters with prettier symbols + vim.fn.sign_define('LspDiagnosticsSignError', {text = ''}) + vim.fn.sign_define('LspDiagnosticsSignWarning', {text = ''}) + vim.fn.sign_define('LspDiagnosticsSignInformation', {text = ''}) + vim.fn.sign_define('LspDiagnosticsSignHint', {text = ''}) + --------------------------- -- Server configurations -- --------------------------- @@ -255,8 +264,6 @@ function M.lsp_conf() } } - -- TODO: efm-langserver - -- Others local servers = { rust_analyzer = {'rust-analyzer'}, @@ -277,11 +284,31 @@ function M.lsp_conf() } end - -- Replace the default lsp diagnostic letters with prettier symbols - vim.fn.sign_define('LspDiagnosticsSignError', {text = ''}) - vim.fn.sign_define('LspDiagnosticsSignWarning', {text = ''}) - vim.fn.sign_define('LspDiagnosticsSignInformation', {text = ''}) - vim.fn.sign_define('LspDiagnosticsSignHint', {text = ''}) + ------------------------ + -- Linters/Formatters -- + ------------------------ + -- TODO: efm-langserver as another option + local null_ls = require('null-ls') + + -- Register sources + null_ls.config { + sources = { + -- Formatters + null_ls.builtins.formatting.stylua.with { + condition = function(utils) + return utils.root_has_file('stylua.toml') + end + }, + null_ls.builtins.formatting.clang_format.with { + filetypes = {'c', 'cpp'} + } + -- Linters + } + } + + lspconf['null-ls'].setup { + on_attach = on_attach + } end function M.sqls_conf() @@ -292,7 +319,7 @@ end function M.lightbulb_conf() vim.api.nvim_command [[ - autocmd CursorHold,CursorHoldI * lua require('nvim-lightbulb').update_lightbulb {sign = {enabled = false}, status_text = {enabled = true, text = ' Code action', text_unavailable = ''}} + autocmd CursorHold * lua require('nvim-lightbulb').update_lightbulb({sign = {enabled = false}, status_text = {enabled = true, text = ' Code action', text_unavailable = ''}}) ]] end @@ -344,9 +371,9 @@ end -- exclude = {'org'}, -- list of file types to exclude highlighting -- }, -- colors = { --- error = {'LspDiagnosticsDefaultError', 'Red'}, --- warning = {'LspDiagnosticsDefaultWarning', 'Yellow'}, --- info = {'LspDiagnosticsDefaultInformation', 'Blue'}, +-- error = {'LspDiagnosticsDefaultError', 'TSDanger', 'Red'}, +-- warning = {'LspDiagnosticsDefaultWarning', 'TSWarning', 'Yellow'}, +-- info = {'LspDiagnosticsDefaultInformation', 'TSNote', 'Blue'}, -- hint = {'LspDiagnosticsDefaultHint', 'Cyan'}, -- default = {'Normal', 'White'} -- }, @@ -375,9 +402,6 @@ function M.outline_conf() } end -function M.null_ls_conf() -end - function M.dap_conf() local dap = require('dap') vim.fn.sign_define('DapBreakpoint', {text='', texthl='Orange'}) diff --git a/home/.config/nvim/lua/modules/tools.lua b/home/.config/nvim/lua/modules/tools.lua index ed5aecb..16faade 100644 --- a/home/.config/nvim/lua/modules/tools.lua +++ b/home/.config/nvim/lua/modules/tools.lua @@ -108,7 +108,7 @@ function M.rest_conf() end function M.orgmode_conf() - local c = require('colors.' .. vim.g.global_theme).colors + local c = require('themes.' .. vim.g.colors_name .. '.colors') require('orgmode').setup { -- General settings @@ -247,7 +247,7 @@ function M.neoscroll_conf() end function M.sniprun_conf() - local c = require('colors.' .. vim.g.global_theme).colors + local c = require('themes.' .. vim.g.colors_name .. '.colors') require('sniprun').setup { display = { @@ -348,7 +348,7 @@ function M.winpicker_conf() keys = 'alskdjfhgwoeiruty', -- Swap windows by holding shift + letter swap_shift = true, - exclude = {qf = true, NvimTree = true, packer = true, alpha = true}, + exclude = {NvimTree = true, alpha = true}, -- Flash the cursor line of the newly focused window flash_duration = 300 } diff --git a/home/.config/nvim/lua/modules/ui.lua b/home/.config/nvim/lua/modules/ui.lua index c2b9aff..c6615b7 100644 --- a/home/.config/nvim/lua/modules/ui.lua +++ b/home/.config/nvim/lua/modules/ui.lua @@ -94,7 +94,7 @@ function M.dashboard_conf() end function M.statusline_conf() - local colors = require('colors.' .. vim.g.global_theme).colors + local colors = require('themes.' .. vim.g.colors_name .. '.colors') local vi_mode_colors = { NORMAL = colors.green, diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/options.lua index d723762..71f463f 100644 --- a/home/.config/nvim/lua/options.lua +++ b/home/.config/nvim/lua/options.lua @@ -24,12 +24,12 @@ function M.disable_default_plugins() end function M.load_options() - -- Global theme - vim.g.global_theme = 'nord' + -- This is the same as `:colorscheme nord/onedark` + vim.g.colors_name = 'nord' -- Leader key vim.g.mapleader = ' ' -- Python path - vim.g.python_host_prog = '/usr/bin/python' + -- vim.g.python_host_prog = '/usr/bin/python' vim.g.python3_host_prog = '/usr/bin/python3' -- General settings diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 4b7fff0..86e4bb5 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -24,6 +24,7 @@ return packer.startup(function(use) } use { 'famiu/feline.nvim', + event = 'VimEnter', wants = 'nvim-web-devicons', config = ui.statusline_conf } @@ -74,6 +75,9 @@ return packer.startup(function(use) event = 'BufRead', config = editor.treesitter_conf } + use {'nvim-treesitter/playground', after = 'nvim-treesitter'} + use {'romgrk/nvim-treesitter-context', after = 'nvim-treesitter'} + use {'nvim-treesitter/nvim-treesitter-textobjects', after = 'nvim-treesitter'} -- use { -- 'lewis6991/spellsitter.nvim', -- event = {'BufRead', 'BufNew', 'BufNewFile'}, @@ -90,8 +94,6 @@ return packer.startup(function(use) -- Putting config into `treesitter_conf` doesn't work for some reason config = editor.rainbow_conf } - use {'romgrk/nvim-treesitter-context', after = 'nvim-treesitter'} - use {'nvim-treesitter/nvim-treesitter-textobjects', after = 'nvim-treesitter'} use { 'mizlan/iswap.nvim', cmd = {'ISwapWith', 'ISwap'}, @@ -175,8 +177,14 @@ return packer.startup(function(use) use { 'neovim/nvim-lspconfig', event = 'BufReadPre', - wants = 'lsp_signature.nvim', - requires = {{'ray-x/lsp_signature.nvim', opt = true}}, + wants = {'lsp_signature.nvim', 'null-ls.nvim'}, + requires = { + {'ray-x/lsp_signature.nvim', opt = true}, + { -- TODO: scripts to install linters/formatters, config + 'jose-elias-alvarez/null-ls.nvim', + wants = 'plenary.nvim', opt = true + } + }, config = lsp.lsp_conf } use { @@ -206,12 +214,6 @@ return packer.startup(function(use) cmd = {'SymbolsOutline', 'SymbolsOutlineOpen'}, setup = lsp.outline_conf } - use { -- TODO: config, scripts to install formaters, linters - 'jose-elias-alvarez/null-ls.nvim', - wants = 'plenary.nvim', - after = 'nvim-lspconfig', - config = lsp.null_ls_conf - } use { -- TODO: config, scripts to install/update dap servers 'rcarriga/nvim-dap-ui', keys = 'd', diff --git a/home/.config/nvim/lua/themes/init.lua b/home/.config/nvim/lua/themes/init.lua new file mode 100644 index 0000000..2fc0ea2 --- /dev/null +++ b/home/.config/nvim/lua/themes/init.lua @@ -0,0 +1,29 @@ +local M = {} + +function M.set(theme) + -- Reset everything + vim.api.nvim_command('hi clear') + if vim.fn.exists('syntax_on') then vim.api.nvim_command('syntax reset') end + vim.opt.background = 'dark' + + -- Get theme specs + local t = require('themes.' .. theme) + vim.g.colors_name = theme + + -- Load highlight groups + local async + async = vim.loop.new_async(vim.schedule_wrap(function() + t.set_vim_termcolors() + t.highlight_plugins() + t.highlight_languages() + t.highlight_treesitter() + t.highlight_lsp() + async:close() + end)) + + t.highlight_editor() + t.highlight_syntax() + async:send() -- Load the rest later +end + +return M diff --git a/home/.config/nvim/lua/themes/nord/colors.lua b/home/.config/nvim/lua/themes/nord/colors.lua new file mode 100644 index 0000000..66c3840 --- /dev/null +++ b/home/.config/nvim/lua/themes/nord/colors.lua @@ -0,0 +1,22 @@ +local nord = { + black = '#2E3440', + grey1 = '#3B4252', + grey2 = '#434C5E', + grey3 = '#4C566A', + grey_bright = '#616E88', + fg = '#D8DEE9', + white1 = '#E5E9F0', + white2 = '#ECEFF4', + teal = '#8FBCBB', + cyan = '#88C0D0', + blue = '#81A1C1', + dark_blue = '#5E81AC', + red = '#BF616A', + orange = '#D08770', + yellow = '#EBCB8B', + green = '#A3BE8C', + purple = '#B48EAD', + highlight = '#7B88A1' +} + +return nord diff --git a/home/.config/nvim/lua/colors/nord.lua b/home/.config/nvim/lua/themes/nord/init.lua similarity index 65% rename from home/.config/nvim/lua/colors/nord.lua rename to home/.config/nvim/lua/themes/nord/init.lua index 84748df..70eb14f 100644 --- a/home/.config/nvim/lua/colors/nord.lua +++ b/home/.config/nvim/lua/themes/nord/init.lua @@ -1,40 +1,11 @@ +local cmd = vim.api.nvim_command local M = {} -M.colors = { - black = '#2E3440', - grey1 = '#3B4252', - grey2 = '#434C5E', - grey3 = '#4C566A', - grey_bright = '#616E88', - fg = '#D8DEE9', - white1 = '#E5E9F0', - white2 = '#ECEFF4', - teal = '#8FBCBB', - cyan = '#88C0D0', - blue = '#81A1C1', - dark_blue = '#5E81AC', - red = '#BF616A', - orange = '#D08770', - yellow = '#EBCB8B', - green = '#A3BE8C', - purple = '#B48EAD', - highlight = '#7B88A1' -} - -local c = M.colors - -local function hi(group, guifg, guibg, attr, guisp) - local fg = guifg ~= '' and 'guifg=' .. guifg or 'guifg=NONE' - local bg = guibg ~= '' and 'guibg=' .. guibg or 'guibg=NONE' - local style = attr ~= '' and 'gui=' .. attr or 'gui=NONE' - local sp = guisp ~= '' and 'guisp=' .. guisp or '' - - local hl = 'hi ' .. group .. ' ' .. fg .. ' ' .. bg .. ' ' .. style .. ' ' .. sp - vim.api.nvim_command(hl) -end +local c = require('themes.nord.colors') +local hi = require('themes.util').highlight -- Set terminal colors -local function set_vim_termcolors() +function M.set_vim_termcolors() vim.g.terminal_color_0 = c.grey1 vim.g.terminal_color_1 = c.red vim.g.terminal_color_2 = c.green @@ -54,7 +25,7 @@ local function set_vim_termcolors() end -- Editor related groups -local function highlight_editors() +function M.highlight_editor() -- Color groups for other uses hi('Red', c.red, '', '', '') hi('Green', c.green, '', '', '') @@ -110,7 +81,7 @@ local function highlight_editors() -- Prompt hi('EndOfBuffer', c.grey1, '' , '', '') hi('ErrorMsg' , c.fg , c.red , '', '') - hi('ModeMsg' , c.green, '' , '', '') + hi('ModeMsg' , c.fg , '' , '', '') hi('MoreMsg' , c.cyan , '' , '', '') hi('Question' , c.fg , '' , '', '') hi('WarningMsg' , c.black, c.yellow, '', '') @@ -137,7 +108,7 @@ local function highlight_editors() end -- Syntax groups -local function highlight_syntax() +function M.highlight_syntax() -- Base syntax hi('Boolean', c.blue, '', '', '') hi('Character', c.fg, '', '', '') @@ -153,7 +124,7 @@ local function highlight_syntax() hi('Function', c.cyan, '', '', '') hi('Identifier', c.fg, '', '', '') hi('Include', c.blue, '', '', '') - hi('Keyword', c.blue, '', '', '') + hi('Keyword', c.blue, '', 'bold', '') hi('Label', c.blue, '', '', '') hi('Number', c.purple, '', '', '') hi('Operator', c.blue, '', '', '') @@ -170,14 +141,10 @@ local function highlight_syntax() hi('Todo', c.yellow, '', '', '') hi('Type', c.blue, '', '', '') hi('Typedef', c.blue, '', '', '') - vim.api.nvim_command('hi! link Annotation Decorator') - vim.api.nvim_command('hi! link Macro Define') - vim.api.nvim_command('hi! link PreCondit PreProc') - vim.api.nvim_command('hi! link Variable Identifier') - - -- sql - vim.api.nvim_command('hi! link sqlKeyword Keyword') - vim.api.nvim_command('hi! link sqlSpecial Keyword') + cmd('hi! link Annotation Decorator') + cmd('hi! link Macro Define') + cmd('hi! link PreCondit PreProc') + cmd('hi! link Variable Identifier') -- Diff hi('DiffAdd' , c.green , c.grey1, '', '') @@ -190,66 +157,107 @@ local function highlight_syntax() hi('diffFile', c.cyan, c.grey1, '', '') hi('diffLine', c.purple, c.grey1, '', '') hi('diffIndexLine', c.fg, c.grey1, '', '') - vim.api.nvim_command('hi! link diffAdded DiffAdd') - vim.api.nvim_command('hi! link diffRemoved DiffDelete') - vim.api.nvim_command('hi! link diffChanged DiffChange') + cmd('hi! link diffAdded DiffAdd') + cmd('hi! link diffRemoved DiffDelete') + cmd('hi! link diffChanged DiffChange') end --- Treesitter -local function highlight_treesitter() - hi('TSPunctDelimiter', c.fg, '', '', '') - hi('TSPunctBracket', c.fg, '', '', '') - hi('TSPunctSpecial', c.fg, '', '', '') - hi('TSConstant', c.yellow, '', '', '') - hi('TSConstBuiltin', c.blue, '', '', '') - hi('TSConstMacro', c.yellow, '', '', '') - hi('TSStringRegex', c.green, '', '', '') - hi('TSString', c.green, '', '', '') - hi('TSStringEscape', c.green, '', '', '') +-- Things that still don't look right with nvim-treesitter +function M.highlight_languages() + -- sql + cmd('hi! link sqlKeyword Keyword') + cmd('hi! link sqlSpecial Keyword') + + -- markdown + hi('markdownCode', c.fg, '', 'italic', '') + hi('markdownCodeBlock', c.fg, '', 'italic', '') + hi('markdownH1', c.purple, '', 'bold', '') + cmd('hi! link markdownH1Delimiter markdownH1') + hi('markdownH2', c.dark_blue, '', 'bold', '') + cmd('hi! link markdownH2Delimiter markdownH2') + hi('markdownH3', c.blue, '', 'bold', '') + cmd('hi! link markdownH3Delimiter markdownH3') + hi('markdownH4', c.cyan, '', 'bold', '') + cmd('hi! link markdownH4Delimiter markdownH4') + hi('markdownH5', c.teal, '', 'bold', '') + cmd('hi! link markdownH5Delimiter markdownH5') + hi('markdownH6', c.green, '', 'bold', '') + cmd('hi! link markdownH6Delimiter markdownH6') + + -- html + hi('htmlLink', c.green, '', 'underline', '') + cmd('hi! link htmlH1 markdownH1') + cmd('hi! link htmlH2 markdownH2') + cmd('hi! link htmlH3 markdownH3') + cmd('hi! link htmlH4 markdownH4') + cmd('hi! link htmlH5 markdownH5') + cmd('hi! link htmlH6 markdownH6') +end + +-- Treesitter (:h nvim-treesitter-highlights) +function M.highlight_treesitter() + cmd('hi! link TSAnnotation Annotation') hi('TSCharacter', c.green, '', '', '') - hi('TSNumber', c.purple, '', '', '') - hi('TSBoolean', c.purple, '', '', '') + hi('TSConstructor', c.blue, '', '', '') + hi('TSConstant', c.yellow, '', '', '') hi('TSFloat', c.purple, '', '', '') - hi('TSAttribute', c.teal, '', '', '') - hi('TSNamespace', c.fg, '', '', '') - hi('TSMethod', c.cyan, '', '', '') - hi('TSField', c.fg, '', '', '') - hi('TSProperty', c.fg, '', '', '') - hi('TSConditional', c.blue, '', '', '') - hi('TSParameter', c.purple, '', '', '') - hi('TSParameterReference', c.purple, '', '', '') - hi('TSRepeat', c.blue, '', '', '') - hi('TSLabel', c.blue, '', '', '') - hi('TSKeyword', c.blue, '', '', '') - hi('TSKeywordFunction', c.blue, '', '', '') - hi('TSKeywordOperator', c.blue, '', '', '') - hi('TSOperator', c.blue, '', '', '') - hi('TSException', c.red, '', '', '') - hi('TSType', c.teal, '', '', '') - hi('TSTypeBuiltin', c.blue, '', '', '') - hi('TSStructure', c.blue, '', '', '') + hi('TSNumber', c.purple, '', '', '') + hi('TSString', c.green, '', '', '') + + hi('TSAttribute', c.purple, '', '', '') + cmd('hi! link TSBoolean Boolean') + hi('TSConstBuiltin', c.teal, '', '', '') + hi('TSConstMacro', c.teal, '', '', '') + hi('TSError', c.red, '', '', '') + hi('TSException', c.purple, '', '', '') + hi('TSField', c.teal, '', '', '') + hi('TSFuncMacro', c.teal, '', '', '') hi('TSInclude', c.blue, '', '', '') - hi('TSVariableBuiltin', c.fg, '', '', '') + hi('TSLabel', c.purple, '', '', '') + hi('TSNamespace', c.fg, '', '', '') + hi('TSOperator', c.blue, '', '', '') + hi('TSParameter', c.purple, '', 'italic', '') + hi('TSParameterReference', c.purple, '', 'italic', '') + hi('TSProperty', c.teal, '', '', '') + hi('TSPunctDelimiter', c.fg, '', '', '') + hi('TSPunctBracket', c.cyan, '', '', '') + hi('TSPunctSpecial', c.cyan, '', '', '') + hi('TSStringRegex', c.teal, '', '', '') + hi('TSStringEscape', c.purple, '', '', '') + hi('TSSymbol', c.purple, '', '', '') + hi('TSType', c.blue, '', '', '') + hi('TSTypeBuiltin', c.blue, '', '', '') + hi('TSTag', c.fg, '', '', '') + hi('TSTagDelimiter', c.purple, '', '', '') hi('TSText', c.fg, '', '', '') - hi('TSStrong', c.cyan, '', 'bold', '') - hi('TSEmphasis', c.cyan, '', 'bold,italic', '') - hi('TSUnderline', c.cyan, '', 'underline', '') - hi('TSTitle', c.cyan, '', '', '') - hi('TSLiteral', c.cyan, '', '', '') - hi('TSURI', c.fg, '', '', '') - hi('TSTag', c.blue, '', '', '') - hi('TSTagDelimiter', c.fg, '', '', '') - vim.api.nvim_command('hi! link TSAnnotation Annotation') - vim.api.nvim_command('hi! link TSConstructor Function') - -- vim.api.nvim_command('hi! link TSError Error') - vim.api.nvim_command('hi! link TSFuncBuiltin Function') - vim.api.nvim_command('hi! link TSFunction Function') - vim.api.nvim_command('hi! link TSFuncMacro Function') - vim.api.nvim_command('hi! link TSVariable Variable') + hi('TSTextReference', c.purple, '', '', '') + hi('TSEmphasis', c.fg, '', 'bold,italic', '') + cmd('hi! link TSUnderline Underline') + hi('TSTitle', c.dark_blue, '', 'bold', '') + hi('TSLiteral', c.fg, '', '', '') + hi('TSURI', c.green, '', 'underline', '') + + cmd('hi! link TSComment Comment') + hi('TSConditional', c.blue, '', 'bold', '') + hi('TSKeyword', c.blue, '', 'bold', '') + hi('TSRepeat', c.blue, '', 'bold', '') + hi('TSKeywordFunction', c.blue, '', 'bold', '') + hi('TSKeywordOperator', c.blue, '', 'bold', '') + cmd('hi! link TSFunction Function') + hi('TSMethod', c.teal, '', '', '') + cmd('hi! link TSFuncBuiltin Function') + cmd('hi! link TSVariable Variable') + cmd('hi! link TSVariableBuiltin Variable') + cmd('hi! link TSStrong Bold') + cmd('hi! link TSStructure Structure') + + hi('TSNote', c.blue, '', 'bold', '') + hi('TSWarning', c.yellow, '', 'bold', '') + hi('TSDanger', c.red, '', 'bold', '') end -- LSP groups -local function highlight_lsp() +function M.highlight_lsp() hi('LspDiagnosticsDefaultError', c.red, '', '', '') hi('LspDiagnosticsSignError', c.red, '', '', '') hi('LspDiagnosticsFloatingError', c.red, '', '', '') @@ -277,29 +285,29 @@ local function highlight_lsp() hi('LspReferenceText', c.fg, c.grey_bright, '', '') hi('LspReferenceRead', c.fg, c.grey_bright, '', '') hi('LspReferenceWrite', c.fg, c.grey_bright, '', '') - vim.api.nvim_command('hi! link LspCodeLens Comment') + cmd('hi! link LspCodeLens Comment') -- Theses are for neovim 0.6 - -- vim.api.nvim_command('hi! link DiagnosticVirtualTextWarn LspDiagnosticsVirtualTextWarning') - -- vim.api.nvim_command('hi! link DiagnosticUnderlineWarn LspDiagnosticsUnderlineWarning') - -- vim.api.nvim_command('hi! link DiagnosticFloatingWarn LspDiagnosticsFloatingWarning') - -- vim.api.nvim_command('hi! link DiagnosticSignWarn LspDiagnosticsSignWarning') - -- vim.api.nvim_command('hi! link DiagnosticVirtualTextError LspDiagnosticsVirtualTextError') - -- vim.api.nvim_command('hi! link DiagnosticUnderlineError LspDiagnosticsUnderlineError') - -- vim.api.nvim_command('hi! link DiagnosticFloatingError LspDiagnosticsFloatingError') - -- vim.api.nvim_command('hi! link DiagnosticSignError LspDiagnosticsSignError') - -- vim.api.nvim_command('hi! link DiagnosticVirtualTextInfo LspDiagnosticsVirtualTextInformation') - -- vim.api.nvim_command('hi! link DiagnosticUnderlineInfo LspDiagnosticsUnderlineInformation') - -- vim.api.nvim_command('hi! link DiagnosticFloatingInfo LspDiagnosticsFloatingInformation') - -- vim.api.nvim_command('hi! link DiagnosticSignInfo LspDiagnosticsSignInformation') - -- vim.api.nvim_command('hi! link DiagnosticVirtualTextHint LspDiagnosticsVirtualTextHint') - -- vim.api.nvim_command('hi! link DiagnosticUnderlineHint LspDiagnosticsUnderlineHint') - -- vim.api.nvim_command('hi! link DiagnosticFloatingHint LspDiagnosticsFloatingHint') - -- vim.api.nvim_command('hi! link DiagnosticSignHint LspDiagnosticsSignHint') + -- cmd('hi! link DiagnosticVirtualTextWarn LspDiagnosticsVirtualTextWarning') + -- cmd('hi! link DiagnosticUnderlineWarn LspDiagnosticsUnderlineWarning') + -- cmd('hi! link DiagnosticFloatingWarn LspDiagnosticsFloatingWarning') + -- cmd('hi! link DiagnosticSignWarn LspDiagnosticsSignWarning') + -- cmd('hi! link DiagnosticVirtualTextError LspDiagnosticsVirtualTextError') + -- cmd('hi! link DiagnosticUnderlineError LspDiagnosticsUnderlineError') + -- cmd('hi! link DiagnosticFloatingError LspDiagnosticsFloatingError') + -- cmd('hi! link DiagnosticSignError LspDiagnosticsSignError') + -- cmd('hi! link DiagnosticVirtualTextInfo LspDiagnosticsVirtualTextInformation') + -- cmd('hi! link DiagnosticUnderlineInfo LspDiagnosticsUnderlineInformation') + -- cmd('hi! link DiagnosticFloatingInfo LspDiagnosticsFloatingInformation') + -- cmd('hi! link DiagnosticSignInfo LspDiagnosticsSignInformation') + -- cmd('hi! link DiagnosticVirtualTextHint LspDiagnosticsVirtualTextHint') + -- cmd('hi! link DiagnosticUnderlineHint LspDiagnosticsUnderlineHint') + -- cmd('hi! link DiagnosticFloatingHint LspDiagnosticsFloatingHint') + -- cmd('hi! link DiagnosticSignHint LspDiagnosticsSignHint') end -- Specify groups for plugins -local function highlight_plugins() +function M.highlight_plugins() -- nvim-cmp hi('CmpItemAbbr', c.fg, '', '', '') hi('CmpItemAbbrMatch', c.yellow, '', '', '') @@ -325,11 +333,11 @@ local function highlight_plugins() hi('HopNextKey', c.red, '', 'bold', '') hi('HopNextKey1', c.cyan, '', 'bold', '') hi('HopNextKey2', c.dark_blue, '', '', '') - vim.api.nvim_command('hi! link HopUnmatched LineNr') + cmd('hi! link HopUnmatched LineNr') -- vim-eft hi('EftChar', c.orange, '', 'bold,underline', '') - vim.api.nvim_command('hi! link EftSubChar LineNr') + cmd('hi! link EftSubChar LineNr') -- dashboard-nvim / alpha-nvim hi('DashboardHeader' , c.blue , '', 'bold' , '') @@ -370,8 +378,8 @@ local function highlight_plugins() hi('WindowPickerSwap', c.fg, c.orange, 'bold', '') -- vim-illuminate - vim.api.nvim_command('hi! link illuminatedWord Underline') - vim.api.nvim_command('hi! link illuminatedCurWord Underline') + cmd('hi! link illuminatedWord Underline') + cmd('hi! link illuminatedCurWord Underline') -- trouble.nvim hi('LspTroubleText', c.blue, '', 'bold', '') @@ -398,26 +406,4 @@ local function highlight_plugins() hi('NeogitNotificationError', c.red, '', '', '') end --- Main function -function M.highlight() - -- Reset everything - vim.api.nvim_command('hi clear') - if vim.fn.exists('syntax_on') then vim.api.nvim_command('syntax reset') end - vim.opt.background = 'dark' - - -- Load highlight groups - local async - async = vim.loop.new_async(vim.schedule_wrap(function() - set_vim_termcolors() - highlight_plugins() - highlight_treesitter() - highlight_lsp() - async:close() - end)) - - highlight_editors() - highlight_syntax() - async:send() -- Load the rest later -end - return M diff --git a/home/.config/nvim/lua/colors/onedark.lua b/home/.config/nvim/lua/themes/onedark/colors.lua similarity index 50% rename from home/.config/nvim/lua/colors/onedark.lua rename to home/.config/nvim/lua/themes/onedark/colors.lua index 84e1525..df98933 100644 --- a/home/.config/nvim/lua/colors/onedark.lua +++ b/home/.config/nvim/lua/themes/onedark/colors.lua @@ -1,6 +1,4 @@ -local M = {} - -M.colors = { +local onedark = { black = '#282C34', grey1 = '#3E4452', grey2 = '#4B5263', @@ -22,20 +20,4 @@ M.colors = { highlight = '#9CA0A4' } -local c = M.colors - -local function hi(group, guifg, guibg, attr, guisp) - local fg = guifg ~= '' and 'guifg=' .. guifg or 'guifg=NONE' - local bg = guibg ~= '' and 'guibg=' .. guibg or 'guibg=NONE' - local style = attr ~= '' and 'gui=' .. attr or 'gui=NONE' - local sp = guisp ~= '' and 'guisp=' .. guisp or '' - - local hl = 'hi ' .. group .. ' ' .. fg .. ' ' .. bg .. ' ' .. style .. ' ' .. sp - vim.api.nvim_command(hl) -end - -function M.highlight() - hi('ModeMsg', c.green, '', '', '') -end - -return M +return onedark diff --git a/home/.config/nvim/lua/themes/onedark/init.lua b/home/.config/nvim/lua/themes/onedark/init.lua new file mode 100644 index 0000000..b1f34ab --- /dev/null +++ b/home/.config/nvim/lua/themes/onedark/init.lua @@ -0,0 +1,10 @@ +local M = {} + +local c = require('themes.onedark.colors') +local hi = require('themes.util').highlight + +function M.highlight_editor() + hi('ModeMsg', c.fg, '', '', '') +end + +return M diff --git a/home/.config/nvim/lua/themes/util.lua b/home/.config/nvim/lua/themes/util.lua new file mode 100644 index 0000000..466e7e3 --- /dev/null +++ b/home/.config/nvim/lua/themes/util.lua @@ -0,0 +1,13 @@ +local M = {} + +function M.highlight(group, guifg, guibg, attr, guisp) + local fg = guifg ~= '' and 'guifg=' .. guifg or 'guifg=NONE' + local bg = guibg ~= '' and 'guibg=' .. guibg or 'guibg=NONE' + local style = attr ~= '' and 'gui=' .. attr or 'gui=NONE' + local sp = guisp ~= '' and 'guisp=' .. guisp or '' + + local hl = 'hi ' .. group .. ' ' .. fg .. ' ' .. bg .. ' ' .. style .. ' ' .. sp + vim.api.nvim_command(hl) +end + +return M diff --git a/home/.config/nvim/scripts/lsp/sumneko_lua b/home/.config/nvim/scripts/lsp/sumneko_lua index 9894645..03839c3 100755 --- a/home/.config/nvim/scripts/lsp/sumneko_lua +++ b/home/.config/nvim/scripts/lsp/sumneko_lua @@ -9,9 +9,9 @@ if [ -d "${server_path}" ]; then git pull else git clone https://github.com/sumneko/lua-language-server.git ${server_path} + cd ${server_path} fi -cd ${server_path} git submodule update --init --recursive # Build diff --git a/setup/scripts.sh b/setup/scripts.sh index b93b799..a5a117d 100755 --- a/setup/scripts.sh +++ b/setup/scripts.sh @@ -18,6 +18,9 @@ chmod 755 $HOME/.local/bin/fzf/adl curl -fL "https://github.com/pystardust/ytfzf/raw/master/ytfzf" -o $HOME/.local/bin/fzf/ytfzf chmod 755 $HOME/.local/bin/fzf/ytfzf +curl -fL "https://github.com/pystardust/ani-cli/raw/master/ani-cli" -o $HOME/.local/bin/ani-cli +chmod 755 $HOME/.local/bin/ani-cli + curl -fL "https://github.com/dilshod/xlsx2csv/raw/master/xlsx2csv.py" -o $HOME/.local/bin/xlsx2csv.py chmod 755 $HOME/.local/bin/xlsx2csv.py diff --git a/system/etc/tlp.d/00-custom.conf b/system/etc/tlp.d/00-custom.conf index 30f6f06..2d860bf 100644 --- a/system/etc/tlp.d/00-custom.conf +++ b/system/etc/tlp.d/00-custom.conf @@ -1,5 +1,5 @@ TLP_DEFAULT_MODE=BAT -#TLP_PS_IGNORE=BAT +#TLP_PERSISTENT_DEFAULT=1 CPU_SCALING_GOVERNOR_ON_BAT=ondemand CPU_SCALING_MIN_FREQ_ON_BAT=1400000 @@ -9,18 +9,16 @@ CPU_SCALING_MIN_FREQ_ON_AC=1400000 CPU_SCALING_MAX_FREQ_ON_AC=2100000 #DISK_DEVICES="nvme0n1 sda" -DISK_SPINDOWN_TIMEOUT_ON_BAT="0 0" +DISK_SPINDOWN_TIMEOUT_ON_AC="keep keep" +DISK_SPINDOWN_TIMEOUT_ON_BAT="keep 1" DISK_IOSCHED="mq-deadline mq-deadline" PCIE_ASPM_ON_BAT=default PCIE_ASPM_ON_AC=default -RADEON_POWER_PROFILE_ON_BAT=auto -RADEON_POWER_PROFILE_ON_AC=auto -RADEON_DPM_STATE_ON_BAT=battery -RADEON_DPM_STATE_ON_AC=performance - +#RESTORE_DEVICE_STATE_ON_STARTUP=1 DEVICES_TO_DISABLE_ON_STARTUP="bluetooth wifi wwan" +#DEVICES_TO_ENABLE_ON_STARTUP="wifi" DEVICES_TO_DISABLE_ON_BAT_NOT_IN_USE="bluetooth wifi wwan" START_CHARGE_THRESH_BAT0=70