| 1 | # Language servers |
| 2 | |
| 3 | Helix has built-in support for the [Language Server Protocol][lsp], providing |
| 4 | IDE-like features — diagnostics, completion, goto-definition, rename and more, |
| 5 | for any language that has a server configured. Language servers are separate |
| 6 | programs you install yourself: the [language support](./lang-support.md) page |
| 7 | lists which languages ship with a server configured, and the |
| 8 | [language server configuration wiki][wiki] has per-server installation notes. |
| 9 | |
| 10 | Run `hx --health <language>` to check whether Helix found the configured server |
| 11 | for a language. After changing a server's configuration, `:lsp-restart` reloads |
| 12 | it and `:lsp-stop` stops it; `:lsp-workspace-command` runs a command the server |
| 13 | exposes for the workspace. |
| 14 | |
| 15 | ## Features |
| 16 | |
| 17 | Most features are bound by default (see the [keymap](./keymap.md)); the relevant |
| 18 | keys are listed below. |
| 19 | |
| 20 | | Feature | Default key / command | |
| 21 | | --- | --- | |
| 22 | | Diagnostics — shown inline and in the gutter | navigate with `[d` / `]d`; `Space-d` / `Space-D` open the document / workspace pickers | |
| 23 | | Completion | automatic while typing; `Ctrl-x` triggers it manually | |
| 24 | | Hover documentation | `Space-k` | |
| 25 | | Signature help (parameter hints) | automatic while typing arguments | |
| 26 | | Goto definition / declaration / type / references / implementation | `gd` / `gD` / `gy` / `gr` / `gi` | |
| 27 | | Rename symbol | `Space-r` | |
| 28 | | Code actions | `Space-a` | |
| 29 | | Document / workspace symbols | `Space-s` / `Space-S` | |
| 30 | | Format document | `:format`, or set `auto-format` to format on save | |
| 31 | | Inlay hints | enable with `display-inlay-hints` (see below) | |
| 32 | |
| 33 | ## Configuration |
| 34 | |
| 35 | The [`[editor.lsp]`](./editor.md#editorlsp-section) section of `config.toml` |
| 36 | toggles LSP behaviour — `display-inlay-hints`, `auto-signature-help`, |
| 37 | `auto-document-highlight`, `snippets`, and `enable` to disable LSP entirely. How |
| 38 | much diagnostic detail is shown inline at the cursor is configured separately in |
| 39 | [`[editor.inline-diagnostics]`](./editor.md#editorinline-diagnostics-section). |
| 40 | |
| 41 | Which server(s) a language uses, the server's command and arguments, and any |
| 42 | language-specific settings are configured in `languages.toml` (see |
| 43 | [Language Server configuration](./languages.md#language-server-configuration)). A |
| 44 | language may use [several servers](./languages.md#configuring-language-servers-for-a-language): |
| 45 | for each request the first server in the list that supports it is used, and a |
| 46 | server's features can be limited with `only-features` / `except-features`. |
| 47 | |
| 48 | [lsp]: https://microsoft.github.io/language-server-protocol/ |
| 49 | [wiki]: https://github.com/helix-editor/helix/wiki/Language-Server-Configurations |