From 2ee9385753b519e7af6e26dd5c5e0572251de922 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Sat, 10 Sep 2022 08:12:47 +0100 Subject: added new go vim plugin --- vim/plugin/lsp.vim | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 vim/plugin/lsp.vim (limited to 'vim/plugin/lsp.vim') diff --git a/vim/plugin/lsp.vim b/vim/plugin/lsp.vim new file mode 100644 index 0000000..ea2f62d --- /dev/null +++ b/vim/plugin/lsp.vim @@ -0,0 +1,45 @@ +func! s:setup_ls(...) abort + let l:servers = lsp#get_allowed_servers() + + " key mappings + for l:server in l:servers + let l:cap = lsp#get_server_capabilities(l:server) + + if has_key(l:cap, 'completionProvider') + setlocal completefunc=lsp#complete + endif + + if has_key(l:cap, 'hoverProvider') + setlocal keywordprg=:LspHover + endif + + if has_key(l:cap, 'codeActionProvider') + nmap ga (lsp-code-action) + endif + + if has_key(l:cap, 'definitionProvider') + nmap gd (lsp-definition) + nmap gk (lsp-peek-definition) + endif + endfor +endfunc + +" register language server +augroup LSC + autocmd! + autocmd User lsp_setup call lsp#register_server({ + \ 'name': 'gopls', + \ 'cmd': {_->['gopls']}, + \ 'allowlist': ['go'] + \}) + + autocmd User lsp_server_init call setup_ls() + autocmd BufEnter * call setup_ls() +augroup END + +" disable diagnostics etc. +let g:lsp_diagnostics_enabled = 0 +let g:lsp_diagnostics_signs_enabled = 0 +let g:lsp_diagnostics_virtual_text_enabled = 0 +let g:lsp_diagnostics_highlights_enabled = 0 +let g:lsp_document_code_action_signs_enabled = 0 -- cgit v1.2.3