From 84c528ddb1db40aa4aae09d64427124f3597ad6c Mon Sep 17 00:00:00 2001 From: FollieHiyuki Date: Thu, 15 Jul 2021 02:59:31 +0300 Subject: [PATCH] neovim: add trouble.nvim Also update treesitter highlight groups to be aligned with original nord.vim --- home/.config/nvim/lua/colors/nord.lua | 52 ++++++++------------ home/.config/nvim/lua/mappings.lua | 22 ++++++--- home/.config/nvim/lua/modules/lsptrouble.lua | 17 +++++++ home/.config/nvim/lua/plugins.lua | 11 ++++- 4 files changed, 61 insertions(+), 41 deletions(-) create mode 100644 home/.config/nvim/lua/modules/lsptrouble.lua diff --git a/home/.config/nvim/lua/colors/nord.lua b/home/.config/nvim/lua/colors/nord.lua index bf91549..eaeda7f 100644 --- a/home/.config/nvim/lua/colors/nord.lua +++ b/home/.config/nvim/lua/colors/nord.lua @@ -137,6 +137,7 @@ local function highlight_syntax() hi('Conceal', '', '', '', '') hi('Conditional', c.blue, '', '', '') hi('Constant', c.fg, '', '', '') + hi('Decorator', c.orange, '', '', '') hi('Define', c.blue, '', '', '') hi('Delimiter', c.white2, '', '', '') hi('Exception', c.blue, '', '', '') @@ -161,8 +162,10 @@ local function highlight_syntax() hi('Todo', c.yellow, '', '', '') hi('Type', c.blue, '', '', '') hi('Typedef', c.blue, '', '', '') + vim.cmd('hi! link Annotation Decorator') vim.cmd('hi! link Macro Define') vim.cmd('hi! link PreCondit PreProc') + vim.cmd('hi! link Variable Identifier') -- Diff hi('DiffAdd' , c.green , c.grey1, '', '') @@ -182,37 +185,21 @@ end -- Treesitter local function highlight_treesitter() - hi('TSAnnotation' , c.orange, '', '', '') - hi('TSCharacter' , c.fg , '', '', '') - hi('TSConstructor' , c.blue , '', '', '') - hi('TSConstant' , c.fg , '', '', '') - hi('TSFloat' , c.purple, '', '', '') - hi('TSNumber' , c.purple, '', '', '') - hi('TSString' , c.green , '', '', '') - hi('TSAttribute' , c.purple, '', '', '') - hi('TSBoolean' , c.blue , '', '', '') - hi('TSConstBuiltin', c.teal , '', '', '') - hi('TSConstMacro' , c.teal , '', '', '') - hi('TSError' , c.fg , c.red, '', '') - hi('TSException' , c.red , '', 'underline', '') - hi('TSField' , c.fg , '', '', '') - hi('TSFuncMacro' , c.cyan , '', '', '') - hi('TSInclude' , c.teal , '', '', '') - hi('TSLabel' , c.blue , '', '', '') - hi('TSNamespace' , c.teal , '', '', '') - hi('TSOperator' , c.blue , '', '', '') - hi('TSParameter' , c.dark_blue, '', '', '') - hi('TSParameterReference', c.dark_blue, '', '', '') - hi('TSProperty' , c.fg , '', '', '') - hi('TSPunctDelimiter', c.white2, '', '', '') - hi('TSPunctBracket', c.white2, '', '', '') - hi('TSPunctSpecial', c.white2 , '', '', '') - hi('TSStringRegex' , c.teal, '', '', '') - hi('TSStringEscape', c.grey2, '', '', '') - hi('TSSymbol' , c.purple, '', '', '') - hi('TSType' , c.blue , '', '', '') - hi('TSTypeBuiltin' , c.blue, '', '', '') - hi('TSTag' , c.teal, '', '', '') + -- tree-sitter + vim.cmd('hi! link TSAnnotation Annotation') + vim.cmd('hi! link TSConstBuiltin Constant') + vim.cmd('hi! link TSConstructor Function') + vim.cmd('hi! link TSEmphasis Italic') + vim.cmd('hi! link TSError Error') + vim.cmd('hi! link TSFuncBuiltin Function') + vim.cmd('hi! link TSFuncMacro Function') + vim.cmd('hi! link TSStringRegex SpecialChar') + vim.cmd('hi! link TSStrong Bold') + vim.cmd('hi! link TSStructure Structure') + vim.cmd('hi! link TSTagDelimiter TSTag') + vim.cmd('hi! link TSUnderline Underline') + vim.cmd('hi! link TSVariable Variable') + vim.cmd('hi! link TSVariableBuiltin Keyword') -- ts-rainbow hi('rainbowcol1', c.red, '', 'bold', '') @@ -300,6 +287,9 @@ local function highlight_plugins() -- vim-illuminate vim.cmd('hi! link illuminatedWord Underline') + -- trouble.nvim + hi('LspTroubleText', c.blue, '', 'bold', '') + -- Telescope hi('TelescopePromptBorder', c.cyan, '', 'bold', '') hi('TelescopeResultsBorder', c.blue, '', 'bold', '') diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index ef56b4f..49d7313 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -26,10 +26,10 @@ wk.register({ L = {'$', 'End of the line'}, -- Easier moving between windows - [''] = {'h', 'Go to the left window'}, - [''] = {'l', 'Go to the right window'}, - [''] = {'j', 'Go to the down window'}, - [''] = {'k', 'Go to the up window'}, + -- [''] = {'h', 'Go to the left window'}, + -- [''] = {'l', 'Go to the right window'}, + -- [''] = {'j', 'Go to the down window'}, + -- [''] = {'k', 'Go to the up window'}, -- Copy the whole buffer [''] = {'%y+', 'Copy whole buffer'}, @@ -82,7 +82,8 @@ wk.register({ d = 'Go to definition', D = 'Go to declaration', i = 'Go to implementation', - r = 'Go to references' + r = 'Go to references', + R = {'TroubleToggle lsp_references', 'Reference list'} }, K = {name = 'Hover'}, z = {name = 'Misc utils'}, @@ -152,12 +153,12 @@ wk.register({ a = 'Add workspace folder', d = 'Type definition', e = 'Line diagnostics', - l = 'List workspace folders', + l = 'Set diagnostics loclist', n = 'Rename in buffer', o = 'Format buffer', - q = 'Set diagnostics loclist', r = 'Remove workspace folder', s = 'Signature help', + w = 'List workspace folders', f = { name = 'Telescope', a = {':Telescope lsp_code_actions', 'Code actions'}, @@ -170,7 +171,12 @@ wk.register({ r = {':Telescope lsp_references', 'References'}, s = {':Telescope lsp_document_symbols', 'Buffer symbols'}, S = {':Telescope lsp_workspace_symbols', 'Workspace symbols'} - } + }, + D = {'TroubleToggle lsp_definitions', 'Definition list'}, + E = {'TroubleToggle lsp_document_diagnostics', 'Document diagnostics list'}, + W = {'TroubleToggle lsp_workspace_diagnostics', 'Workspace diagnostics list'}, + L = {'TroubleToggle loclist', 'Location list items'}, + Q = {'TroubleToggle quickfix', 'Quickfix list'} }, -- Git diff --git a/home/.config/nvim/lua/modules/lsptrouble.lua b/home/.config/nvim/lua/modules/lsptrouble.lua new file mode 100644 index 0000000..41ce577 --- /dev/null +++ b/home/.config/nvim/lua/modules/lsptrouble.lua @@ -0,0 +1,17 @@ +return require('trouble').setup { + mode = 'lsp_workspace_diagnostics', + fold_open = ' ', + fold_closed = '', + action_keys = { + open_split = {''}, + open_vsplit = {''}, + open_tab = {''} + }, + signs = { + error = '', + warning = '', + hint = '', + information = '', + other = '' + } +} diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 2606fa2..5200a67 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -128,11 +128,18 @@ return require('packer').startup( } use { 'onsails/lspkind-nvim', - event = 'BufRead', + event = 'InsertEnter', config = function() require('lspkind').init({with_text = false}) end } + use { + 'folke/trouble.nvim', + event = 'BufRead', + config = function() + require('modules.lsptrouble') + end + } use { 'hrsh7th/nvim-compe', event = 'InsertEnter', @@ -306,6 +313,6 @@ return require('packer').startup( end } - -- TODO: trouble.nvim, lspsaga, orgmode.nvim, TrueZen/zen-mode, nvim-lint, vim-spectre, nvim-dap, hop.nvim, dial.nvim, asynctasks.nvim + -- TODO: lspsaga, orgmode.nvim, TrueZen/zen-mode, nvim-lint, vim-spectre, nvim-dap, hop.nvim, dial.nvim, asynctasks.nvim end )