nvim-treesitter/nvim-treesitter-textobjects

Add `#make-range-between!`

alexmozaidze opened this issue · 0 comments

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

Currently, creating a range between nodes requires intermediate nodes that are inside what you selected:

((sequence_arguments
   .
   (_) @_start
   (_) @_end
   .
   ")" .)
 (#make-range! "parameter.outer" @_start @_end))

And if the behaviour also changes depending on how many elements there are in sequence_arguments, you must add several more queries that take this into account, which is extremely annoying and prone to mistakes.

Describe the solution you'd like

Add a new #make-range-between! directive, that creates a range that captures everything between @_start and @_end.

Instead of taking range (capture1.start)..(capture2.end) like #make-range! does, it would take (capture1.end)..(capture2.start).

This would allow creating queries to capture things inside something much, much easier!

Describe alternatives you've considered

_

Additional context

_