Someone here to help me with nixd?

Is there like a complete newbies guide to use nixd (lsp) with nvim already ?

I’m trying to wrap my head around the instructions given at their editor setup page, but I can’t get my editor to do what the gifs suggest it should with any nix file I tried.

I must be missing something important there and I would so much like to be able to turbo-charge my editing with this awesome lsp implementation.

Nixd has been announced five days ago, so I doubt there’s any tutorials on it yet.
Maybe @inclyc can help you directly?

Could you share your nvim setup files and what changes you made in an attempt to enable nixd?

Did you write workspace configuration?

Also you can join our matrix room: https://matrix.to/#/#nixd:matrix.org for real-time communication & support.

I was able now to fully reproduce all non-flake examples from the User Guide using nvim configured with nvim-lspconfig.

Some hints:

  • I had to generate the .nixd.json file (called workspace configuration) via the .nixd.nix given at their site to avoid syntax errors - the User Guide explains how
  • In the workspace configuration I added the full path to my nix file - /tmp/test/default.nix in my case - /tmp/test/.nixd.json accordingly as workspace configuration
  • nvim /tmp/test/default.nix was the call that the Editor Setup page suggests but just nvim or loading from an active nvim session works as well as long as the .nixd.json lives in the same folder
  • completions are only triggered when the edited file produces no eval errors i. e. is syntactically sound - edit accordingly until eval succeeds again. Example: The line meta.platforms = lib.platforms.;. In case the list doesn’t pop up edit until eval is happy again i. e. meta.platforms = lib.platforms.js; and then re-trigger by replacing the .js with .. It’s a bit involved but you’ll get the hang of it. Maybe there emerge better ways.
  • depending on the nvim-lspconfig setup - mine is complete after dot or at least 3 matching characters - the completion list expands accordingly
  • in my case hovering is accessible via :lua vim.lsp.buf.hover()

Happy nixd’ing

just my 2c for others struggling <3

3 Likes