From 8c2d9b7ef00d998ae5eb7440e3ddd4d5a5cbc313 Mon Sep 17 00:00:00 2001 From: Roel de Cort Date: Sat, 13 Apr 2024 15:10:02 +0200 Subject: [PATCH] add treesitter context and text objects config --- config/plugins/treesitter/default.nix | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/config/plugins/treesitter/default.nix b/config/plugins/treesitter/default.nix index f192abf..5e21d73 100644 --- a/config/plugins/treesitter/default.nix +++ b/config/plugins/treesitter/default.nix @@ -7,5 +7,57 @@ nixvimInjections = true; grammarPackages = pkgs.vimPlugins.nvim-treesitter.allGrammars; }; + + plugins.treesitter-context = { + enable = true; + }; + plugins.treesitter-textobjects = { + enable = false; + select = { + enable = true; + lookahead = true; + keymaps = { + "aa" = "@parameter.outer"; + "ia" = "@parameter.inner"; + "af" = "@function.outer"; + "if" = "@function.inner"; + "ac" = "@class.outer"; + "ic" = "@class.inner"; + "ii" = "@conditional.inner"; + "ai" = "@conditional.outer"; + "il" = "@loop.inner"; + "al" = "@loop.outer"; + "at" = "@comment.outer"; + }; + }; + move = { + enable = true; + gotoNextStart = { + "]m" = "@function.outer"; + "]]" = "@class.outer"; + }; + gotoNextEnd = { + "]M" = "@function.outer"; + "][" = "@class.outer"; + }; + gotoPreviousStart = { + "[m" = "@function.outer"; + "[[" = "@class.outer"; + }; + gotoPreviousEnd = { + "[M" = "@function.outer"; + "[]" = "@class.outer"; + }; + }; + swap = { + enable = true; + swapNext = { + "a" = "@parameters.inner"; + }; + swapPrevious = { + "A" = "@parameter.outer"; + }; + }; + }; }