summary refs log tree commit diff
path: root/.vim
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2021-11-02 17:51:01 +0100
committerRobert Günzler <r@gnzler.io>2021-11-02 19:06:49 +0100
commit5b8b04fc1b5f765d1e9f6f59e3309562b5feef35 (patch)
tree1c1a392180f74f670a010959c17007aecef82300 /.vim
parent128828b8e993a457a35afd1c71bf0b5fbd1a8a25 (diff)
vim: fixup lsp and treesitter config
Diffstat (limited to '.vim')
-rw-r--r--.vim/lua/lsp.lua16
-rw-r--r--.vim/lua/plugins.lua35
2 files changed, 44 insertions, 7 deletions
diff --git a/.vim/lua/lsp.lua b/.vim/lua/lsp.lua
index 9822e2c..1b189d4 100644
--- a/.vim/lua/lsp.lua
+++ b/.vim/lua/lsp.lua
@@ -63,6 +63,10 @@ local my_attach = function(client, bufnr)
   }
 end
 
+local my_exit = function(code, signal, client_id)
+  spinner_lsp.on_exit(code, signal, client_id)
+end
+
 local setup = function()
   local caps = vim.lsp.protocol.make_client_capabilities()
   -- enable lsp-based snippets
@@ -93,12 +97,12 @@ local setup = function()
   -- overwrite codeAction handler to not ask for confirmation if only a single
   -- action is given
   vim.lsp.handlers['textDocument/codeAction'] = function(_, _, actions) -- {{{
-    if actions == nil or vim.tbl_isempty(actions) then
+    if actions == nil or #actions == 0 then
       -- skip printing 'no code actions available'
       return
     end
 
-    local action_cosen
+    local action_chosen
     if #actions == 1 then
       action_chosen = actions[1]
     else
@@ -138,11 +142,13 @@ local setup = function()
 
   -- lsp.ccls.setup {
   --  on_attach = my_attach,
+  --  on_exit = my_exit,
   --  capabilities = caps,
   -- }
 
   lsp.gopls.setup {
     on_attach = my_attach,
+    on_exit = my_exit,
     capabilities = caps,
     settings = {
       gopls = {
@@ -160,6 +166,7 @@ local setup = function()
 
   lsp.sumneko_lua.setup {
     on_attach = my_attach,
+    on_exit = my_exit,
     capabilities = caps,
     cmd = { 'lua-language-server' };
     settings = {
@@ -182,17 +189,20 @@ local setup = function()
 
   lsp.rust_analyzer.setup {
     on_attach = my_attach,
+    on_exit = my_exit,
     capabilities = caps,
-    cmd = { 'env', 'CARGO_TARGET_DIR=/tmp', 'rust-analyzer' },
+    cmd = { 'env', 'CARGO_TARGET_DIR=/tmp', 'RUST_SRC_PATH=/usr/src/rustlib/library', 'rust-analyzer' },
   }
 
   lsp.zls.setup {
     on_attach = my_attach,
+    on_exit = my_exit,
     capabilities = caps,
   }
 
   lsp.zk.setup {
     on_attach = my_attach,
+    on_exit = my_exit,
     capabilities = caps,
     root_dir = lsp.util.root_pattern('.zk/'),
   }
diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua
index e532c0a..b263ba2 100644
--- a/.vim/lua/plugins.lua
+++ b/.vim/lua/plugins.lua
@@ -79,15 +79,38 @@ return require('packer').startup({function()
     requires = {'nvim-lua/plenary.nvim'},
     config = function()
       local nls = require('null-ls')
+      local h = require('null-ls.helpers')
       nls.config {
+        -- debug = true,
         sources = {
           nls.builtins.diagnostics.shellcheck, -- *sh
           -- nls.builtins.formatting.clang_format, -- c*
           -- nls.builtins.formatting.gofumpt, -- go
           -- nls.builtins.formatting.json_tool, -- json
-          nls.builtins.formatting.rustfmt, -- rust
+          -- nls.builtins.formatting.rustfmt, -- rust
           nls.builtins.formatting.shfmt, -- *sh
           nls.builtins.formatting.yapf, -- python
+          h.make_builtin({
+            method = nls.methods.DIAGNOSTICS,
+            filetypes = { 'go' },
+            generator_opts = {
+              command = 'sh',
+              args = {
+                '-c',
+                'golangci-lint run --fix=false --out-format=tab -E gocritic | grep ^$RELNAME',
+              },
+              to_stdin = false,
+              check_exit_code = {0, 1},
+              format = 'line',
+              on_output = h.diagnostics.from_patterns({
+                {
+                  pattern = [[(.+):(%d+):(%d+)%s+([%w%_%-]+)%s+(.*)]],
+                  groups = { 'data', 'row', 'col', 'source', 'message' },
+                }
+              })
+            },
+            factory = h.generator_factory,
+          })
         }
       }
 
@@ -145,8 +168,7 @@ return require('packer').startup({function()
       'nvim-treesitter/nvim-treesitter-textobjects',
     },
     config = function()
-      require('nvim-treesitter.configs').setup {
-        ensure_installed = { 
+      local enabled = {
           'bash',
           'c',
           'c_sharp',
@@ -168,7 +190,12 @@ return require('packer').startup({function()
           'typescript',
           'vim',
           'yaml',
+          'zig',
         },
+      }
+
+      require('nvim-treesitter.configs').setup {
+        ensure_installed = enabled,
         highlight = {
           enable = true,
         },
@@ -217,7 +244,7 @@ return require('packer').startup({function()
       }
 
       augroup {
-        treesitter = {{ 'FileType', '*', [[ set foldmethod=expr foldexpr=nvim_treesitter#foldexpr() ]] }}
+        treesitter = {{ 'FileType', table.concat(enabled, ','), [[ set foldmethod=expr foldexpr=nvim_treesitter#foldexpr() ]] }}
       }
     end} -- }}}