Nixd: nix language server

How about moving this thread to github issues? This original post is somehow outdated.

1 Like

No problem, I wasn’t sure if it’s a bug. So far I thought I’m doing something wrong (and I did as you pointed out the outdated syntax).

I am unable to set up nixd for my Helix editor.

I have in my languages.toml:

[[language]]
name = "nix"
formatter = { command = 'nixfmt' }
language-servers = [ "nixd" ]

But Helix doesn’t see it:

$ hx --health nix
Configured language servers: None
Configured debug adapter: None
Configured formatter: nixfmt
Binary for formatter: /etc/profiles/per-user/pierre/bin/nixfmt
Highlight queries: ✓
Textobject queries: ✓
Indent queries: ✘

I got the formatter right. nixd is my PATH.

Am I doing something wrong?

command = nixd I guess?

Here is the line for Go in the same file:

language-servers = [ "gopls" ]

This property is expecting an array.

I am able to make it work with nil, though.

These are snippets from the languages.toml generated by Home Manager. Check the repo for instructions https://github.com/nix-community/nixd/blob/f12e2f77094ac73c1b1101390c02ec5bcf69ad46/nixd/docs/configuration.md:

[[language]]
auto-format = true
language-servers = ["nixd"]
name = "nix"

[language-server.nixd]
command = "nixd"

[language-server.nixd.config.nixpkgs]
expr = "import (builtins.getFlake \"/home/brisingr/nixos-config\").inputs.nixpkgs { }"

[language-server.nixd.config.options.nixos]
expr = "(builtins.getFlake \"/home/brisingr/nixos-config\").nixosConfigurations.manin.options"
2 Likes

I was missing these lines:

[language-server.nixd]
command = "nixd"

Thank you. Everything is now working fine. :smiley:

2 Likes