From 0654289eccbd75c33da94eda3daec3f299b7b824 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Sun, 26 Feb 2023 10:40:31 +0100 Subject: [PATCH] Update treesitter config --- dot_config/nvim/after/plugin/lsp.lua.tmpl | 14 +++- dot_config/nvim/after/plugin/treesitter.lua | 83 ++++++++++++++++++++- dot_zshrc.tmpl | 1 + 3 files changed, 93 insertions(+), 5 deletions(-) diff --git a/dot_config/nvim/after/plugin/lsp.lua.tmpl b/dot_config/nvim/after/plugin/lsp.lua.tmpl index 33b7866..534e008 100644 --- a/dot_config/nvim/after/plugin/lsp.lua.tmpl +++ b/dot_config/nvim/after/plugin/lsp.lua.tmpl @@ -158,7 +158,19 @@ local on_attach = function(client) bufmap('n', ']d', 'lua vim.diagnostic.goto_next()') end -lsp.gopls.setup { on_attach = on_attach } +lsp.gopls.setup { + settings = { + gopls = { + analyses = { + unusedparams = true, + unusedvariable = true, + shadow = true + }, + staticcheck = true, + }, + }, + on_attach = on_attach +} lsp.clangd.setup { on_attach = on_attach } lsp.ltex.setup { on_attach = on_attach } lsp.svelte.setup { on_attach = on_attach } diff --git a/dot_config/nvim/after/plugin/treesitter.lua b/dot_config/nvim/after/plugin/treesitter.lua index ed81546..a775e84 100644 --- a/dot_config/nvim/after/plugin/treesitter.lua +++ b/dot_config/nvim/after/plugin/treesitter.lua @@ -5,17 +5,92 @@ end treesitter.setup { + incremental_selection = { + enable = true, + keymaps = { + -- mappings for incremental selection (visual mappings) + init_selection = "gnn", -- maps in normal mode to init the node/scope selection + node_incremental = "grn", -- increment to the upper named parent + scope_incremental = "grc", -- increment to the upper scope (as defined in locals.scm) + node_decremental = "grm" -- decrement to the previous node + } + }, + textobjects = { + -- syntax-aware textobjects + enable = true, + lsp_interop = { + enable = true, + peek_definition_code = { + ["DF"] = "@function.outer", + } + }, + keymaps = { + ["iL"] = { + -- you can define your own textobjects directly here + go = "(function_definition) @function", + }, + -- or you use the queries from supported languages with textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["aC"] = "@class.outer", + ["iC"] = "@class.inner", + ["ac"] = "@conditional.outer", + ["ic"] = "@conditional.inner", + ["ae"] = "@block.outer", + ["ie"] = "@block.inner", + ["al"] = "@loop.outer", + ["il"] = "@loop.inner", + ["is"] = "@statement.inner", + ["as"] = "@statement.outer", + ["ad"] = "@comment.outer", + ["am"] = "@call.outer", + ["im"] = "@call.inner" + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]]"] = "@function.outer" + }, + goto_next_end = { + ["]["] = "@function.outer" + }, + goto_previous_start = { + ["[["] = "@function.outer" + }, + goto_previous_end = { + ["[]"] = "@function.outer" + } + }, select = { enable = true, lookahead = true, keymaps = { - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', + -- You can use the capture groups defined in textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + -- Or you can define your own textobjects like this + ["iF"] = { + python = "(function_definition) @function", + cpp = "(function_definition) @function", + c = "(function_definition) @function", + java = "(method_declaration) @function", + go = "(method_declaration) @function" + } } }, + swap = { + enable = true, + swap_next = { + ["a"] = "@parameter.inner" + }, + swap_previous = { + ["A"] = "@parameter.inner" + } + } }, ensure_installed = { 'javascript', diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl index 40ca3a7..8a873b7 100644 --- a/dot_zshrc.tmpl +++ b/dot_zshrc.tmpl @@ -47,6 +47,7 @@ export JAVA_HOME=/usr/local/jdk-11/ export PMIX_MCA_gds='hash' alias top='htop' +alias ctags='uctags' alias man='manpager.sh' alias mutt='neomutt' alias dvim='doas nvim'