Skip to content

Commit 1b2a4a4

Browse files
chernetskyithe-mikedavis
authored andcommitted
Add Groovy grammar (helix-editor#9350)
* Add Groovy grammar * Rewrite Neovim captures into Helix for Groovy * Simplify Groovy injections Co-authored-by: Michael Davis <[email protected]> * Remove Neovim's spell from Groovy highlights Co-authored-by: Michael Davis <[email protected]> * Apply suggestions to languages.toml * Escape backslash in groovy highlights.scm --------- Co-authored-by: Michael Davis <[email protected]>
1 parent fd8b901 commit 1b2a4a4

File tree

4 files changed

+112
-0
lines changed

4 files changed

+112
-0
lines changed

book/src/generated/lang-support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
| gotmpl || | | `gopls` |
6666
| gowork || | | `gopls` |
6767
| graphql || | | `graphql-lsp` |
68+
| groovy || | | |
6869
| hare || | | |
6970
| haskell ||| | `haskell-language-server-wrapper` |
7071
| haskell-persistent || | | |

languages.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,3 +3125,16 @@ indent = { tab-width = 2, unit = " " }
31253125
[[grammar]]
31263126
name = "pkl"
31273127
source = { git = "https://github.com/apple/tree-sitter-pkl", rev = "c03f04a313b712f8ab00a2d862c10b37318699ae" }
3128+
3129+
[[language]]
3130+
name = "groovy"
3131+
language-id = "groovy"
3132+
scope = "source.groovy"
3133+
file-types = ["groovy", "jenkinsfile", { glob = "Jenkinsfile" }, { glob = "Jenkinsfile.*" }]
3134+
shebangs = ["groovy"]
3135+
comment-token = "//"
3136+
indent = { tab-width = 2, unit = " " }
3137+
3138+
[[grammar]]
3139+
name = "groovy"
3140+
source = { git = "https://github.com/Decodetalkers/tree-sitter-groovy", rev = "7e023227f46fee428b16a0288eeb0f65ee2523ec" }

runtime/queries/groovy/highlights.scm

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
(unit
2+
(identifier) @variable)
3+
4+
(string
5+
(identifier) @variable)
6+
7+
(escape_sequence) @constant.character.escape
8+
9+
(block
10+
(unit
11+
(identifier) @namespace))
12+
13+
(func
14+
(identifier) @function)
15+
16+
(number) @constant.numeric
17+
18+
((identifier) @constant.builtin.boolean
19+
(#any-of? @constant.builtin.boolean "true" "false"))
20+
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"))
77+
78+
(string) @string
79+
80+
[
81+
(line_comment)
82+
(block_comment)
83+
] @comment
84+
85+
((block_comment) @comment.block.documentation
86+
(#match? @comment.block.documentation "^/[*][*][^*](?s:.)*[*]/$"))
87+
88+
((line_comment) @comment.block.documentation
89+
(#match? @comment.block.documentation "^///[^/]*.*$"))
90+
91+
[
92+
(operators)
93+
(leading_key)
94+
] @operator
95+
96+
["(" ")" "[" "]" "{" "}"] @punctuation.bracket

runtime/queries/groovy/injections.scm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
([(line_comment) (block_comment)] @injection.content
2+
(#set! injection.language "comment"))

0 commit comments

Comments
 (0)