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 syntax definition / highlight for Groovy, specifically Jenkinsfiles #4211

Closed
weakphish opened this issue Oct 11, 2022 · 7 comments · Fixed by #9350
Closed

Add syntax definition / highlight for Groovy, specifically Jenkinsfiles #4211

weakphish opened this issue Oct 11, 2022 · 7 comments · Fixed by #9350
Labels
A-tree-sitter Area: Tree-sitter C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors E-help-wanted Call for participation: Extra attention is needed

Comments

@weakphish
Copy link
Contributor

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

@weakphish weakphish added the C-enhancement Category: Improvements label Oct 11, 2022
@the-mikedavis the-mikedavis added E-easy Call for participation: Experience needed to fix: Easy / not much E-help-wanted Call for participation: Extra attention is needed A-tree-sitter Area: Tree-sitter E-good-first-issue Call for participation: Issues suitable for new contributors labels Oct 12, 2022
@zephaniahong
Copy link

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!

@the-mikedavis
Copy link
Member

the-mikedavis commented Oct 15, 2022

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

@weakphish
Copy link
Contributor Author

Any updates on this?

@jlebon
Copy link
Contributor

jlebon commented Jun 30, 2023

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"]

@Lonestar137
Copy link

Lonestar137 commented Oct 23, 2023

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.

@britter
Copy link
Contributor

britter commented Feb 14, 2024

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

@Lonestar137
Copy link

Lonestar137 commented Feb 15, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tree-sitter Area: Tree-sitter C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors E-help-wanted Call for participation: Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants