From 0e39a70f6a5d348dc306cee00149ff8cbc03ad43 Mon Sep 17 00:00:00 2001 From: Nathan Zeng Date: Mon, 13 Apr 2026 18:01:38 -0700 Subject: [PATCH] feat: remap treesitter incremental selection not to collide with mini.ai --- init.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/init.lua b/init.lua index 9f008fa502d..4c69fa802f0 100644 --- a/init.lua +++ b/init.lua @@ -921,6 +921,25 @@ require('lazy').setup({ end end, }) + + -- Treesitter incremental selection, see `:help treesitter-incremental-selection` + -- Note: the default keymaps `an` and `in` collide with mini.ai, so we remap them below + -- Try putting your cursor in one of the lines below and typing `v+` (then continue to type `+` or `-`) + vim.keymap.set({ 'x', 'o' }, '+', function() + if vim.treesitter.get_parser(nil, nil, { error = false }) then + require('vim.treesitter._select').select_parent(vim.v.count1) + else + vim.lsp.buf.selection_range(vim.v.count1) + end + end, { desc = 'Select parent (outer) node' }) + + vim.keymap.set({ 'x', 'o' }, '-', function() + if vim.treesitter.get_parser(nil, nil, { error = false }) then + require('vim.treesitter._select').select_child(vim.v.count1) + else + vim.lsp.buf.selection_range(-vim.v.count1) + end + end, { desc = 'Select child (inner) node' }) end, },