Adds nix language support for VSCode Editor.
-
Syntax Highlight
- Thanks to https://github.com/wmertens/sublime-nix for the grammer file
- nix code snippets inside
markdownfiles also work.
-
Full editing support when using a language server. Generally, any nix LSP implementation should work.
The following are tested so far:Pass settings to the language server via
serverSettings.{ "nix.serverSettings": { // settings for 'nil' LSP "nil": { "diagnostics": { "ignored": ["unused_binding", "unused_with"] }, "formatting": { "command": ["nixpkgs-fmt"] } } } } -
When
Language Serversupport is not enabled the following tools are used to- Formatting support. Set
nix.formatterPathto any command which can accept file contents on stdin and return formatted text on stdout; e.g.,{ "nix.formatterPath": "nixpkgs-fmt" // default // "nix.formatterPath": "nixfmt" // "nix.formatterPath": ["treefmt", "--stdin", "{file}"] // "nix.formatterPath": ["nix", "fmt", "--", "-"] // using flakes with `formatter = pkgs.alejandra;` } - Error Report
- Using
nix-instantiateerrors reported
- Using
- Formatting support. Set
-
Snippets
PRs welcome for them
- embedded language syntax support for bash
- path completion - https://github.com/ChristianKohler/PathIntellisense
Hit F1 and enter the ext install jnoortheen.nix-ide command or search for nix-ide.
The extension can be downloaded from the release page.
Just clone the GitHub repository under your local extensions folder:
- Windows:
%USERPROFILE%\.vscode\extensions - Mac / Linux:
$HOME/.vscode/extensions
- Document the purpose of functions and classes.
- When adding a new feature, please mention it in the
README.mdFeatures section. Use screenshots when applicable. - Conventional Commit style should be used for commit messages as it is used to generate changelog.
There is direnv and nix-shell support so a dev environment can be created with the nix-shell command or a one-time direnv allow at the root of the repo.
Press F5 in VSCode to run an Extension Development Host instance with the extension installed.
TypeScript is used to develop the extension.
yarn install # install dependencies
yarn build # build the extension- fill
.envfrom.env.template
# this is needed to publish extensions to [openvsx](https://open-vsx.org/) from local machine.
yarn env-cmd
# this will generate changelog and will create a GitHub release. This will also trigger jobs to publish the extension.
yarn release
# to manually publish the extension
yarn publishSpecial thanks to
- article to have all the pieces in one place to develop vscode extension with
Fable. - The extension vscode-fish is modified to work for
nix.
{ "nix.serverPath": "rnix-lsp" // "nix.serverPath": "nil" }