X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=vim%2F.vim%2Fplugin%2Flsp.vim;h=1928046941157257f7e6d251d1b51478a863ada6;hb=HEAD;hp=621548b542491a19c5fe41be7b5dcf0879840375;hpb=abeca38b2bf8282f0ad673286bc51fbaf59d27f2;p=dotfiles.git diff --git a/vim/.vim/plugin/lsp.vim b/vim/.vim/plugin/lsp.vim index 621548b..a342e3c 100644 --- a/vim/.vim/plugin/lsp.vim +++ b/vim/.vim/plugin/lsp.vim @@ -1,19 +1,57 @@ -let g:asyncomplete_auto_completeopt = 0 -let g:asyncomplete_auto_popup = 0 -imap (asyncomplete_force_refresh) +vim9script -let g:lsp_highlight_references_enabled = 1 -let g:lsp_diagnostics_echo_cursor = 1 -let g:lsp_diagnostics_echo_delay = -1 +# go get golang.org/x/tools/gopls@latest +# pip install "python-language-server[all]" -function! s:on_lsp_buffer_enabled() abort - nmap [g (lsp-previous-diagnostic) - nmap ]g (lsp-next-diagnostic) - nmap gd (lsp-definition) - nmap K (lsp-hover) -endfunction +var lspServers: list> -augroup lsp_install - autocmd! - autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() -augroup END +for d in [ + { + filetype: ["c", "ch", "cpp"], + path: "clangd", + args: ["--log=error"], + }, + { + filetype: ["go", "gomod"], + path: "gopls", + syncInit: true, + }, + { + filetype: ["python"], + path: "pyls", + syncInit: true, + workspaceConfig: {pyls: { + configurationSources: ["flake8"], + plugins: { + mccabe: {enabled: false}, + }, + }}, + }, +] + if executable(d["path"]) + add(lspServers, d) + endif +endfor + +var lspOpts = { + ignoreMissingServer: true, + autoComplete: false, + + autoHighlight: true, + autoPopulateDiags: true, + + # Lint warning only on status line, do not show near cursor + showDiagInPopup: false, + showDiagOnStatusLine: true, + showSignature: false, +} + +set omnifunc=g:LspOmniFunc +autocmd VimEnter * call LspAddServer(lspServers) +autocmd VimEnter * call LspOptionsSet(lspOpts) +autocmd CursorMoved * silent! LspDiagCurrent +nmap gd :LspGotoDefinition +nmap gd :vert LspGotoDefinition +nmap :lopen +nmap [l :LspDiagPrev +nmap ]l :LspDiagNext