helix icon indicating copy to clipboard operation
helix copied to clipboard

Add syntax definition / highlight for Groovy, specifically Jenkinsfiles

Open weakphish opened this issue 3 years ago • 7 comments

Currently, no syntax highlighting exists for Jenkinsfiles, which are written in Groovy.

weakphish avatar Oct 11 '22 18:10 weakphish

Hey! I'd be happy to give this issue a shot. @the-mikedavis May I get some advice as to which files/directories I should be looking at?

Thank you!

zephaniahong avatar Oct 15 '22 12:10 zephaniahong

Take a look at the adding languages guide https://docs.helix-editor.com/guides/adding_languages.html and recent PRs that added languages https://github.com/helix-editor/helix/pulls?q=is%3Apr+is%3Amerged+add+language

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

Any updates on this?

weakphish avatar Jun 30 '23 17:06 weakphish

If it helps anyone else, parsing it as Java works OK (definitely not perfect, but better than no highlighting at all). I've put this in my ~/.config/helix/languages.toml:

[[language]]
name = "java"
file-types = ["java", "groovy", "Jenkinsfile", "jenkinsfile"]

jlebon avatar Jun 30 '23 18:06 jlebon

According to the Helix documentation Language Config, adding the following to the languages.toml in your helix config location should provide syntax highlighting.

[[language]]
name = "groovy"
scope = "source.groovy"
injection-regex = "groovy"
file-types = ["groovy", "Jenkinsfile"]
roots = []

[[grammar]]
name = "groovy"
source = { git = "https://github.com/Decodetalkers/tree-sitter-groovy", rev = "gh-pages" }

If I'm not wrong, the only missing part is adding queries in runtime/queries/ if I have time later this week, I'll do this and look at opening a PR cause I would like syntax highlighting for Jenkinsfiles.

Lonestar137 avatar Oct 23 '23 03:10 Lonestar137

@Lonestar137 did you have some time to prepare a PR?

britter avatar Feb 14 '24 09:02 britter

@britter No, I just added the nvim treesitter queries and moved on, I haven't had time to learn treesitter. The highlighting isn't perfect but it's good enough for me. You can either use the changes from the pull request above or use my helix config if you need a reference on how to set it up https://github.com/Lonestar137/helix-config/tree/main

You need the query files under runtime/ and the config mentioned in my prior post. Don't forget to build the grammars afterward.

Lonestar137 avatar Feb 15 '24 08:02 Lonestar137