diff options
| author | Robert Günzler <r@gnzler.io> | 2022-06-15 04:43:32 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2022-06-15 04:43:32 +0200 |
| commit | 37e8a51ab0393b2232b9c7594560f29b7b2e0088 (patch) | |
| tree | 96bd595083cc2b0f6ef3c65eb6207f6b816516ec | |
| parent | 5d3c12f35fc1295032c494a14cf902ed091aeb89 (diff) | |
vim: add navic plugin
to show the current location inside the AST
| -rw-r--r-- | .vim/lua/lsp.lua | 30 | ||||
| -rw-r--r-- | .vim/lua/plugins.lua | 9 |
2 files changed, 27 insertions, 12 deletions
diff --git a/.vim/lua/lsp.lua b/.vim/lua/lsp.lua index 9d80889..e134cff 100644 --- a/.vim/lua/lsp.lua +++ b/.vim/lua/lsp.lua @@ -1,5 +1,6 @@ local lsp = require('lspconfig') local lspstatus = require('lsp-status') +local navic = require('nvim-navic') local my_attach = function(client, bufnr) if vim.opt.diff:get() then @@ -27,6 +28,9 @@ local my_attach = function(client, bufnr) }) lspstatus.on_attach(client) + if client.supports_method('textDocument/symbols') then + navic.attach(client, bufnr) + end if client.supports_method('textDocument/definition') then vim.keymap.set('n', '<C-]>' , vim.lsp.buf.definition) @@ -247,21 +251,23 @@ local setup = function() end end +local format = function(afile) + if vim.g.nofmt then return end + if not string.match(afile, '^/home/robert/devel/upstream') then + vim.lsp.buf.format() + if string.match(afile, '.go$') then + vim.lsp.buf.code_action({ only = {'source.organizeImports'} }) + end + -- vim.notify('%#MoreMsg#%#Italic# fmt') + vim.notify('%#MoreMsg#%#Italic# fmt') + end +end + return { my_attach = my_attach, my_exit = my_exit, capabilities = capabilities, setup = setup, - - format = function(afile) - if vim.g.nofmt then return end - if not string.match(afile, '^/home/robert/devel/upstream') then - vim.lsp.buf.format() - if string.match(afile, '.go$') then - vim.lsp.buf.code_action({ only = {'source.organizeImports'} }) - end - -- vim.notify('%#MoreMsg#%#Italic# fmt') - vim.notify('%#MoreMsg#%#Italic# fmt') - end - end, + format = format, + symbols = symbols, } diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua index b3b8d75..28fd193 100644 --- a/.vim/lua/plugins.lua +++ b/.vim/lua/plugins.lua @@ -365,6 +365,15 @@ require('packer').startup({function() lspstatus.register_progress() end} -- }}} + use {'SmiteshP/nvim-navic', -- {{{ + requires = {'neovim/nvim-lspconfig'}, + config = function() + local navic = require('nvim-navic') + navic.setup { + icons = package.loaded.lsp.symbols + } + end} -- }}} + use {'kosayoda/nvim-lightbulb', -- {{{ -- branch = 'virtual-text-column', config = function() |