Nix language server that evaluates code

Related tags

System tools nix lsp
Overview

nix-eval-lsp

Still use nix-community/rnix-lsp. This repo is a work in progress.

nix-eval-lsp is an experimental language server for Nix. It provides completions and tooltips by efficiently evaluating Nix expressions as they are typed.

Features

  • hover over an expression to see its value
  • auto-complete inside expressions such as with pkgs; [ ]
  • goto definitions across files
  • clickable paths and urls
  • auto-formatting using nixpkgs-fmt
  • helpful documentation for builtins
  • caching of lambda parameters to make callPackage derivations easier to write
  • auto-complete for lambda arguments, with documentation comments extracted from source code
  • snippets for common Nix expressions

Important note: the evaluator is developed for the purpose of debugging tools only. It does not aim to correctly implement Nix in its entirety.

Usage

  1. Install the Nix IDE extension for VS Code
  2. git clone https://github.com/aaronjanse/nix-eval-lsp.git && cd nix-eval-lsp
  3. Run nix build, nix-build, or RUSTC_BOOTSTRAP=1 cargo build --release (the --release is important!)
  4. Copy the absolute path of the built binary into Nix IDE's settings (search "nix" then edit the "server path" field)
  5. Make sure "Nix: Enable Language Server" is set to true
  6. Restart VS Code ("Reload Window" in command palette)

Try it out

Here's an expression to try out the LSP:

let
  pkgs = import /path/to/nixpkgs {};
  foo = pkgs.gcc;
in
with pkgs; [
  htop hello
]

Credits

Huge thank you to @jd91mZM2 for nix-community/rnix-parser.

You might also like...
A LSP (Language Server Protocol) server for OpenSCAD.

openscad-LSP A LSP (Language Server Protocol) server for OpenSCAD. inspired by dzhu/openscad-language-server Tested with VSCode on Mac and Windows. Te

impl LSP (Language Server Protocol) Server for librime

rime-ls 为 rime 输入法核心库 librime (的部分功能) 实现 LSP 协议, 从而通过编辑器的代码补全功能输入汉字. 项目还处在早期阶段, 各方面都非常不成熟. 目标是提供 rime + LSP 的通用解决方案, 在不同编辑器内实现与其他 rime 前端类似的输入体验. Feat

Rust friendly bindings to *nix APIs

Rust bindings to *nix APIs Documentation (Releases) Nix seeks to provide friendly bindings to various *nix platform APIs (Linux, Darwin, ...). The goa

Your project’s nix-env [maintainer=@Profpatsch]
Your project’s nix-env [maintainer=@Profpatsch]

lorri https://github.com/nix-community/lorri lorri is a nix-shell replacement for project development. lorri is based around fast direnv integration f

Dog command for *nix systems, Rust port of dog.

dog-rs Dog command for *nix systems, Rust port of dog. Because there is a cat command, should be a dog command too. It was written completely using VS

Make creating nix expressions easy

Make creating nix expressions easy

A flexible simple theme manager for *nix systems

tema A theme manager for *nix systems respecting the FHS spec configuration As of now all the configuration is done via $XDG_CONFIG_HOME/tema/config.y

Generates a Nix expression for buildDotnetModule, with support for non nuget.org repos.

nuget2nix Generates a Nix expression for buildDotnetModule, with support for non nuget.org repos. Usage Similar to the nuget-to-nix command available

An alternative broken buggy Nix implementation in Rust + Java (for evaluation)

An alternative broken buggy Nix implementation in Rust + Java (for evaluation)

Artifact collection tool for *nix systems
Artifact collection tool for *nix systems

fennec is an artifact collection tool written in Rust to be used during incident response on *nix based systems. fennec allows you to write a configuration file that contains how to collect artifacts.

App source + Nix packages + Docker = Image
App source + Nix packages + Docker = Image

Nixpacks App source + Nix packages + Docker = Image Nixpacks takes a source directory and produces an OCI compliant image that can be deployed anywher

Nix binary cache implemented in rust using libnix-store

harmonia Build Whole application nix-shell --run cargo b C Library Wrapper around libnixstore nix-shell --run make Note: The makefile is only to pro

A simple gtk4/libadwaita software center to easily install and manage nix packages
A simple gtk4/libadwaita software center to easily install and manage nix packages

Nix Software Center A graphical app store for Nix built with libadwaita, GTK4, and Relm4. Heavily inspired by GNOME Software. Features Install package

rpsc is a *nix command line tool to quickly search for file systems items matching varied criterions like permissions, extended attributes and much more.

rpsc rpsc is a *nix command line tool to quickly search for file systems items matching varied criterions like permissions, extended attributes and mu

Tooling for the simple-package-paths Nix RFC

Implementation Index the tree for references. If .git exists, use ls-tree equivalent Check the validity of the pkgs/unit directory Should only contain

Generate Nix fetcher calls from repository URLs [maintainer=@figsoda]

nurl Generate Nix fetcher calls from repository URLs $ nurl https://github.com/nix-community/patsh v0.2.0 2/dev/null fetchFromGitHub { owner = "nix

Generate Nix packages from URLs
Generate Nix packages from URLs

Generate Nix packages from URLs with hash prefetching, dependency inference, license detection, and more

Multi-tenant Nix Binary Cache

Attic Attic is a self-hostable Nix Binary Cache server backed by an S3-compatible storage provider. It has support for global deduplication and garbag

Tvix - A Rust implementation of Nix

Tvix Tvix is a new implementation of the Nix language and package manager. See the announcement post for information about the background of this proj

Comments
  • support outside of vscode?

    support outside of vscode?

    I'm a kakoune user and I can't get this to work at all. I've also tried using it from helix. Both have standard lsp implementations so I'm not sure what the issue is.

    opened by nrdxp 2
Releases(v0.1.0)
Owner
Aaron Janse
UC Berkeley '24
Aaron Janse
📊 Fetch & monitor your server's resource usage through Lua

?? gmsv_serverstat Simple serverside binary module which can expose information about system resource usage to Lua. Installation Download the relevant

William 21 Jul 30, 2022
Count your code, quickly.

Tokei (時計) Tokei is a program that displays statistics about your code. Tokei will show the number of files, total lines within those files and code,

null 7.5k Jan 9, 2023
A `nix` and `nix-shell` wrapper for shells other than `bash`

nix-your-shell A nix and nix-shell wrapper for shells other than bash. nix develop and nix-shell use bash as the default shell, so nix-your-shell prin

Mercury 15 Apr 10, 2023
Progress In Nix - Pacman inspired frontend for Nix

Progress In Nix Pinix is a Pacman inspired frontend for Nix. It wraps a regular Nix command and replaces the output with a more modern and informative

Rémi Dupré 23 Mar 9, 2024
NixEl is a Rust library that turns Nix code into a variety of correct, typed, memory-safe data-structures

?? NixEL Lexer, Parser, Abstract Syntax Tree and Concrete Syntax Tree for the Nix Expressions Language. NixEl is a Rust library that turns Nix code in

Kevin Amado 56 Dec 29, 2022
Downloads and provides debug symbols and source code for nix derivations to gdb and other debuginfod-capable debuggers as needed.

nixseparatedebuginfod Downloads and provides debug symbols and source code for nix derivations to gdb and other debuginfod-capable debuggers as needed

Guillaume Girol 16 Mar 6, 2023
lints and suggestions for the nix programming language

statix Lints and suggestions for the Nix programming language. statix highlights antipatterns in Nix code. statix --fix can fix several such occurrenc

Akshay 311 Dec 25, 2022
A natural language shell interface for *nix systems

Orphic A natural language shell interface for *nix systems. Overview Orphic is a CLI tool that uses GPT to translate complex tasks into shell commands

Will Savage 42 Mar 29, 2023
Jex Compiler Server - Server that runs Jex code

Server that compiles and runs Jex code.

furetur 3 Nov 18, 2021
AIDL Language Server Protocol (LSP) server

AIDL Language Server Protocol (LSP) server Experimental AIDL LSP server based on rust-aidl-parser. Features: diagnostics workspace symbols (Ctrl+T in

Benoit Walter 0 Jan 9, 2022