Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Groovy grammar #9350

Merged
merged 6 commits into from
Feb 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add Groovy grammar
chernetskyi committed Feb 19, 2024
commit 6290349d8ae0ac8a834ead5bfcd0155ee8f795a9
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@
| gotmpl || | | `gopls` |
| gowork || | | `gopls` |
| graphql || | | `graphql-lsp` |
| groovy || | | |
| hare || | | |
| haskell ||| | `haskell-language-server-wrapper` |
| haskell-persistent || | | |
14 changes: 14 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
@@ -3125,3 +3125,17 @@ indent = { tab-width = 2, unit = " " }
[[grammar]]
name = "pkl"
source = { git = "https://github.com/apple/tree-sitter-pkl", rev = "c03f04a313b712f8ab00a2d862c10b37318699ae" }

[[language]]
name = "groovy"
language-id = "groovy"
scope = "source.groovy"
file-types = ["groovy", "Jenkinsfile", "jenkinsfile"]
chernetskyi marked this conversation as resolved.
Show resolved Hide resolved
shebangs = ["groovy"]
roots = []
chernetskyi marked this conversation as resolved.
Show resolved Hide resolved
comment-token = "//"
indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "groovy"
source = { git = "https://github.com/Decodetalkers/tree-sitter-groovy", rev = "7e023227f46fee428b16a0288eeb0f65ee2523ec" }
95 changes: 95 additions & 0 deletions runtime/queries/groovy/highlights.scm
chernetskyi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
(unit
(identifier) @variable)
(string
(identifier) @variable)

(escape_sequence) @string.escape

(block
(unit
(identifier) @namespace))

(func
(identifier) @function)

(number) @number

((identifier) @boolean
(#any-of? @boolean "true" "false" "True" "False"))

((identifier) @constant
(#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
chernetskyi marked this conversation as resolved.
Show resolved Hide resolved

((identifier) @constant.builtin
(#eq? @constant.builtin "null"))

((identifier) @type
(#any-of? @type
"String"
"Map"
"Object"
"Boolean"
"Integer"
"List"))

((identifier) @function.builtin
(#any-of? @function.builtin
"void"
"id"
"version"
"apply"
"implementation"
"testImplementation"
"androidTestImplementation"
"debugImplementation"))

((identifier) @keyword
(#any-of? @keyword
"static"
"class"
"def"
"import"
"package"
"assert"
"extends"
"implements"
"instanceof"
"interface"
"new"))

((identifier) @type.qualifier
(#any-of? @type.qualifier
"abstract"
"protected"
"private"
"public"))

((identifier) @exception
(#any-of? @exception
"throw"
"finally"
"try"
"catch"))

(string) @string

[
(line_comment)
(block_comment)
] @comment @spell
chernetskyi marked this conversation as resolved.
Show resolved Hide resolved

((block_comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))

((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^///[^/]"))

((line_comment) @comment.documentation
(#lua-match? @comment.documentation "^///$"))

[
(operators)
(leading_key)
] @operator

["(" ")" "[" "]" "{" "}"] @punctuation.bracket
5 changes: 5 additions & 0 deletions runtime/queries/groovy/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
((block_comment) @injection.content
(#set! injection.language "comment"))

((line_comment) @injection.content
(#set! injection.language "comment"))
chernetskyi marked this conversation as resolved.
Show resolved Hide resolved