Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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' })
Comment on lines +924 to +942
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this would fit better in the mini.nvim package spec?
That's the source of the conflict, and incremental selection is not exclusive to treesitter (it's also an lsp feature).

WDYT?

end,
},

Expand Down
Loading