redhat-developer / yaml-language-server

Language Server for YAML Files
MIT License
1.08k stars 263 forks source link

Support for .tpf (Helm chart Yaml-based template files) #220

Open mickaelistria opened 4 years ago

mickaelistria commented 4 years ago

It seems like Helm Chart files are basically Kubernetes yaml files with templating capability in {{...}} blocks. It would be nice if Yaml Language Server could provide support for those files (by pre-setting schema, allowing validation/completion in {{...}} and so on.

nklmilojevic commented 3 years ago

What is needed for this to be added - how we can help? There is https://github.com/Azure/vscode-kubernetes-tools/blob/master/syntaxes/helm.tmLanguage.json which VSCode uses to correctly highlight Helm template syntax.

valorl commented 3 years ago

There seems to be a tree-sitter grammar for go templates. It might be useful here.

With tree-sitter and this grammar, the template blocks can be fully parsed into an AST that could be used for functionality beyond highlighting, such as diagnostics, autocomplete, etc.

https://github.com/ngalaiko/tree-sitter-go-template

luisdavim commented 2 years ago

It would be nice to make this work with templates in general and not just helm templates, {{...}} is the default delimiter set but it can be customised, and we also have Jinja and ERB....

kekscode commented 1 year ago

Just revisiting after nearly a year. Any new solutions or workarounds? @luisdavim any thoughts?

Kerwood commented 1 year ago

Would be nice to see this feature.

luisdavim commented 5 months ago

There is there now: https://github.com/mrjosh/helm-ls

luisdavim commented 5 months ago

This is the setup I landed on, install these 2 plugins:

Then configure the language server to run helm-ls for helm files, in my case, I use https://github.com/neoclide/coc.nvim so I have:

"languageserver": {
  "helm": {
    "command": "helm_ls",
    "args": ["serve"],
    "filetypes": ["helm", "helmfile"],
    "rootPatterns": ["Chart.yaml"]
  }
}

This solves the problems with all the diagnostics errors from yaml ls but still uses it under the covers if installed. There's a TreeSitter gramar for helm so that also works out nicely.