Difference between revisions of "Editor Modes for Nix Files"
From NixOS Wiki
(Add zed-nix link) |
(Add warning about the new wiki) |
||
Line 1: | Line 1: | ||
+ | {{warning|1=You are reading an article on the deprecated unofficial wiki. For the up to date version of this article, see https://wiki.nixos.org/wiki/Editor_Modes_for_Nix_Files.}} | ||
+ | |||
Nix language has decent syntax highlighting (SH) support among popular code editors, but refactoring/autocomplete is still rare. Below is a list of editor modes for Nix syntax. | Nix language has decent syntax highlighting (SH) support among popular code editors, but refactoring/autocomplete is still rare. Below is a list of editor modes for Nix syntax. | ||
Revision as of 16:28, 4 April 2024
Nix language has decent syntax highlighting (SH) support among popular code editors, but refactoring/autocomplete is still rare. Below is a list of editor modes for Nix syntax.
Language servers
Most popular editors have support for the llanguage server protocol, the following language servers can be used to provide features like completions and go-to-definition.
Emacs
- nix-mode official available in melpa
- @marsam's nix-mode
- nix-buffer
- nix-update-el
Vim
vim-addon-nix
This plugin supports syntax highlighting and simple syntax and undeclared variable checking.
Usage with VAM package manager:
{ # /etc/nixos/configuration.nix
environment.systemPackages = [
(pkgs.vim_configurable.customize {
name = "vim";
vimrcConfig.vam.pluginDictionaries = [
# vim-nix handles indentation better but does not perform sanity
{ names = [ "vim-addon-nix" ]; ft_regex = "^nix\$"; }
];
})
];
}
vim-nix
vim-nix *only* supports syntax-highighting.
Usage with vim package manager:
{ # /etc/nixos/configuration.nix
environment.systemPackages = [
(pkgs.vim_configurable.customize {
name = "vim";
vimrcConfig.packages.myplugins = with pkgs.vimPlugins; {
start = [ vim-nix ]; # load plugin on startup
};
})
];
}
Neovim
In addition to the Vim plugins listed above, nvim-treesitter also has support for nix.
{
programs.neovim = {
configure = {
packages.all.start = with pkgs.vimPlugins; [
(nvim-treesitter.withPlugins (ps: [ ps.nix ]))
# or
nvim-treesitter.withAllGrammars # to install all grammars (including nix)
];
};
};
}
IntelliJ IDEA
Eclipse
- nix-eclipse - development stopped in 2010
Sublime Text
Atom
Visual Studio Code
- vscode-nix on github
- vscode-nix-ide on GitHub and VSCode Store with support to format and lint