nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects
[Question] Why is Alternations not working in this case?
Nobody has claimed this yet.
- Dominant language
- Tree-sitter Query
- Stars
- 2.8k
- Forks
- 271
- Avg merge
- 8d 8h
- Merged PRs (30d)
- 1
Description
I'm trying to write an aQuery to select the inner range of either a list_lit or a vec_lit TSNode for Clojure
(+ 1 2 3) ;; list_lit
[1 2 3] ;; vec_lit
I've created individual queries for each type which work however, within an alternation it doesn't.
; -- Works: Get List start and end
(list_lit . value: (_) @_list_start value: (_) @_list_end .)
; -- Works: Get Vector start and end
(vec_lit . value: (_) @_vec_start value: (_) @_vec_end .)
; -- Alternations Fails: List or Vector inner start and end
([list_lit vec_lit] . value: (_) @_start value: (_) @_end .)
I don't know how to debug why it's not working. Could anyone help explain what's happening please?
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 reproducing the three Clojure query examples and compare the results for the individual patterns and the alternation. Consult the Tree-sitter query behavior relevant to alternations and document an explanation of why the combined query behaves differently, including a working form if the behavior is expected.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100