From 61037bb3eb41a0cd5247fbccba598152076704bc Mon Sep 17 00:00:00 2001 From: qvalentin Date: Sun, 3 Dec 2023 13:57:29 +0100 Subject: [PATCH] [Docs] rework README --- README.md | 93 ++++++++++++++++++++++++++++++++++++++---- examples/nvim/init.lua | 2 + 2 files changed, 87 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index af031e5f..0216fb3c 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,32 @@ ## Helm Language Server Protocol Helm-ls is a [helm](https://github.com/helm/helm) language server protocol [LSP](https://microsoft.github.io/language-server-protocol/) implementation. + + + +* [Demo](#demo) +* [Getting Started](#getting-started) + * [Download](#download) + * [Make it executable](#make-it-executable) + * [Integration with yaml-language-server](#integration-with-yaml-language-server) +* [Configuration options](#configuration-options) + * [LSP Server](#lsp-server) + * [yaml-language-server config](#yaml-language-server-config) + * [Default Configuration](#default-configuration) +* [Editor Config examples](#editor-config-examples) + * [Neovim (using nvim-lspconfig)](#neovim-using-nvim-lspconfig) + * [Vim Helm Plugin](#vim-helm-plugin) + * [Setup laguage server](#setup-laguage-server) + * [Emacs eglot setup](#emacs-eglot-setup) +* [Contributing](#contributing) +* [License](#license) + + + +## Demo +[![asciicast](https://asciinema.org/a/485522.svg)](https://asciinema.org/a/485522) + ## Getting Started -### Vim Helm Plugin -You'll need [vim-helm](https://github.com/towolf/vim-helm) plugin installed before using helm_ls, to install it using vim-plug (or use your preferred plugin manager): -```lua -Plug 'towolf/vim-helm' -``` ### Download * Download the latest helm_ls executable file from [here](https://github.com/mrjosh/helm-ls/releases/latest) and move it to your binaries directory @@ -28,6 +48,8 @@ Plug 'towolf/vim-helm' 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](https://github.com/williamboman/mason.nvim) you can also install it with mason. + ### Make it executable ```bash chmod +x /usr/local/bin/helm_ls @@ -43,7 +65,61 @@ To install it using npm run (or use your preferred package manager): npm install --global yaml-language-server ``` -## nvim-lspconfig setup +## 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](https://github.com/redhat-developer/yaml-language-server#language-server-settings)): + - **Schemas**: Define YAML schemas. + - **Completion**: Enable code completion. + - **Hover Information**: Enable hover details. + +### Default Configuration + +```lua +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](https://github.com/towolf/vim-helm) plugin installed before using helm_ls, to install it using vim-plug (or use your preferred plugin manager): +```lua +Plug 'towolf/vim-helm' +``` + +#### Setup laguage server ```lua local lspconfig = require('lspconfig') @@ -57,10 +133,11 @@ lspconfig.helm_ls.setup { } } ``` +See [examples/nvim/init.lua](https://github.com/mrjosh/helm-ls/blob/master/examples/nvim/init.lua) for an +complete example, which also includes yaml-language-server. -[![asciicast](https://asciinema.org/a/485522.svg)](https://asciinema.org/a/485522) -## Emacs eglot setup +### Emacs eglot setup Integrating helm-ls with [eglot](https://github.com/joaotavora/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. diff --git a/examples/nvim/init.lua b/examples/nvim/init.lua index c524026c..b7613095 100644 --- a/examples/nvim/init.lua +++ b/examples/nvim/init.lua @@ -1,3 +1,5 @@ +-- a minimal example config for setting up neovim with helm-ls and yamlls + -- setup lazy plugin manager local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then