From 37e8a51ab0393b2232b9c7594560f29b7b2e0088 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Wed, 15 Jun 2022 04:43:32 +0200 Subject: vim: add navic plugin to show the current location inside the AST --- .vim/lua/lsp.lua | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to '.vim/lua/lsp.lua') 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', '' , 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, } -- cgit 1.4.1