feat: add treesitter textobjects

This commit is contained in:
Christoph Koehler 2025-05-08 18:52:16 -06:00
commit 054e4a3b9c
No known key found for this signature in database
6 changed files with 66 additions and 0 deletions

View file

@ -0,0 +1,23 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.dag) entryAfter;
inherit (config.vim) treesitter;
cfg = treesitter.textobjects;
in {
config = mkIf (treesitter.enable && cfg.enable) {
vim = {
startPlugins = ["nvim-treesitter-textobjects"];
# set up treesitter-textobjects after Treesitter, whose config we're adding to.
pluginRC.treesitter-textobjects = entryAfter ["treesitter"] ''
require("nvim-treesitter.configs").setup({textobjects = ${toLuaObject cfg.setupOpts}})
'';
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./textobjects.nix
./config.nix
];
}

View file

@ -0,0 +1,21 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.treesitter.textobjects = {
enable = mkEnableOption "Treesitter textobjects";
setupOpts =
mkPluginSetupOption "treesitter-textobjects" {}
// {
example = {
select = {
enable = true;
lookahead = true;
keymaps = {
af = "@function.outer";
};
};
};
};
};
}