Skip to content
forked from mrjosh/helm-ls

⎈ Language server for Helm ⎈

License

Notifications You must be signed in to change notification settings

qvalentin/helm-ls

 
 

Repository files navigation

Lint Tests Release License

  /\  /\___| |_ __ ___   / / ___ 
 / /_/ / _ \ | '_ ` _ \ / / / __|
/ __  /  __/ | | | | | / /__\__ \
\/ /_/ \___|_|_| |_| |_\____/___/

Helm Language Server Protocol

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

Demo

asciicast

Getting Started

Download

  • Download the latest helm_ls executable file from here and move it to your binaries directory

  • You can download it with curl, replace the {os} and {arch} variables

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

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

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. This feature is expermiental, you can disable it in the config (todo: link to config). Having a broken template syntax (e.g. while your are stil typing) will 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

Configuration options

You can configure helm-ls with lsp workspace configurations.

LSP Server

  • Log Level: Adjust log verbosity.

yaml-language-server config

  • Enable yaml-language-server: Toggle support of this feature.

  • Path to yaml-language-server: Specify the executable location.

  • Diagnostics Settings:

    • Limit: Number of displayed diagnostics per file.
    • Show Directly: Show diagnostics while typing.
  • Additional Settings (see yaml-language-server):

    • Schemas: Define YAML schemas.
    • Completion: Enable code completion.
    • Hover Information: Enable hover details.

Default Configuration

settings = {
  ['helm-ls'] = {
    logLevel = "debug",
    yamlls = {
      enabled = true,
      diagnosticsLimit = 50,
      showDiagnosticsDirectly = false,
      path = "yaml-language-server",
      config = {
        schemas = {
          kubernetes = "**",
        },
        completion = true,
        hover = true,
        -- any other config: https://github.com/redhat-developer/yaml-language-server#language-server-settings
      }
    }
  }
}

Editor Config examples

Neovim (using nvim-lspconfig)

Vim Helm Plugin

You'll need vim-helm plugin installed before using helm_ls, to install it using vim-plug (or use your preferred plugin manager):

Plug 'towolf/vim-helm'

Setup laguage server

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.

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

Contributing

Thank you for considering contributing to HelmLs project!

License

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

About

⎈ Language server for Helm ⎈

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 74.1%
  • Go 25.7%
  • Makefile 0.2%