nvim-treesitter / nvim-treesitter-textobjects

Apache License 2.0
2.11k stars 190 forks source link

Additional text-objects to be handled by incremental selection. #432

Open effinsky opened 1 year ago

effinsky commented 1 year ago

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.

ObserverOfTime commented 1 year ago

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.

effinsky commented 1 year ago

thanks, and thanks for the tip.

theHamsta commented 1 year ago

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

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