X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=vim%2F.vim%2Fplugin%2Flsp.vim;h=1928046941157257f7e6d251d1b51478a863ada6;hb=HEAD;hp=7cf4c2fbcb24e38158cfdcee0291991e5e442d7e;hpb=d60b54182c364848921783841c6a64d8eb4742c5;p=dotfiles.git diff --git a/vim/.vim/plugin/lsp.vim b/vim/.vim/plugin/lsp.vim index 7cf4c2f..a342e3c 100644 --- a/vim/.vim/plugin/lsp.vim +++ b/vim/.vim/plugin/lsp.vim @@ -1,29 +1,57 @@ vim9script # go get golang.org/x/tools/gopls@latest -# pip install 'python-language-server[all]' +# pip install "python-language-server[all]" -g:lsc_enable_autocomplete = false -g:lsc_server_commands = { - c: {command: "clangd --log=error"}, - cpp: {command: "clangd --log=error"}, - go: {command: "gopls", log_level: -1}, - python: { - command: "pyls", - workspace_config: {pyls: { +var lspServers: list> + +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}, }, }}, - enabled: false, }, -} -g:lsc_auto_map = { - GoToDefinition: "gd", - GoToDefinitionSplit: "gd", - ShowHover: true, - Completion: "omnifunc", +] + 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, } -map :LSClientAllDiagnostics +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