nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects
Add `#make-range-between!`
Nobody has claimed this yet.
- Dominant language
- Tree-sitter Query
- Stars
- 2.8k
- Forks
- 271
- Avg merge
- 8d 8h
- Merged PRs (30d)
- 1
Description
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
_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing #make-range! directive implementation and its usages, then compare how it computes capture ranges. Add the analogous #make-range-between! behavior so the range runs from the end of @_start to the start of @_end, and verify it with the sequence_arguments example from the issue.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100