nvim-treesitter-textobjects
nvim-treesitter-textobjects copied to clipboard
[Question] Why is Alternations not working in this case?
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?
I believe list_lit and vec_lit in the alternation each need parens around them. Have you tried that?
([
(list_lit)
(vec_lit)
]
. value: (_) @_start
value: (_) @_end .
) @list_or_vec_lit