aboutsummaryrefslogtreecommitdiffstats
path: root/queries/groovy
diff options
context:
space:
mode:
authorMurtaza <murtaza.javaid@gmail.com>2024-01-28 16:17:50 -0500
committerGitHub <noreply@github.com>2024-01-28 22:17:50 +0100
commitd4dac523d2546afc266eb9b5a7986690b5319c41 (patch)
tree4b3825cf6b50f65d1d5b5af8e3bceb293bbc749f /queries/groovy
parentUpdate parsers: query (diff)
downloadnvim-treesitter-d4dac523d2546afc266eb9b5a7986690b5319c41.tar
nvim-treesitter-d4dac523d2546afc266eb9b5a7986690b5319c41.tar.gz
nvim-treesitter-d4dac523d2546afc266eb9b5a7986690b5319c41.tar.bz2
nvim-treesitter-d4dac523d2546afc266eb9b5a7986690b5319c41.tar.lz
nvim-treesitter-d4dac523d2546afc266eb9b5a7986690b5319c41.tar.xz
nvim-treesitter-d4dac523d2546afc266eb9b5a7986690b5319c41.tar.zst
nvim-treesitter-d4dac523d2546afc266eb9b5a7986690b5319c41.zip
feat(groovy)!: switch to more complete parser (#5957)
Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
Diffstat (limited to 'queries/groovy')
-rw-r--r--queries/groovy/folds.scm6
-rw-r--r--queries/groovy/highlights.scm286
-rw-r--r--queries/groovy/indents.scm35
-rw-r--r--queries/groovy/injections.scm4
-rw-r--r--queries/groovy/locals.scm6
5 files changed, 291 insertions, 46 deletions
diff --git a/queries/groovy/folds.scm b/queries/groovy/folds.scm
new file mode 100644
index 000000000..354861a61
--- /dev/null
+++ b/queries/groovy/folds.scm
@@ -0,0 +1,6 @@
+[
+ (argument_list)
+ (closure)
+ (list)
+ (map)
+] @fold
diff --git a/queries/groovy/highlights.scm b/queries/groovy/highlights.scm
index 4306f17a3..aadd04fe4 100644
--- a/queries/groovy/highlights.scm
+++ b/queries/groovy/highlights.scm
@@ -1,64 +1,86 @@
-(unit
- (identifier) @variable)
-
-(string
- (identifier) @variable)
-
-(escape_sequence) @string.escape
-
-(block
- (unit
- (identifier) @module))
+[
+ "!instanceof"
+ "assert"
+ "class"
+ "extends"
+ "instanceof"
+ "package"
+] @keyword
-(func
- (identifier) @function)
+[
+ "!in"
+ "as"
+ "in"
+] @keyword.operator
-(number) @number
+[
+ "case"
+ "default"
+ "else"
+ "if"
+ "switch"
+] @keyword.conditional
-((identifier) @boolean
- (#any-of? @boolean "true" "false" "True" "False"))
+[
+ "catch"
+ "finally"
+ "try"
+] @keyword.exception
-((identifier) @constant
- (#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
+"def" @keyword.function
-((identifier) @constant.builtin
- (#eq? @constant.builtin "null"))
+"import" @keyword.import
-((identifier) @type
- (#any-of? @type "String" "Map" "Object" "Boolean" "Integer" "List"))
+[
+ "for"
+ "while"
+ (break)
+ (continue)
+] @keyword.repeat
-((identifier) @function.builtin
- (#any-of? @function.builtin "void" "id" "version" "apply" "implementation" "testImplementation" "androidTestImplementation" "debugImplementation"))
+"return" @keyword.return
-((identifier) @keyword
- (#any-of? @keyword "static" "class" "def" "import" "package" "assert" "extends" "implements" "instanceof" "interface" "new"))
+[
+ "true"
+ "false"
+] @boolean
-((identifier) @type.qualifier
- (#any-of? @type.qualifier "abstract" "protected" "private" "public"))
+(null) @constant.builtin
-((identifier) @keyword.exception
- (#any-of? @keyword.exception "throw" "finally" "try" "catch"))
+"this" @variable.builtin
-(string) @string
+[
+ "int"
+ "char"
+ "short"
+ "long"
+ "boolean"
+ "float"
+ "double"
+ "void"
+] @type.builtin
[
- (line_comment)
- (block_comment)
-] @comment @spell
+ "final"
+ "private"
+ "protected"
+ "public"
+ "static"
+ "synchronized"
+] @type.qualifier
-((block_comment) @comment.documentation
- (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
+(comment) @comment @spell
-((line_comment) @comment.documentation
- (#lua-match? @comment.documentation "^///[^/]"))
+(shebang) @keyword.directive
-((line_comment) @comment.documentation
- (#lua-match? @comment.documentation "^///$"))
+(string) @string
-[
- (operators)
- (leading_key)
-] @operator
+(string
+ (escape_sequence) @string.escape)
+
+(string
+ (interpolation
+ "$" @punctuation.special))
[
"("
@@ -68,3 +90,179 @@
"{"
"}"
] @punctuation.bracket
+
+[
+ ":"
+ ","
+ "."
+] @punctuation.delimiter
+
+(number_literal) @number
+
+(identifier) @variable
+
+((identifier) @constant
+ (#match? @constant "^[A-Z][A-Z_]+"))
+
+[
+ "%"
+ "*"
+ "/"
+ "+"
+ "-"
+ "<<"
+ ">>"
+ ">>>"
+ ".."
+ "..<"
+ "<..<"
+ "<.."
+ "<"
+ "<="
+ ">"
+ ">="
+ "=="
+ "!="
+ "<=>"
+ "==="
+ "!=="
+ "=~"
+ "==~"
+ "&"
+ "^"
+ "|"
+ "&&"
+ "||"
+ "?:"
+ "+"
+ "*"
+ ".&"
+ ".@"
+ "?."
+ "*."
+ "*"
+ "*:"
+ "++"
+ "--"
+ "!"
+] @operator
+
+(string
+ "/" @string)
+
+(ternary_op
+ ([
+ "?"
+ ":"
+ ]) @keyword.conditional.ternary)
+
+(map
+ (map_item
+ key: (identifier) @variable.parameter))
+
+(parameter
+ type: (identifier) @type
+ name: (identifier) @variable.parameter)
+
+(generic_param
+ name: (identifier) @variable.parameter)
+
+(declaration
+ type: (identifier) @type)
+
+(function_definition
+ type: (identifier) @type)
+
+(function_declaration
+ type: (identifier) @type)
+
+(class_definition
+ name: (identifier) @type)
+
+(class_definition
+ superclass: (identifier) @type)
+
+(generic_param
+ superclass: (identifier) @type)
+
+(type_with_generics
+ (identifier) @type)
+
+(type_with_generics
+ (generics
+ (identifier) @type))
+
+(generics
+ [
+ "<"
+ ">"
+ ] @punctuation.bracket)
+
+(generic_parameters
+ [
+ "<"
+ ">"
+ ] @punctuation.bracket)
+
+; TODO: Class literals with PascalCase
+(declaration
+ "=" @operator)
+
+(assignment
+ "=" @operator)
+
+(function_call
+ function: (identifier) @function)
+
+(function_call
+ function:
+ (dotted_identifier
+ (identifier) @function .))
+
+(function_call
+ (argument_list
+ (map_item
+ key: (identifier) @variable.parameter)))
+
+(juxt_function_call
+ function: (identifier) @function)
+
+(juxt_function_call
+ function:
+ (dotted_identifier
+ (identifier) @function .))
+
+(juxt_function_call
+ (argument_list
+ (map_item
+ key: (identifier) @variable.parameter)))
+
+(function_definition
+ function: (identifier) @function)
+
+(function_declaration
+ function: (identifier) @function)
+
+(annotation) @function.macro
+
+(annotation
+ (identifier) @function.macro)
+
+"@interface" @function.macro
+
+(groovy_doc) @comment.documentation @spell
+
+(groovy_doc
+ [
+ (groovy_doc_param)
+ (groovy_doc_throws)
+ (groovy_doc_tag)
+ ] @string.special @nospell)
+
+(groovy_doc
+ (groovy_doc_param
+ (identifier) @variable.parameter) @nospell)
+
+(groovy_doc
+ (groovy_doc_throws
+ (identifier) @type @nospell))
diff --git a/queries/groovy/indents.scm b/queries/groovy/indents.scm
new file mode 100644
index 000000000..888d50107
--- /dev/null
+++ b/queries/groovy/indents.scm
@@ -0,0 +1,35 @@
+[
+ (closure)
+ (map)
+ (list)
+ (argument_list)
+ (parameter_list)
+ (for_parameters)
+] @indent.begin
+
+; (function_definition "(" @indent.begin)
+(closure
+ "}" @indent.end)
+
+(argument_list
+ ")" @indent.end)
+
+(for_parameters
+ ")" @indent.end)
+
+((for_loop
+ body: (_) @_body) @indent.begin
+ (#not-has-type? @_body closure))
+
+; TODO: while, try
+(list
+ "]" @indent.end)
+
+(map
+ "]" @indent.end)
+
+[
+ "}"
+ ")"
+ "]"
+] @indent.branch
diff --git a/queries/groovy/injections.scm b/queries/groovy/injections.scm
index 14a5d393e..1c04c65fb 100644
--- a/queries/groovy/injections.scm
+++ b/queries/groovy/injections.scm
@@ -1,5 +1,5 @@
-((block_comment) @injection.content
+((comment) @injection.content
(#set! injection.language "comment"))
-((line_comment) @injection.content
+((groovy_doc) @injection.content
(#set! injection.language "comment"))
diff --git a/queries/groovy/locals.scm b/queries/groovy/locals.scm
new file mode 100644
index 000000000..23cb5f0cb
--- /dev/null
+++ b/queries/groovy/locals.scm
@@ -0,0 +1,6 @@
+(function_definition) @local.scope
+
+(parameter
+ name: (identifier) @local.definition.parameter)
+
+(identifier) @local.reference