nvim-treesitter-textobjects icon indicating copy to clipboard operation
nvim-treesitter-textobjects copied to clipboard

Refined incremental selection

Open glyh opened this issue 4 years ago • 1 comments

Although the original incremental selection is good, it can be improved. It goes from the very bottom to the top, which can be tedious sometimes. Leveraging text objects, we can ensure that what we select are always that text object we specified earlier.

Refined incremental selection work this way: User type some command that specify a text object and enter visual mode. When user increase or decrease the node in the syntax tree, he can only reach a new text object (or syntax structure) that can match the query.

I have some time and I'm happy to contribute this feature. XD

glyh avatar Aug 05 '21 12:08 glyh

For example, the following lua code:

function x()
  b = 2
  lambda = function()
    a = 1
  end
  c = 3
end

When user's cursor is in the function lambda, and run a command to select a text object that matches function.outer, he can only select the whole function, and when he increases, he will select function x, rather than the assignment for lambda.

glyh avatar Aug 05 '21 12:08 glyh