Nixd: 2.0.2 released

nixd - nix language server 2.0.2

tldr.

teach your editor pure functional package manager.

I just published a re-designed language server which performs package & nixos/home-manager/nix-darwin options completion, goto definition, syntax errors, liveness, missing “;” … these features works out of box,

Screen Shots

Inlay Hints for your packages:

Goto Definition works for nixpkgs packages. (Highlighted with pkgs; also)

Completion, with snippets.

Screencast_20240422_183939

Where are the options declared?

Screencast_20240422_185124

Quick Fixes

Screencast_20240422_185531

Packages completion.

Screencast_20240422_190155

Any suggestions? / Features Discussion ?

Links

Nixpkgs version bump: nixd: 1.2.3 -> 2.0.0 by marsam · Pull Request #305285 · NixOS/nixpkgs · GitHub
Release notes: Release 2.0.2 · nix-community/nixd · GitHub

63 Likes

Thank you so much for your work!

When I last tried setting up nixd, I hit a roadblock configuring the .nixd.json files. From the changelog I take it that these are no longer necessary?

How does that work? Black magic?

2 Likes

One primary purpose of .nixd.json is to determine the target for evaluation. However, based on my experience with “nix,” evaluating “all” files on workspace updates is a technique more suitable for “one-time” checks rather than on-the-fly editing. Consequently, evaluation per node has been eliminated. Now, packages completion and options completion operate akin to querying an REPL but communicate programmatically via RPC (Remote Procedure Call). In this approach, evaluated results remain unaffected by workspace changes.

For instance, the frontend heuristically matches with pkgs; constructs and queries the “REPL” for package definitions, subsequently displaying completions and documentations. This means it now aligns with certain “idioms” in the nix language, without fully evaluating everything and risking invalidation immediately after workspace changes.

While not perfect or exact, this approach represents a tradeoff considering performance & experience.

4 Likes

Excelent! I love the feature to go-to-definition on nixpkgs options. It would be nice if I could also go-to-definition of my own personal modules. There should be a way for the lsp to grab information from the flakes itself, right?

See Jump to definition of custom modules · Issue #451 · nix-community/nixd · GitHub

1 Like