Skip to content

Commit 701b6c2

Browse files
committed
Extend groovy support
- Use more complete parser introduced in nvm-treesitter in nvim-treesitter/nvim-treesitter@d4dac52 - Use groovy support when working with *.gradle files
1 parent 990378a commit 701b6c2

File tree

6 files changed

+305
-83
lines changed

6 files changed

+305
-83
lines changed

languages.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3130,11 +3130,11 @@ source = { git = "https://github.com/apple/tree-sitter-pkl", rev = "c03f04a313b7
31303130
name = "groovy"
31313131
language-id = "groovy"
31323132
scope = "source.groovy"
3133-
file-types = ["groovy", "jenkinsfile", { glob = "Jenkinsfile" }, { glob = "Jenkinsfile.*" }]
3133+
file-types = ["gradle", "groovy", "jenkinsfile", { glob = "Jenkinsfile" }, { glob = "Jenkinsfile.*" }]
31343134
shebangs = ["groovy"]
31353135
comment-token = "//"
31363136
indent = { tab-width = 2, unit = " " }
31373137

31383138
[[grammar]]
31393139
name = "groovy"
3140-
source = { git = "https://github.com/Decodetalkers/tree-sitter-groovy", rev = "7e023227f46fee428b16a0288eeb0f65ee2523ec" }
3140+
source = { git = "https://github.com/murtaza64/tree-sitter-groovy", rev = "235009aad0f580211fc12014bb0846c3910130c1" }

runtime/queries/groovy/folds.scm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
(argument_list)
3+
(closure)
4+
(list)
5+
(map)
6+
] @fold

runtime/queries/groovy/highlights.scm

Lines changed: 251 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,268 @@
1-
(unit
2-
(identifier) @variable)
1+
[
2+
"!instanceof"
3+
"assert"
4+
"class"
5+
"extends"
6+
"instanceof"
7+
"package"
8+
] @keyword
39

4-
(string
5-
(identifier) @variable)
10+
[
11+
"!in"
12+
"as"
13+
"in"
14+
] @keyword.operator
15+
16+
[
17+
"case"
18+
"default"
19+
"else"
20+
"if"
21+
"switch"
22+
] @keyword.conditional
623

7-
(escape_sequence) @constant.character.escape
24+
[
25+
"catch"
26+
"finally"
27+
"try"
28+
] @keyword.exception
829

9-
(block
10-
(unit
11-
(identifier) @namespace))
30+
"def" @keyword.function
1231

13-
(func
14-
(identifier) @function)
32+
"import" @keyword.import
1533

16-
(number) @constant.numeric
34+
[
35+
"for"
36+
"while"
37+
(break)
38+
(continue)
39+
] @keyword.repeat
1740

18-
((identifier) @constant.builtin.boolean
19-
(#any-of? @constant.builtin.boolean "true" "false"))
41+
"return" @keyword.return
2042

21-
((identifier) @constant
22-
(#match? @constant "^[A-Z][A-Z\\d_]*$"))
23-
24-
((identifier) @constant.builtin
25-
(#eq? @constant.builtin "null"))
26-
27-
((identifier) @type
28-
(#any-of? @type
29-
"String"
30-
"Map"
31-
"Object"
32-
"Boolean"
33-
"Integer"
34-
"List"))
35-
36-
((identifier) @function.builtin
37-
(#any-of? @function.builtin
38-
"void"
39-
"id"
40-
"version"
41-
"apply"
42-
"implementation"
43-
"testImplementation"
44-
"androidTestImplementation"
45-
"debugImplementation"))
46-
47-
((identifier) @keyword.storage.modifier
48-
(#eq? @keyword.storage.modifier "static"))
49-
50-
((identifier) @keyword.storage.type
51-
(#any-of? @keyword.storage.type "class" "def" "interface"))
52-
53-
((identifier) @keyword
54-
(#any-of? @keyword
55-
"assert"
56-
"new"
57-
"extends"
58-
"implements"
59-
"instanceof"))
60-
61-
((identifier) @keyword.control.import
62-
(#any-of? @keyword.control.import "import" "package"))
63-
64-
((identifier) @keyword.storage.modifier
65-
(#any-of? @keyword.storage.modifier
66-
"abstract"
67-
"protected"
68-
"private"
69-
"public"))
70-
71-
((identifier) @keyword.control.exception
72-
(#any-of? @keyword.control.exception
73-
"throw"
74-
"finally"
75-
"try"
76-
"catch"))
43+
[
44+
"true"
45+
"false"
46+
] @boolean
47+
48+
(null) @constant.builtin
49+
50+
"this" @variable.builtin
51+
52+
[
53+
"int"
54+
"char"
55+
"short"
56+
"long"
57+
"boolean"
58+
"float"
59+
"double"
60+
"void"
61+
] @type.builtin
62+
63+
[
64+
"final"
65+
"private"
66+
"protected"
67+
"public"
68+
"static"
69+
"synchronized"
70+
] @type.qualifier
71+
72+
(comment) @comment @spell
73+
74+
(shebang) @keyword.directive
7775

7876
(string) @string
7977

78+
(string
79+
(escape_sequence) @string.escape)
80+
81+
(string
82+
(interpolation
83+
"$" @punctuation.special))
84+
85+
[
86+
"("
87+
")"
88+
"["
89+
"]"
90+
"{"
91+
"}"
92+
] @punctuation.bracket
93+
8094
[
81-
(line_comment)
82-
(block_comment)
83-
] @comment
95+
":"
96+
","
97+
"."
98+
] @punctuation.delimiter
99+
100+
(number_literal) @number
84101

85-
((block_comment) @comment.block.documentation
86-
(#match? @comment.block.documentation "^/[*][*][^*](?s:.)*[*]/$"))
102+
(identifier) @variable
87103

88-
((line_comment) @comment.block.documentation
89-
(#match? @comment.block.documentation "^///[^/]*.*$"))
104+
((identifier) @constant
105+
(#match? @constant "^[A-Z][A-Z_]+"))
90106

91107
[
92-
(operators)
93-
(leading_key)
108+
"%"
109+
"*"
110+
"/"
111+
"+"
112+
"-"
113+
"<<"
114+
">>"
115+
">>>"
116+
".."
117+
"..<"
118+
"<..<"
119+
"<.."
120+
"<"
121+
"<="
122+
">"
123+
">="
124+
"=="
125+
"!="
126+
"<=>"
127+
"==="
128+
"!=="
129+
"=~"
130+
"==~"
131+
"&"
132+
"^"
133+
"|"
134+
"&&"
135+
"||"
136+
"?:"
137+
"+"
138+
"*"
139+
".&"
140+
".@"
141+
"?."
142+
"*."
143+
"*"
144+
"*:"
145+
"++"
146+
"--"
147+
"!"
94148
] @operator
95149

96-
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
150+
(string
151+
"/" @string)
152+
153+
(ternary_op
154+
([
155+
"?"
156+
":"
157+
]) @keyword.conditional.ternary)
158+
159+
(map
160+
(map_item
161+
key: (identifier) @variable.parameter))
162+
163+
(parameter
164+
type: (identifier) @type
165+
name: (identifier) @variable.parameter)
166+
167+
(generic_param
168+
name: (identifier) @variable.parameter)
169+
170+
(declaration
171+
type: (identifier) @type)
172+
173+
(function_definition
174+
type: (identifier) @type)
175+
176+
(function_declaration
177+
type: (identifier) @type)
178+
179+
(class_definition
180+
name: (identifier) @type)
181+
182+
(class_definition
183+
superclass: (identifier) @type)
184+
185+
(generic_param
186+
superclass: (identifier) @type)
187+
188+
(type_with_generics
189+
(identifier) @type)
190+
191+
(type_with_generics
192+
(generics
193+
(identifier) @type))
194+
195+
(generics
196+
[
197+
"<"
198+
">"
199+
] @punctuation.bracket)
200+
201+
(generic_parameters
202+
[
203+
"<"
204+
">"
205+
] @punctuation.bracket)
206+
207+
; TODO: Class literals with PascalCase
208+
(declaration
209+
"=" @operator)
210+
211+
(assignment
212+
"=" @operator)
213+
214+
(function_call
215+
function: (identifier) @function)
216+
217+
(function_call
218+
function:
219+
(dotted_identifier
220+
(identifier) @function .))
221+
222+
(function_call
223+
(argument_list
224+
(map_item
225+
key: (identifier) @variable.parameter)))
226+
227+
(juxt_function_call
228+
function: (identifier) @function)
229+
230+
(juxt_function_call
231+
function:
232+
(dotted_identifier
233+
(identifier) @function .))
234+
235+
(juxt_function_call
236+
(argument_list
237+
(map_item
238+
key: (identifier) @variable.parameter)))
239+
240+
(function_definition
241+
function: (identifier) @function)
242+
243+
(function_declaration
244+
function: (identifier) @function)
245+
246+
(annotation) @function.macro
247+
248+
(annotation
249+
(identifier) @function.macro)
250+
251+
"@interface" @function.macro
252+
253+
(groovy_doc) @comment.documentation @spell
254+
255+
(groovy_doc
256+
[
257+
(groovy_doc_param)
258+
(groovy_doc_throws)
259+
(groovy_doc_tag)
260+
] @string.special @nospell)
261+
262+
(groovy_doc
263+
(groovy_doc_param
264+
(identifier) @variable.parameter) @nospell)
265+
266+
(groovy_doc
267+
(groovy_doc_throws
268+
(identifier) @type @nospell))

0 commit comments

Comments
 (0)