Skip to content

Commit 8ba6405

Browse files
committed
feat: add treesitter textobjects
1 parent 09f2e1d commit 8ba6405

File tree

6 files changed

+55
-0
lines changed

6 files changed

+55
-0
lines changed

docs/release-notes/rl-0.8.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,13 @@
325325

326326
[flash.nvim]: https://github.com/folke/flash.nvim
327327
[gitlinker.nvim]: https://github.com/linrongbin16/gitlinker.nvim
328+
[nvim-treesitter-textobjects]: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
328329

329330
- Fix oil config referencing snacks
330331
- Add [flash.nvim] plugin to `vim.utility.motion.flash-nvim`
331332
- Fix default telescope ignore list entry for '.git/' to properly match
332333
- Add [gitlinker.nvim] plugin to `vim.git.gitlinker-nvim`
334+
- Add [nvim-treesitter-textobjects] plugin to `vim.treesitter.textobjects`
333335

334336
[rrvsh](https://github.com/rrvsh):
335337

modules/plugins/treesitter/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
imports = [
33
# treesitter extras
44
./ts-context
5+
./ts-textobjects
56

67
./treesitter.nix
78
./config.nix
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
config,
3+
lib,
4+
...
5+
}: let
6+
inherit (lib.modules) mkIf;
7+
inherit (lib.nvim.lua) toLuaObject;
8+
inherit (lib.nvim.dag) entryAfter;
9+
10+
inherit (config.vim) treesitter;
11+
cfg = treesitter.textobjects;
12+
in {
13+
config = mkIf (treesitter.enable && cfg.enable) {
14+
vim = {
15+
startPlugins = ["nvim-treesitter-textobjects"];
16+
17+
# set up treesitter-textobjects after Treesitter and before mini-ai, which can then use
18+
# the provided textobjects.
19+
pluginRC.treesitter-textobjects = entryAfter ["treesitter"] ''
20+
require("nvim-treesitter.configs").setup({textobjects = ${toLuaObject cfg.setupOpts}})
21+
'';
22+
};
23+
};
24+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
imports = [
3+
./textobjects.nix
4+
./config.nix
5+
];
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{lib, ...}: let
2+
inherit (lib.options) mkEnableOption;
3+
inherit (lib.nvim.types) mkPluginSetupOption;
4+
in {
5+
options.vim.treesitter.textobjects = {
6+
enable = mkEnableOption "Treesitter textobjects";
7+
setupOpts = mkPluginSetupOption "treesitter-textobjects" {};
8+
};
9+
}

npins/sources.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,6 +1894,19 @@
18941894
"url": "https://github.com/nvim-treesitter/nvim-treesitter-context/archive/6daca3ad780f045550b820f262002f35175a6c04.tar.gz",
18951895
"hash": "0qprwd44hw9sz0vh14p6lpvs9vxrick462pfkradmal6ak1kfwn3"
18961896
},
1897+
"nvim-treesitter-textobjects": {
1898+
"type": "Git",
1899+
"repository": {
1900+
"type": "GitHub",
1901+
"owner": "nvim-treesitter",
1902+
"repo": "nvim-treesitter-textobjects"
1903+
},
1904+
"branch": "master",
1905+
"submodules": false,
1906+
"revision": "0e3be38005e9673d044e994b1e4b123adb040179",
1907+
"url": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects/archive/0e3be38005e9673d044e994b1e4b123adb040179.tar.gz",
1908+
"hash": "0y93pj3asarw7jhk4cdphhx6awxdyiwajc0n9nr4836gn48qcs85"
1909+
},
18971910
"nvim-ts-autotag": {
18981911
"type": "Git",
18991912
"repository": {

0 commit comments

Comments
 (0)