]> Sergey Matveev's repositories - dotfiles.git/blobdiff - vim/.vim/plugin/lsp.vim
HI flag
[dotfiles.git] / vim / .vim / plugin / lsp.vim
index 7cf4c2fbcb24e38158cfdcee0291991e5e442d7e..a342e3cfe3398e2a0075bc5fe5edd49b29dbccc3 100644 (file)
@@ -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<dict<any>>
+
+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: "<C-W>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 <F6> :LSClientAllDiagnostics<CR>
+set omnifunc=g:LspOmniFunc
+autocmd VimEnter * call LspAddServer(lspServers)
+autocmd VimEnter * call LspOptionsSet(lspOpts)
+autocmd CursorMoved * silent! LspDiagCurrent
+nmap gd :LspGotoDefinition<CR>
+nmap <C-W>gd :vert LspGotoDefinition<CR>
+nmap <F6> :lopen<CR>
+nmap [l :LspDiagPrev<CR>
+nmap ]l :LspDiagNext<CR>