aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolodymyr Chernetskyi2024-02-19 17:37:02 +0000
committerGitHub2024-02-19 17:37:02 +0000
commit990378a46be2138b2f74799d1af8955390360c4e (patch)
tree399f19a914ea757599b9df86a4162176e7e708ab
parentcdef4f8a701f921c29fdfe66f104a2edac7fe05c (diff)
Add Groovy grammar (#9350)
* Add Groovy grammar * Rewrite Neovim captures into Helix for Groovy * Simplify Groovy injections Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * Remove Neovim's spell from Groovy highlights Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * Apply suggestions to languages.toml * Escape backslash in groovy highlights.scm --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml13
-rw-r--r--runtime/queries/groovy/highlights.scm96
-rw-r--r--runtime/queries/groovy/injections.scm2
4 files changed, 112 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index f46c9f5e..7aec3777 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -65,6 +65,7 @@
| gotmpl | ✓ | | | `gopls` |
| gowork | ✓ | | | `gopls` |
| graphql | ✓ | | | `graphql-lsp` |
+| groovy | ✓ | | | |
| hare | ✓ | | | |
| haskell | ✓ | ✓ | | `haskell-language-server-wrapper` |
| haskell-persistent | ✓ | | | |
diff --git a/languages.toml b/languages.toml
index e52dcabb..1c4c6126 100644
--- a/languages.toml
+++ b/languages.toml
@@ -3125,3 +3125,16 @@ 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", { glob = "Jenkinsfile" }, { glob = "Jenkinsfile.*" }]
+shebangs = ["groovy"]
+comment-token = "//"
+indent = { tab-width = 2, unit = " " }
+
+[[grammar]]
+name = "groovy"
+source = { git = "https://github.com/Decodetalkers/tree-sitter-groovy", rev = "7e023227f46fee428b16a0288eeb0f65ee2523ec" }
diff --git a/runtime/queries/groovy/highlights.scm b/runtime/queries/groovy/highlights.scm
new file mode 100644
index 00000000..4e94ccd3
--- /dev/null
+++ b/runtime/queries/groovy/highlights.scm
@@ -0,0 +1,96 @@
+(unit
+ (identifier) @variable)
+
+(string
+ (identifier) @variable)
+
+(escape_sequence) @constant.character.escape
+
+(block
+ (unit
+ (identifier) @namespace))
+
+(func
+ (identifier) @function)
+
+(number) @constant.numeric
+
+((identifier) @constant.builtin.boolean
+ (#any-of? @constant.builtin.boolean "true" "false"))
+
+((identifier) @constant
+ (#match? @constant "^[A-Z][A-Z\\d_]*$"))
+
+((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.storage.modifier
+ (#eq? @keyword.storage.modifier "static"))
+
+((identifier) @keyword.storage.type
+ (#any-of? @keyword.storage.type "class" "def" "interface"))
+
+((identifier) @keyword
+ (#any-of? @keyword
+ "assert"
+ "new"
+ "extends"
+ "implements"
+ "instanceof"))
+
+((identifier) @keyword.control.import
+ (#any-of? @keyword.control.import "import" "package"))
+
+((identifier) @keyword.storage.modifier
+ (#any-of? @keyword.storage.modifier
+ "abstract"
+ "protected"
+ "private"
+ "public"))
+
+((identifier) @keyword.control.exception
+ (#any-of? @keyword.control.exception
+ "throw"
+ "finally"
+ "try"
+ "catch"))
+
+(string) @string
+
+[
+ (line_comment)
+ (block_comment)
+] @comment
+
+((block_comment) @comment.block.documentation
+ (#match? @comment.block.documentation "^/[*][*][^*](?s:.)*[*]/$"))
+
+((line_comment) @comment.block.documentation
+ (#match? @comment.block.documentation "^///[^/]*.*$"))
+
+[
+ (operators)
+ (leading_key)
+] @operator
+
+["(" ")" "[" "]" "{" "}"] @punctuation.bracket
diff --git a/runtime/queries/groovy/injections.scm b/runtime/queries/groovy/injections.scm
new file mode 100644
index 00000000..e4509a5f
--- /dev/null
+++ b/runtime/queries/groovy/injections.scm
@@ -0,0 +1,2 @@
+([(line_comment) (block_comment)] @injection.content
+ (#set! injection.language "comment"))