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