helix
helix copied to clipboard
Add syntax definition / highlight for Groovy, specifically Jenkinsfiles
Currently, no syntax highlighting exists for Jenkinsfiles, which are written in Groovy.
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!
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
Any updates on this?
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"]
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 did you have some time to prepare a PR?
@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.