mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-05 04:50:03 -04:00
feat(groovy)!: switch to more complete parser (#5957)
Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
This commit is contained in:
parent
95987ee2d6
commit
d4dac523d2
8 changed files with 295 additions and 51 deletions
|
|
@ -252,7 +252,7 @@ We are looking for maintainers to add more parsers and to write query files for
|
|||
- [x] [gowork](https://github.com/omertuc/tree-sitter-go-work) (maintained by @omertuc)
|
||||
- [x] [gpg](https://github.com/ObserverOfTime/tree-sitter-gpg-config) (maintained by @ObserverOfTime)
|
||||
- [x] [graphql](https://github.com/bkegley/tree-sitter-graphql) (maintained by @bkegley)
|
||||
- [x] [groovy](https://github.com/Decodetalkers/tree-sitter-groovy) (maintained by @Decodetalkers)
|
||||
- [x] [groovy](https://github.com/murtaza64/tree-sitter-groovy) (maintained by @murtaza64)
|
||||
- [x] [gstlaunch](https://github.com/theHamsta/tree-sitter-gstlaunch) (maintained by @theHamsta)
|
||||
- [ ] [hack](https://github.com/slackhq/tree-sitter-hack)
|
||||
- [x] [hare](https://github.com/amaanq/tree-sitter-hare) (maintained by @amaanq)
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@
|
|||
"revision": "5e66e961eee421786bdda8495ed1db045e06b5fe"
|
||||
},
|
||||
"groovy": {
|
||||
"revision": "7e023227f46fee428b16a0288eeb0f65ee2523ec"
|
||||
"revision": "e20f616e6223b66defabc82c29f52431ee66e269"
|
||||
},
|
||||
"gstlaunch": {
|
||||
"revision": "2c0d9c94d35e37aa63fa5002163c8480985b3e5b"
|
||||
|
|
|
|||
|
|
@ -737,11 +737,10 @@ list.gpg = {
|
|||
|
||||
list.groovy = {
|
||||
install_info = {
|
||||
url = "https://github.com/Decodetalkers/tree-sitter-groovy",
|
||||
url = "https://github.com/murtaza64/tree-sitter-groovy",
|
||||
files = { "src/parser.c" },
|
||||
branch = "gh-pages",
|
||||
},
|
||||
maintainers = { "@Decodetalkers" },
|
||||
maintainers = { "@murtaza64" },
|
||||
}
|
||||
|
||||
list.graphql = {
|
||||
|
|
|
|||
6
queries/groovy/folds.scm
Normal file
6
queries/groovy/folds.scm
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[
|
||||
(argument_list)
|
||||
(closure)
|
||||
(list)
|
||||
(map)
|
||||
] @fold
|
||||
|
|
@ -1,64 +1,86 @@
|
|||
(unit
|
||||
(identifier) @variable)
|
||||
[
|
||||
"!instanceof"
|
||||
"assert"
|
||||
"class"
|
||||
"extends"
|
||||
"instanceof"
|
||||
"package"
|
||||
] @keyword
|
||||
|
||||
(string
|
||||
(identifier) @variable)
|
||||
[
|
||||
"!in"
|
||||
"as"
|
||||
"in"
|
||||
] @keyword.operator
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
[
|
||||
"case"
|
||||
"default"
|
||||
"else"
|
||||
"if"
|
||||
"switch"
|
||||
] @keyword.conditional
|
||||
|
||||
(block
|
||||
(unit
|
||||
(identifier) @module))
|
||||
[
|
||||
"catch"
|
||||
"finally"
|
||||
"try"
|
||||
] @keyword.exception
|
||||
|
||||
(func
|
||||
(identifier) @function)
|
||||
"def" @keyword.function
|
||||
|
||||
(number) @number
|
||||
"import" @keyword.import
|
||||
|
||||
((identifier) @boolean
|
||||
(#any-of? @boolean "true" "false" "True" "False"))
|
||||
[
|
||||
"for"
|
||||
"while"
|
||||
(break)
|
||||
(continue)
|
||||
] @keyword.repeat
|
||||
|
||||
((identifier) @constant
|
||||
(#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
|
||||
"return" @keyword.return
|
||||
|
||||
((identifier) @constant.builtin
|
||||
(#eq? @constant.builtin "null"))
|
||||
[
|
||||
"true"
|
||||
"false"
|
||||
] @boolean
|
||||
|
||||
((identifier) @type
|
||||
(#any-of? @type "String" "Map" "Object" "Boolean" "Integer" "List"))
|
||||
(null) @constant.builtin
|
||||
|
||||
((identifier) @function.builtin
|
||||
(#any-of? @function.builtin "void" "id" "version" "apply" "implementation" "testImplementation" "androidTestImplementation" "debugImplementation"))
|
||||
"this" @variable.builtin
|
||||
|
||||
((identifier) @keyword
|
||||
(#any-of? @keyword "static" "class" "def" "import" "package" "assert" "extends" "implements" "instanceof" "interface" "new"))
|
||||
[
|
||||
"int"
|
||||
"char"
|
||||
"short"
|
||||
"long"
|
||||
"boolean"
|
||||
"float"
|
||||
"double"
|
||||
"void"
|
||||
] @type.builtin
|
||||
|
||||
((identifier) @type.qualifier
|
||||
(#any-of? @type.qualifier "abstract" "protected" "private" "public"))
|
||||
[
|
||||
"final"
|
||||
"private"
|
||||
"protected"
|
||||
"public"
|
||||
"static"
|
||||
"synchronized"
|
||||
] @type.qualifier
|
||||
|
||||
((identifier) @keyword.exception
|
||||
(#any-of? @keyword.exception "throw" "finally" "try" "catch"))
|
||||
(comment) @comment @spell
|
||||
|
||||
(shebang) @keyword.directive
|
||||
|
||||
(string) @string
|
||||
|
||||
[
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
] @comment @spell
|
||||
(string
|
||||
(escape_sequence) @string.escape)
|
||||
|
||||
((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
|
||||
(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))
|
||||
|
|
|
|||
35
queries/groovy/indents.scm
Normal file
35
queries/groovy/indents.scm
Normal file
|
|
@ -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
|
||||
|
|
@ -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"))
|
||||
|
|
|
|||
6
queries/groovy/locals.scm
Normal file
6
queries/groovy/locals.scm
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(function_definition) @local.scope
|
||||
|
||||
(parameter
|
||||
name: (identifier) @local.definition.parameter)
|
||||
|
||||
(identifier) @local.reference
|
||||
Loading…
Add table
Add a link
Reference in a new issue