Helm (kubernetes) support
No idea what I'm doing, just trying to get Helm support added in.
Helm is a combo of YAML and go-templating. There is no "helm" tree-sitter at the moment.
YAML: https://github.com/ikatyang/tree-sitter-yaml Go Template: https://github.com/ngalaiko/tree-sitter-go-template
helm-ls: https://github.com/mrjosh/helm-ls
I'm not sure how to implement the helm language server or combine the YAML and go-template tree sitters, but I'd love to see it in here. If someone could help me through the process, I'd appreciate it.
Zed Issue: https://github.com/zed-industries/extensions/issues/186
We require contributors to sign our Contributor License Agreement, and we don't have @cabrinha on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.
@cla-bot check
The cla-bot has been summoned, and re-checked this pull request!
@caius I see you've added Make support in another PR, would you mind taking a look here and seeing if there is anything needs changing for helm support?
@SomeoneToIgnore mind taking a look?
We would need a docs entry for that, as all the other languages do.
I've tested this on https://github.com/helm/examples and https://github.com/helm/charts-repo-actions-demo and not sure I've liked what I saw:
highlights break right after the first yaml error
due to the same issue, outlines do not work as expected:
This is because Helm is combination of YAML syntax with Go templates mixed in. Everything between {{ }} is go-template syntax. I'm not sure how to combine these two things...
@SomeoneToIgnore I would enjoy learning how to combine yaml w/ go-templating with your help if possible!
@caius I see you've added Make support in another PR, would you mind taking a look here and seeing if there is anything needs changing for helm support?
Had a quick glance but not sure what you wanted me to look at specifically? None of it looks related to Make.
@caius I see you've added Make support in another PR, would you mind taking a look here and seeing if there is anything needs changing for helm support?
Had a quick glance but not sure what you wanted me to look at specifically? None of it looks related to Make.
Just figured you knew how to implement language support in Zed. I'm lost, but really want to get Kubernetes Helm support added in, there doesn't seem to be an easy tree-sitter plugin available here.
I also started a discussion trying to get some attention on this issue: https://github.com/zed-industries/zed/discussions/7260
I have no good idea how to combine those, mainly due to the fact that helm is context-dependent, if I understand it correctly? So a certain yaml file like https://github.com/helm/examples/blob/main/charts/hello-world/templates/deployment.yaml could be either a yaml one (if placed outside of that project or even into that project but not included into any of the imports?)
So I see two ways to consider:
- either add a different grammar to yaml, that is able to recover from {} templates and move on with highlighting — that looks like what VSCode does, given that screenshots contain both syntax errors and full highlights
- either somehow determine that it's a helm project and somehow disable yaml highlighting with something else? Sounds not feasible, since "something else" have to be, again, a grammar similar to the previous bullet.
Do note that Zed currently has zero ways to combine multiple syntax highlights in a single file: at best (if it even works), two associated grammars with a single file type will try to highlight it entirely, without splitting it into logical regions.
Sees like a big task, to be honest, I would start with something stadalone and a bit simpler: https://github.com/zed-industries/zed/pull/6905 as Docker does not break with its tree-sitter grammar, but would benefit from highlighting some of the things with bash language.
I do think it's possible to add correct syntax highlighting for Helm. We would need to parse the file primarily as a Go template, and then use language injection to parse all of the content outside of a {{ }} block as YAML. Overall, it's the same strategy that we use for the ERB template language.
Going to close this for now, but it should be possible to package this as an extension.