LSP server to autocomplete Helm files.
The Helm files are parsed as YAML files. The trick is that the Helm files are
"redacted", i.e. all the {{...}} template placeholders are substituted with
# comment characters, so most of the time YAML tree-sitter
parser can figure proper hints.
I used YAML examples from ContainerSolutions and helm templates from helm/examples. A good playground to view tree-sitter output is on ast-grep.
When a file is opened, LSP can run an external initialization script. The script can, for example, download helm charts with helm dependencies update or helmfile fetch --output-dir charts/
[lazyvim][https://www.lazyvim.org/]
Definitions are taken from Kubernetes API. For sake of testing, in the repo we have only selected keys (the original from cluster can be much larger).
kubectl proxy
curl http://localhost:8001/openapi/v2 | python3 testdata/filter_kubernetes_api_schema.py > filtered_v2.json
- Show YAML parse errors (e.g. when there is a missing colon after a key) - It seems that tree-sitter for YAML marks the whole top node as erroneous.
Prerequisite is to have charts/ loaded with
helm dependencies update
- Copy the configuration to
~/.config/nvim/lua/plugins/lsp-yaml.lua cargo build
To make Helm autocomplete work, you need to deliver OpenAPI V2 definitions for your cluster resources, see below.
- Autocomplete for top-level props (when there is no "path to property").
- Go to
charts/directory - Parse Charts.yaml
- Parse
namefrom Charts.yaml - Later, parse dependencies.
- Parse
- Parse tgz
- Find the chart with "name"
- Load all the values files
- Parse all the values files
- On edit, find all the matching values and display hints.
- Go to
- Fix "redacting" by being more smart on what is replaced with what. e.g. values with placeholder, if-else blocks with spaces.
- BUG: Helm autocomplete does not work for top level fields.
- Autocomplete for all the values_... files.
- Have some reasonable installation script that bootstraps the schema.
- Underline error for API version and Kind, if not in the schema.
- Handle
hemlfile.yamland its dir structure:helmfile fetch --output-dir charts