From 5b8b04fc1b5f765d1e9f6f59e3309562b5feef35 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Tue, 2 Nov 2021 17:51:01 +0100 Subject: vim: fixup lsp and treesitter config --- .vim/lua/plugins.lua | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to '.vim/lua/plugins.lua') 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} -- }}} -- cgit 1.4.1