feat(treesitter): expand selection to sibling node #38938

Problem:
Can't expand treesitter-incremental-selection to the next and previous
sibling nodes.

Solution:
Pressing `]N` in visual mode will expand the selection to the next
sibling node, and `[N` will do the same with the previous node.
This commit is contained in:
altermo
2026-04-22 23:10:24 +02:00
committed by GitHub
parent 28ba068372
commit 451811b1be
5 changed files with 107 additions and 15 deletions

View File

@@ -466,6 +466,14 @@ do
require 'vim.treesitter._select'.select_next(vim.v.count1)
end, { desc = 'Select next node' })
vim.keymap.set({ 'x' }, '[N', function()
require 'vim.treesitter._select'.select_grow_prev(vim.v.count1)
end, { desc = 'Select expand previous node' })
vim.keymap.set({ 'x' }, ']N', function()
require 'vim.treesitter._select'.select_grow_next(vim.v.count1)
end, { desc = 'Select expand next node' })
vim.keymap.set({ 'x', 'o' }, 'an', function()
if vim.treesitter.get_parser(nil, nil, { error = false }) then
require 'vim.treesitter._select'.select_parent(vim.v.count1)