helix icon indicating copy to clipboard operation
helix copied to clipboard

Add LSP for groovy

Open zephaniahong opened this issue 3 years ago • 7 comments

#4211 Hi! @the-mikedavis I'm trying to implement LSP and syntax highlighting for groovy. The LSP sorta works though it seems a little slow. But my main problem is trying to implement syntax highlighting. I tried copying the entire highlights.scm and injections.scm from java just to test things out but even that did not work. Any advice?

Thank you!

zephaniahong avatar Oct 16 '22 03:10 zephaniahong

There seems to be a separate grammar in development here? I'm not sure how different groovy is from Java https://github.com/codieboomboom/tree-sitter-groovy

archseer avatar Oct 16 '22 03:10 archseer

Try using inherits instead in the same way this was done for purescript https://github.com/helix-editor/helix/commit/2d958d6c50b10318e29f6dacc291d8fcafd66de9

archseer avatar Oct 16 '22 04:10 archseer

Tried it but still does not seem to work. Checked the logs and I'm getting this error: helix_core::syntax [ERROR] Could not parse queries for language "groovy". Are your grammars out of sync? Try running 'hx --grammar fetch' and 'hx --grammar build'. This query could not be parsed: QueryError { row: 78, column: 1, offset: 1256, message: "comment", kind: NodeType }

I've ensured that I've sync all my grammars by running the mentioned commands but I still get the same error

zephaniahong avatar Oct 16 '22 04:10 zephaniahong

If you use tree-sitter-groovy then you need to write queries specific to that implementation and can't just reuse the Java ones.

archseer avatar Oct 16 '22 06:10 archseer

I see! I'll give that a shot. I've changed the tree sitter back to Java and tried using inherits. Any advice on why that implementation does not work? I checked the logs and it did not produce any error. But there is no syntax highlighting. My worry is that if I can't even get groovy to work with something that is already working then I can't begin to work on the custom highlight queries.

The only way I've gotten syntax highlighting to work for groovy is by add the groovy file extension to the java language.

Thank you!

zephaniahong avatar Oct 16 '22 09:10 zephaniahong

I don't think groovy is close enough to java syntax-wise to use tree-sitter-java

the-mikedavis avatar Oct 16 '22 14:10 the-mikedavis

Yupp! But I just wanted to play around to make sure I understood the mechanics of how things were working. Once I wrap my head around it, I'll swap it out with tree-sitter-groovy and write queries for it.

zephaniahong avatar Oct 16 '22 14:10 zephaniahong