File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -921,6 +921,25 @@ require('lazy').setup({
921921 end
922922 end ,
923923 })
924+
925+ -- Treesitter incremental selection, see `:help treesitter-incremental-selection`
926+ -- Note: the default keymaps `an` and `in` collide with mini.ai, so we remap them below
927+ -- Try putting your cursor in one of the lines below and typing `v+` (then continue to type `+` or `-`)
928+ vim .keymap .set ({ ' x' , ' o' }, ' +' , function ()
929+ if vim .treesitter .get_parser (nil , nil , { error = false }) then
930+ require (' vim.treesitter._select' ).select_parent (vim .v .count1 )
931+ else
932+ vim .lsp .buf .selection_range (vim .v .count1 )
933+ end
934+ end , { desc = ' Select parent (outer) node' })
935+
936+ vim .keymap .set ({ ' x' , ' o' }, ' -' , function ()
937+ if vim .treesitter .get_parser (nil , nil , { error = false }) then
938+ require (' vim.treesitter._select' ).select_child (vim .v .count1 )
939+ else
940+ vim .lsp .buf .selection_range (- vim .v .count1 )
941+ end
942+ end , { desc = ' Select child (inner) node' })
924943 end ,
925944 },
926945
You can’t perform that action at this time.
0 commit comments