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 LSP for groovy #4303

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
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
14 changes: 14 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1835,3 +1835,17 @@ roots = []
[[grammar]]
name = "wast"
source = { git = "https://github.com/wasm-lsp/tree-sitter-wasm", rev = "2ca28a9f9d709847bf7a3de0942a84e912f59088", subpath = "wast" }

[[language]]
name = "groovy"
scope = "source.groovy"
injection-regex = "groovy"
file-types = ["groovy", "gvy", "gy", "gsh"]
comment-token = "//"
indent = { tab-width = 2, unit = " " }
language-server = { command = "java", args = ["-jar", "/Users/zephaniahong/Desktop/groovy-language-server/build/libs/groovy-language-server-all.jar"]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hard coded to your setup and shouldn't be upstreamed in this way

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! I'm just testing things out to get a better understanding. But the main issue is that, I can't get the syntax highlighting to work

roots = []

[[grammar]]
name = "groovy"
source = { git = "https://github.com/tree-sitter/tree-sitter-java", rev = "bd6186c24d5eb13b4623efac9d944dcc095c0dad" }
130 changes: 130 additions & 0 deletions runtime/queries/groovy/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
; Methods

(method_declaration
name: (identifier) @function.method)
(method_invocation
name: (identifier) @function.method)
(super) @function.builtin

; Annotations

(annotation
name: (identifier) @attribute)
(marker_annotation
name: (identifier) @attribute)

"@" @operator

; Types

(interface_declaration
name: (identifier) @type)
(class_declaration
name: (identifier) @type)
(enum_declaration
name: (identifier) @type)

((field_access
object: (identifier) @type)
(#match? @type "^[A-Z]"))
((scoped_identifier
scope: (identifier) @type)
(#match? @type "^[A-Z]"))

(constructor_declaration
name: (identifier) @type)

(type_identifier) @type

[
(boolean_type)
(integral_type)
(floating_point_type)
(floating_point_type)
(void_type)
] @type.builtin

; Variables

((identifier) @constant
(#match? @constant "^_*[A-Z][A-Z\\d_]+$"))

(identifier) @variable

(this) @variable.builtin

; Literals

[
(hex_integer_literal)
(decimal_integer_literal)
(octal_integer_literal)
] @constant.numeric.integer

[
(decimal_floating_point_literal)
(hex_floating_point_literal)
] @constant.numeric.float

(character_literal) @constant.character
(string_literal) @string

[
(true)
(false)
(null_literal)
] @constant.builtin

(comment) @comment

; Keywords

[
"abstract"
"assert"
"break"
"case"
"catch"
"class"
"continue"
"default"
"do"
"else"
"enum"
"exports"
"extends"
"final"
"finally"
"for"
"if"
"implements"
"import"
"instanceof"
"interface"
"module"
"native"
"new"
"open"
"opens"
"package"
"private"
"protected"
"provides"
"public"
"requires"
"return"
"static"
"strictfp"
"switch"
"synchronized"
"throw"
"throws"
"to"
"transient"
"transitive"
"try"
"uses"
"volatile"
"while"
"with"
] @keyword
2 changes: 2 additions & 0 deletions runtime/queries/groovy/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))