Home

Awesome

Lint Tests Release License

<pre align="center"> /\ /\___| |_ __ ___ / / ___ / /_/ / _ \ | '_ ` _ \ / / / __| / __ / __/ | | | | | / /__\__ \ \/ /_/ \___|_|_| |_| |_\____/___/ </pre>

Helm Language Server

Helm-ls is a helm language server protocol LSP implementation.

<!-- vim-markdown-toc GFM --> <!-- vim-markdown-toc -->

Demo

asciicast

Getting Started

Installation with a package manager

Helm-ls is currently available as a package for some package managers.

Packaging status

These are some of the supported package managers. Thanks to everyone who packaged it!

Homebrew

If you are using MacOS or Linux with Homebrew you can install it with brew.

brew install helm-ls

Nix

nix-shell -p helm-ls

Arch Linux

You can install it from the aur using your preferred aur helper, e.g. yay:

yay -S helm-ls
# or
yay -S helm-ls-bin

Windows

You can use scoop to install it:

scoop bucket add extras
scoop install extras/helm-ls

mason (neovim)

If you are using neovim with mason you can also install it with mason.

:MasonInstall helm-ls

Manual download

curl -L https://github.com/mrjosh/helm-ls/releases/download/master/helm_ls_{os}_{arch} --output /usr/local/bin/helm_ls

Make it executable

chmod +x /usr/local/bin/helm_ls

Integration with yaml-language-server

Helm-ls will use yaml-language-server to provide additional capabilities, if it is installed.

[!WARNING]

This feature is experimental, you can disable it in the config (see) if you are getting a lot of errors beginning with Yamlls:. Having a broken template syntax (e.g. while your are still typing) will also cause diagnostics from yaml-language-server to be shown as errors.

To install it using npm run (or use your preferred package manager):

npm install --global yaml-language-server

The default kubernetes schema of yaml-language-server will be used for all files. You can overwrite which schema to use in the config (see). If you are for example using CRDs that are not included in the default schema, you can overwrite the schema using a comment to use the schemas from the CRDs-catalog.

# yaml-language-server: $schema=https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/keda.sh/scaledobject_v1alpha1.json
apiVersion: keda.sh/v1alpha1
kind: ScaledObject

Dependency Charts

Helm-ls can process dependency charts to provide autocompletion, hover etc. with values from the dependencies. For this the dependency charts have to be downloaded. Run the following command in your project to download them:

helm dependency build

Configuration options

You can configure helm-ls with lsp workspace configurations.

General

Values Files

yaml-language-server config

Default Configuration

settings = {
  ['helm-ls'] = {
    logLevel = "info",
    valuesFiles = {
      mainValuesFile = "values.yaml",
      lintOverlayValuesFile = "values.lint.yaml",
      additionalValuesFilesGlobPattern = "values*.yaml"
    },
    yamlls = {
      enabled = true,
      enabledForFilesGlob = "*.{yaml,yml}",
      diagnosticsLimit = 50,
      showDiagnosticsDirectly = false,
      path = "yaml-language-server",
      config = {
        schemas = {
          kubernetes = "templates/**",
        },
        completion = true,
        hover = true,
        -- any other config from https://github.com/redhat-developer/yaml-language-server#language-server-settings
      }
    }
  }
}

Editor Config examples

Neovim

Vim Helm Plugin

To get filetype detection working, you'll need the vim-helm plugin installed before using helm_ls, to install it using vim-plug (or use your preferred plugin manager):

Plug 'towolf/vim-helm'

nvim-lspconfig setup

Add the following to your neovim lua config:

local lspconfig = require('lspconfig')

lspconfig.helm_ls.setup {
  settings = {
    ['helm-ls'] = {
      yamlls = {
        path = "yaml-language-server",
      }
    }
  }
}

See examples/nvim/init.lua for an complete example, which also includes yaml-language-server.

[!TIP]

If you are using AstroNvim you can just install the astrocommunity helm pack.

coc.nvim setup

You can also use coc.nvim to set up the language server. You will need to configure the use of helm_ls in the langageserver section of your coc-settings.json file.

Open Neovim and type the command :CocConfig to access the configuration file. Find the langageserver section and add this configuration:

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

Save the configuration file and then either restart Neovim or type :CocRestart to restart the language server.

VSCode

Check out the helm-ls-vscode extension for more details.

Zed

Setup filetypes as described in the Zed Docs and install the helm.zed extension.

Emacs eglot setup

Integrating helm-ls with eglot for emacs consists of two steps: wiring up Helm template files into a specific major mode and then associating that major mode with helm_ls via the eglot-server-programs variable. The first step is necessary because without a Helm-specific major mode, using an existing major mode like yaml-mode for helm_ls in eglot-server-programs may invoke the language server for other, non-Helm yaml files.

For example, the following elisp snippet demonstrates how to use this language server after installing it as explained in Getting Started. Assuming that you leverage use-package for package management:

;; ...ensure that your package manager of choice is setup before
;; installing packages, and then

;; Install yaml-mode
(use-package yaml-mode)

;; Create a derived major-mode based on yaml-mode
(define-derived-mode helm-mode yaml-mode "helm"
  "Major mode for editing kubernetes helm templates")

(use-package eglot
  ; Any other existing eglot configuration plus the following:
  :hook
  ; Run eglot in helm-mode buffers
  (helm-mode . eglot-ensure)
  :config
  ; Run `helm_ls serve` for helm-mode buffers
  (add-to-list 'eglot-server-programs '(helm-mode "helm_ls" "serve")))

Invoke M-x helm-mode in a Helm template file to begin using helm-ls as a backend for eglot. Alternatively, you can include a comment such as the following at the top of Helm yaml files to automatically enter helm-mode:

# -*- mode: helm -*-

Features and Demos

<details> <summary> <b>Hover</b> </summary>

<video alt="demo for hover" src="https://github.com/user-attachments/assets/48413b5b-aedf-4735-aeca-aff32553f3fd"></video>

Language ConstructExample Effect
Values.Values.replicaCount shows the value of replicaCount in the values.yaml files.
Built-In-Objects.Chart.Name shows the name of the Chart.
Includesinclude "example.labels" shows the defintion of the template.
Functionsadd shows the docs of the add function.
Yaml in TemplatesKind shows the docs from the yaml-schema (via yaml-language-server).
</details> <details> <summary> <b>Autocomplete</b> </summary>

<video alt="Demo for autocompletion" src="https://github.com/user-attachments/assets/15c57a0a-4a17-48b4-9861-a324bcfa2158"></video>

Language ConstructEffect
ValuesValues from values*.yaml files (including child/parent Charts).
Built-In-ObjectsValues from Chart, Release, Files, Capabilities, Template.
IncludesAvailable includes (including child/parent Charts).
FunctionsFunctions from gotemplate and helm.
Yaml in TemplatesValues from the yaml-schema (via yaml-language-server).
</details> <details> <summary> <b>Go-To-Definition/References</b> </summary>

<video alt="Demo for definition and references" src="https://github.com/user-attachments/assets/e49769e9-4ddb-4b05-b075-645a9f9b9937"></video>

Language ConstructEffect
ValuesGo to values*.yaml files for template references (including child/parent Charts).
Built-In-ObjectsGo to Chart.yaml for Chart.*.
IncludesGo to defintion/references of template (including child/parent Charts).
</details> <details> <summary> <b>Symbol</b> </summary>

Can show a breadcrumb of the yaml path of the current position (via yaml-language-server). Demo for Symbol

</details> <details> <summary> <b>Linting</b> </summary>

Diagnostics from both helm lint and yaml-language-server. Demo of Linting

</details>

Contributing

Thank you for considering contributing to Helm-ls project!

License

The Helm-ls is open-source software licensed under the MIT license.

Part of the documentation that is included in helm-ls is copied from the Go standard library. The original license is included in the files containing the documentation.