https://github.com/nix-community/vscode-nix-ide
Nix language support for VSCode editor [maintainer: @jnoortheen]
https://github.com/nix-community/vscode-nix-ide
nix nixos vscode vscode-extension
Last synced: 20 days ago
JSON representation
Nix language support for VSCode editor [maintainer: @jnoortheen]
- Host: GitHub
- URL: https://github.com/nix-community/vscode-nix-ide
- Owner: nix-community
- License: mit
- Created: 2020-07-12T23:06:57.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-03-18T06:56:40.000Z (about 1 month ago)
- Last Synced: 2025-04-01T15:52:22.017Z (27 days ago)
- Topics: nix, nixos, vscode, vscode-extension
- Language: TypeScript
- Homepage: https://marketplace.visualstudio.com/items?itemName=jnoortheen.nix-ide
- Size: 1.35 MB
- Stars: 356
- Watchers: 5
- Forks: 30
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - nix-community/vscode-nix-ide - Nix language support for VSCode editor [maintainer: @jnoortheen] (TypeScript)
- awesome-starred - nix-community/vscode-nix-ide - Nix language support for VSCode editor [maintainer: @jnoortheen] (TypeScript)
README
# Nix IDE ✨💡🌟
Adds [Nix](https://nixos.org/) language support for [Visual Studio Code](https://code.visualstudio.com/).
## Quickstart 🚀
1. [Install](./install.md) the extension, and open a Nix file.
1. [Syntax highlighting](./images/docs/nix-syntax-highlight.png) should work out of the box. Nix code blocks inside `markdown` files are also [supported](./images/docs/md-embed-nix.png).
1. Auto-formatting should work if [`nixfmt`](https://github.com/NixOS/nixfmt) or [`nixpkgs-fmt`](https://github.com/nix-community/nixpkgs-fmt) is available in `$PATH`. A custom formatter can be set by [configuring `nix.formatterPath`](#custom-formatter).
1. Syntax errors are [linted](./images/docs/linting.png) using `nix-instantiate`.
1. Full language support can be enabled by configuring a language server. See [LSP Plugin Support](#lsp-plugin-support) for more information.
1. Snippets are provided for conditional expressions, `let`/`with` expressions, and `rec`ursive sets.
1. Path completion is supported using the [Path Intellisense](https://github.com/ChristianKohler/PathIntellisense) extension.## Settings ⚙️
### LSP Plugin Support
Full language support can be enabled by using a language server. Generally, any Nix [LSP](https://microsoft.github.io/language-server-protocol/) implementation should work. Some examples are given below for [`nil`](https://github.com/oxalica/nil?tab=readme-ov-file#vscodevscodium-with-nix-ide) and [`nixd`](https://github.com/nix-community/nixd).
```json5
{
"nix.enableLanguageServer": true,
"nix.serverPath": "nil", // or "nixd"
// LSP config can be passed via the ``nix.serverSettings.{lsp}`` as shown below.
"nix.serverSettings": {
// check https://github.com/oxalica/nil/blob/main/docs/configuration.md for all options available
"nil": {
// "diagnostics": {
// "ignored": ["unused_binding", "unused_with"],
// },
"formatting": {
"command": ["nixfmt"],
},
},
// check https://github.com/nix-community/nixd/blob/main/nixd/docs/configuration.md for all nixd config
"nixd": {
"formatting": {
"command": ["nixfmt"],
},
"options": {
// By default, this entry will be read from `import { }`.
// You can write arbitrary Nix expressions here, to produce valid "options" declaration result.
// Tip: for flake-based configuration, utilize `builtins.getFlake`
"nixos": {
"expr": "(builtins.getFlake \"/absolute/path/to/flake\").nixosConfigurations..options",
},
"home-manager": {
"expr": "(builtins.getFlake \"/absolute/path/to/flake\").homeConfigurations..options",
},
// Tip: use ${workspaceFolder} variable to define path
"nix-darwin": {
"expr": "(builtins.getFlake \"${workspaceFolder}/path/to/flake\").darwinConfigurations..options",
},
},
}
}
}
```### 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. If you are using an LSP server, then this configuration is not used.
```json5
{
"nix.formatterPath": "nixfmt" // or "nixpkgs-fmt" or "alejandra" or "nix3-fmt" or pass full list of args such as or `["treefmt", "--stdin", "{file}"]`
}
```## Contributing 💪
We welcome contributions to this extension. Kindly start with any of open issues or feature requests.
See [CONTRIBUTING.md](./CONTRIBUTING.md) for more information.
## Credits
Special thanks to:
- [@wmertens](https://github.com/wmertens) for [writing the grammar](https://github.com/wmertens/sublime-nix/blob/master/nix.tmLanguage).
- The [vscode-fish](https://github.com/bmalehorn/vscode-fish/) extension, which was modified to work for Nix in this extension.