Bring back incremental_selection of nvim-treesitter
vim.pack.add("https://github.com/d-itu/incsel.nvim", { load = false })This plugin can be lazily loaded.
{
'd-itu/incsel.nvim',
keys = {
-- ...
},
},This plugin has no setup. It contains some functions which you can bind to your preferred keys.
Here is an example:
local incsel = require "incsel"
vim.keymap.set('n', '<CR>', function()
if not incsel.init_selection() then
vim.cmd "normal \r\n"
end
end, {
desc = "Start selecting nodes with nvim-treesitter"
})
vim.keymap.set('x', '<CR>', function()
if not incsel.incremental() then
vim.cmd "normal \r\n"
end
end, {
desc = "Increment selection to named node"
})
vim.keymap.set('x', '<BS>', function()
if not incsel.decremental() then
vim.cmd "normal \x1b"
end
end, {
desc = "Shrink selection to previous named node"
})