Skip to content

Commit 3532f60

Browse files
authored
fix(fennel): update queries for the new grammar (#570)
Updating queries to account for the new parser introduced in nvim-treesitter/nvim-treesitter#6132.
1 parent 739da25 commit 3532f60

File tree

1 file changed

+22
-40
lines changed

1 file changed

+22
-40
lines changed

queries/fennel/textobjects.scm

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,34 @@
1-
21
; https://fennel-lang.org/reference
32

43
(comment) @comment.outer
54

65
(_ . "(" ")" .) @statement.outer
76

8-
; functions
9-
((fn . name: (_)? . (parameters) . docstring: (_)? . (_) @_start . (_)* . (_)? @_end .)
10-
(#make-range! "function.inner" @_start @_end)) @function.outer
11-
12-
((lambda . name: (_)? . (parameters) . docstring: (_)? . (_) @_start . (_)* . (_)? @_end .)
13-
(#make-range! "function.inner" @_start @_end)) @function.outer
14-
15-
(hashfn ["#" "hashfn"] @function.outer.start (_) @function.inner) @function.outer
16-
17-
; parameters
18-
(parameters (_) @parameter.inner)
19-
(parameters (_) @parameter.outer)
7+
; functions & parameters
8+
(list .
9+
(symbol) @_fn
10+
(symbol)? @_fn_name
11+
(sequence
12+
(_) @parameter.inner)
13+
(_)* @function.inner
14+
(#any-of? @_fn "fn" "lambda" "λ")) @function.outer
2015

2116
; call
22-
((list . [(multi_symbol) (symbol)] @_sym . (_) @_start . (_)* . (_)? @_end .)
23-
(#make-range! "call.inner" @_start @_end)
24-
(#not-any-of? @_sym "if" "do" "while" "for" "let" "when")) @call.outer
17+
(list .
18+
(symbol) @_fn_name
19+
(_)* @call.inner
20+
(#not-any-of? @_fn_name "if" "do" "while" "for" "each" "let" "when" "fn")) @call.outer
2521

2622
; conditionals
27-
((list . ((symbol) @_if (#any-of? @_if "if" "when")) . (_) .
28-
(_) @_start .
29-
(_)* .
30-
(_)? @_end .)
31-
(#make-range! "conditional.inner" @_start @_end)) @conditional.outer
32-
23+
(list
24+
(symbol) @_cond
25+
(_)
26+
(_)* @conditional.inner
27+
(#any-of? @_cond "if" "when")) @conditional.outer
3328

3429
; loops
35-
((for . (for_clause) .
36-
(_) @_start .
37-
(_)* .
38-
(_)? @_end .)
39-
(#make-range! "loop.inner" @_start @_end)) @loop.outer
40-
41-
((each . (_) .
42-
(_) @_start .
43-
(_)* .
44-
(_)? @_end .)
45-
(#make-range! "loop.inner" @_start @_end)) @loop.outer
46-
47-
((list . ((symbol) @_while (#eq? @_while "while")) . (_) .
48-
(_) @_start .
49-
(_)* .
50-
(_)? @_end .)
51-
(#make-range! "loop.inner" @_start @_end)) @loop.outer
52-
30+
(list .
31+
(symbol) @_sym .
32+
(_) .
33+
(_)* @loop.inner
34+
(#any-of? @_sym "each" "while" "for")) @loop.outer

0 commit comments

Comments
 (0)