mrjosh / helm-ls

⎈ Language server for Helm ⎈

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for subcharts

ameddin73 opened this issue · comments

One really nice feature helm-ls is missing that other lsps have is "go to definition". It feels intuitive that you should be able to use the same shortcut that takes you to a variable definition in Go to get to a helper or values file definition in helm.

Has this been attempted? Is it hard? Would a PR be welcome?

This was added with #24 in v0.0.6.

Or do you mean something else?

Thanks, you're right. Upon further investigation this actually should be a bug report. It looks go to definition does work, but it doesn't work for nested helm charts which index values in the parent chart. For example:

# charts/subchart/templates/deployment.yaml
  image: {{ .Values.global.image.repository }}:latest
---
# values.yaml
image:
  repository: ghcr.io/stefanprodan/podinfo

Got to definition on repository fails. AFAICT there's no error, it's just a no-op.

Same with

# charts/subchart/templates/deployment.yaml
    image: {{ .Values.image.repository }}:latest
---
# values.yaml
subchart:
  image:
    repository: ghcr.io/stefanprodan/podinfo

Thanks for the detailed explanation. Subcharts are currently not supported, so I would flag this as a feature request.

Brief outline of the necessary changes to enable subchart support:

  • The current logic for selecting the workspace directory in helm-ls is based on finding the first Chart.yaml file by traversing the directory path up from the opened file (particularly for the nvim config). This logic needs adjustment to go up to the parent chart.

  • Currently, helm-ls relies on a single values.yaml file for operations like completions and hover. To support subcharts, the tool must be enhanced to parse and utilize multiple values.yaml files, ensuring they are applied according to the correct hierarchy. Additionally, adding support for multiple values.yaml files within the same hierarchy would be useful

If anyone is interested in making a first draft for this, feel free to open a PR.

Fixed in v0.0.10 with support for go to definition hover and completion.

@qvalentin - this doesn't seem to work for values which exist in the top-level values, but not in the subchart values.

Example:

image

values.yaml

---
global:
  namespace: default
  ...
...

charts/<subchart>/values.yaml

---
# no global section
...

I'm on this version:

helm_ls version
Helm-ls version: 0.0.12
Git commit: Homebrew
Build type: Release
Build time: 2024-03-10T18:12:42Z
Golang: go1.22.1
Compiled by: Homebrew

Hi @thatnerdjosh, thanks for reporting, seem like only the linting is broken (you will get false positives). Hover and go-to-defintion should work.
I will look into it.