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

Helm (kubernetes) support #7259

Closed
wants to merge 4 commits into from
Closed

Conversation

cabrinha
Copy link
Contributor

@cabrinha cabrinha commented Feb 2, 2024

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: zed-industries/extensions#186

Screenshot 2024-02-02 at 8 29 43 PM

Copy link

cla-bot bot commented Feb 2, 2024

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 cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 2, 2024
@cabrinha cabrinha changed the title Adding syntax highlighting for Helm Helm support Feb 2, 2024
@cabrinha
Copy link
Contributor Author

cabrinha commented Feb 2, 2024

@cla-bot check

Copy link

cla-bot bot commented Feb 2, 2024

The cla-bot has been summoned, and re-checked this pull request!

@cabrinha cabrinha changed the title Helm support Helm (kubernetes) support Feb 2, 2024
@cabrinha
Copy link
Contributor Author

cabrinha commented Feb 7, 2024

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

@cabrinha
Copy link
Contributor Author

cabrinha commented Feb 7, 2024

@SomeoneToIgnore mind taking a look?

Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

image
image

  • due to the same issue, outlines do not work as expected:

image

]

increase_indent_pattern = ":\\s*[|>]?\\s*$"
prettier_parser_name = "yaml"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep newlines at the end of the files, as we do in the rest of the files around.
Funny that you did that in one of the *.scm files but not here and other *.scm files.

@cabrinha
Copy link
Contributor Author

cabrinha commented Feb 8, 2024

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

@cabrinha
Copy link
Contributor Author

cabrinha commented Feb 8, 2024

@SomeoneToIgnore I would enjoy learning how to combine yaml w/ go-templating with your help if possible!

@caius
Copy link
Contributor

caius commented Feb 8, 2024

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

@cabrinha
Copy link
Contributor Author

cabrinha commented Feb 8, 2024

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

@cabrinha
Copy link
Contributor Author

cabrinha commented Feb 8, 2024

I also started a discussion trying to get some attention on this issue: #7260

@SomeoneToIgnore
Copy link
Contributor

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: #6905 as Docker does not break with its tree-sitter grammar, but would benefit from highlighting some of the things with bash language.

@SomeoneToIgnore SomeoneToIgnore marked this pull request as draft February 8, 2024 19:42
@maxbrunsfeld
Copy link
Collaborator

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.

@ConradIrwin
Copy link
Member

Going to close this for now, but it should be possible to package this as an extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants