Configuring Helix Language Servers on NixOS
I've enjoyed my experience with the Helix editor so far. It slots in nicely as a VIM replacement. Getting language servers setup for Helix on NixOS isn't totally obvious though, so I thought I'd document the process here.
Suppose we want to install a SQL language server.
On NixOS, we can't run npm i
-g
.
Instead, we can use npx
. Run npx and inside the shell environment run npm i
sql-language-server
. Now in ~/.config/helix/languages.toml
, add
[language-server.sql-language-server]
command = "npx"
args = ["sql-language-server", "up", "--method", "stdio"]
[[language]]
name = "sql"
language-servers = ["sql-language-server"]
As a second example, let's setup an HTML
language server. As before, use npx
to execute npm i
vscode-langservers-extracted
.
Add to languages.toml
the following:
[language-server.vscode-html-language-server]
command = "npx"
args = ["vscode-html-language-server", "--stdio"]
[[language]]
name = "html"
language-servers = ["vscode-html-language-server"]
For Python, there's ruff (the langserver is here). Luckily, there are ruff nixpkgs we can use.
Add the ruff
and ruff-lsp
packages to your nix config
and add
[language-server.python-ruff]
command = "ruff-lsp"
[[language]]
name = "python"
language-servers = ["python-ruff"]
to your Helix languages.toml
.
That's all there is to it. For more language servers and configuration information see here. Just be mindful of the differences if you're on NixOS.