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

Additional text-objects to be handled by incremental selection.

Open effinsky opened this issue 2 years ago • 3 comments

Is your feature request related to a problem? Please describe.

Incremental selection on nvim-ts is a useful feature, and is logically bound to ts-defined objects. I wonder if we could add more objects to it, so that, it'd not treat a string, for instance, as a single object, but select more gradually within the string, say inside a word ('iw'), for instance, then around word ('aw'), and then the entire string.

effinsky avatar Apr 04 '23 10:04 effinsky

It might be possible but only in the few languages that have nodes for words within strings.

P.S. This should probably go to nvim-treesitter-textobjects.

ObserverOfTime avatar Apr 05 '23 15:04 ObserverOfTime

thanks, and thanks for the tip.

effinsky avatar Apr 06 '23 05:04 effinsky

Nvim-treesitter does not have an incremental selection feature yet. Also, it can only select tree-sitter defined objects.

When you look at the source code of incremental selection it is roughly

  • get current selection
  • get node enclosing current selection
  • get parent of node
  • set new selection to new node's range

Isn't it possible to use regular b, w motion to extend a selection world-wise? Nvim-treesitter-textobjects would allow to do also certain tree-sitter motions

theHamsta avatar Apr 06 '23 07:04 theHamsta