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

inclyc/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/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/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

Resources

Project Structure

.
├── default.nix
├── docs
├── editors
├── flake.lock
├── flake.nix
├── LICENSE
├── lspserver                          # The C++ library for writing LSP servers.
├── meson.build
├── nixd                               # Modularized nixd components, test suite, and tools (binary)
│   ├── 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++ 76.6%
  • Nix 16.4%
  • Yacc 3.4%
  • Meson 1.8%
  • Lex 1.4%
  • Python 0.3%
  • NASL 0.1%