Skip to content
/ nixd Public
forked from nix-community/nixd

Nix language server, based on nix libraries [maintainer=@inclyc]

License

Notifications You must be signed in to change notification settings

cmacrae/nixd

 
 

Repository files navigation

nixd

Nix language server

About

This is a Nix language server that directly uses (i.e., is linked with) the official Nix library (https://github.com/NixOS/nix).

Some notable features provided by linking with the Nix library include:

  • Nixpkgs option support, for all option system (NixOS/home-manager/flake-parts).
  • Diagnostics and evaluation that produce identical results as the real Nix command.
  • Shared eval caches (flake, file) with your system's Nix.
  • Native support for cross-file analysis (goto definition to locations in nixpkgs).
  • Precise Nix language support. We do not maintain "yet another parser & evaluator".
  • Support for built-ins, including Nix plugins.

Features Preview

Home-manager options auto-completion & goto declaration

options-example

See how to configure option system: https://github.com/nix-community/nixd/blob/main/nixd/docs/user-guide.md#options

Write a package using nixd

write-package

Native cross-file analysis

package

We support goto-definition on nix derivations! Just Ctrl + click to see where is a package defined.

goto-def-pkg-2

And also for nix lambda:

lambda-location

See how to configure the evaluator for cross-file analysis: https://github.com/nix-community/nixd/blob/main/nixd/docs/user-guide.md#evaluation

Handle evaluations exactly same as nix evaluator

infinte-recursion

Support *all* builtins

eval-builtin-json

And diagnostic:

eval-builtin-diagnostic

Get Started

You can try nixd without installation. We have tested some working & reproducible editor environments and example configurations & workspaces.

Resources

Project Structure

.
├── default.nix
├── flake.lock
├── flake.nix
├── LICENSE
├── lspserver                          # The C++ library for writing LSP servers.
├── meson.build
├── nixd                               # Modularized nixd components, test suite, and tools (binary)
│   ├── docs                           # Documentation
│   ├── include                        # General header files
│   ├── lib
│   │   ├── AST                        # AST library for nix expressions, static analysis (rename, completion, location, range) & evaluation bindings.
│   │   ├── Expr                       # Expressions library (single AST nodes) with name lookups, locations, ...
│   │   ├── meson.build
│   │   ├── Nix                        # Extension to NixOS/nix
│   │   ├── Parser                     # Extension to the parser from NixOS/nix. with ranges support & error handling.
│   │   ├── Server                     # The nixd server library with controller (the process interacting with clients) and multiple workers (option, eval).
│   │   └── Support
│   ├── meson.build
│   ├── test                           # Library tests. (rarely used)
│   └── tools
│       ├── meson.build
│       ├── nix-ast-dump               # Dump nix AST from the offical parser (NixOS/nix)
│       │   ├── meson.build
│       │   ├── nix-ast-dump.cpp
│       │   └── test
│       ├── nixd                       # The nixd binary (entry point)
│       │   ├── meson.build
│       │   ├── nixd.cpp
│       │   └── test                   # The regression tests.
│       └── nixd-ast-dump              # Dump the AST nodes parsed from the extended parser, check leaks & memory safety.
│           ├── meson.build
│           ├── nixd-ast-dump.cpp
│           └── test
└── README.md

About

Nix language server, based on nix libraries [maintainer=@inclyc]

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 93.4%
  • Nix 4.7%
  • Meson 1.5%
  • Other 0.4%