Skip to content

nix-community/vscode-nix-ide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nix IDE ✨💡🌟

Adds Nix language support for Visual Studio Code.

Installation 🔨

Available on both the Visual Studio Marketplace and the Open VSX Registry.

You can also open the Command Palette (Ctrl+Shift+P on Windows/Linux or Cmd+Shift+P on macOS) and enter ext install jnoortheen.nix-ide to install the extension, or download it from the latest release.

Quickstart 🚀

  1. Install the extension
  2. Open a Nix file
  3. Syntax highlighting should work out of the box.
  4. Formatting the code should work if nixfmt (or the archived nixpkgs-fmt) is installed and available on the $PATH.
  5. Full language support is available if you have a language server installed and enabled. See LSP Plugin Support for more information.

Features 🎯

  • Syntax Highlighting support. Also Nix code blocks inside markdown files also highlighted.
  • The basic language integration is supported out of the box using nixfmt and nix-instantiate. Syntax Errors are linted using nix-instantiate while Auto-Formatting is handled by nixfmt by default. Custom formatter can be set by setting nix.formatterPath.
  • The full language support is enabled by configuring an LSP server.
  • Snippets are provided for conditional expressions, let expressions, with expressions, and recursive sets.
  • Path completion support using PathIntellisense extension

Settings ⚙️

Custom Formatter

It can be changed by setting nix.formatterPath to any command which can accept file contents on stdin and return formatted text on stdout.

{ 
    "nix.formatterPath": "nixfmt" // or "nixpkgs-fmt" or ["treefmt", "--stdin", "{file}"]
    // or using flakes with `formatter = pkgs.alejandra;`
    // "nix.formatterPath": ["nix", "fmt", "--", "--"]
}

LSP Plugin Support

Full language support can be enabled by using a language server. Generally, any Nix LSP implementation should work.

{
  "nix.enableLanguageServer": true,
  "nix.serverPath": "nil", // or "nixd"
  // Pass settings to the language server via the `serverSettings` option.
  "nix.serverSettings": { ... }
}

Some examples of advanced settings are provided below for nil and nixd.

Contributing 💪

We welcome contributions to this extension. Kindly start with any of open issues or feature requests.

See CONTRIBUTING.md for more information.

Credits

Special thanks to: