diff --git a/modules/programs/nvim/new_plugins/treesitter-textobjects.nix b/modules/programs/nvim/new_plugins/treesitter-textobjects.nix new file mode 100644 index 0000000..589b923 --- /dev/null +++ b/modules/programs/nvim/new_plugins/treesitter-textobjects.nix @@ -0,0 +1,91 @@ +{ config, lib, pkgs, inputs, ... }: + +let + inherit (lib) mkEnableOption mkIf readFile; +in +{ + home-manager.users.moritz.programs.nixvim = { + plugins.treesitter-textobjects = { + enable = true; + move = { + enable = true; + gotoNext = { + "]f" = { + desc = "Next function"; + query = "@function.outer"; + }; + "]c" = { + desc = "Next class"; + query = "@class.outer"; + }; + "]b" = { + desc = "Next block"; + query = "@block.outer"; + }; + "]P" = { + desc = "Next parameter"; + query = "@parameter.outer"; + }; + }; + gotoPrevious = { + "[f" = { + desc = "Previous function"; + query = "@function.outer"; + }; + "[c" = { + desc = "Previous class"; + query = "@class.outer"; + }; + "[b" = { + desc = "Previous block"; + query = "@block.outer"; + }; + "[P" = { + desc = "Previous parameter"; + query = "@parameter.outer"; + }; + }; + }; + select = { + enable = true; + keymaps = { + "af" = { + desc = "function"; + query = "@function.outer"; + }; + "if" = { + desc = "inner function"; + query = "@function.inner"; + }; + "ac" = { + desc = "class"; + query = "@class.outer"; + }; + "ic" = { + desc = "inner class"; + query = "@class.inner"; + }; + "ab" = { + desc = "block"; + query = "@block.outer"; + }; + "ib" = { + desc = "inner block"; + query = "@block.inner"; + }; + "aP" = { + desc = "parameter"; + query = "@parameter.outer"; + }; + "iP" = { + desc = "inner parameter"; + query = "@parameter.inner"; + }; + }; + }; + }; + performance.combinePlugins.standalonePlugins = [ + "nvim-treesitter-textobjects" + ]; + }; +}