Editor Modes for Nix Files: Difference between revisions
imported>Toraritte m Add categories |
m Category:Text Editor added |
||
(8 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
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. | ||
== Language servers == | |||
Most popular editors have support for the [https://microsoft.github.io/language-server-protocol language server protocol], the following language servers can be used to provide features like completions and go-to-definition. | |||
* [https://github.com/oxalica/nil nil] | |||
* [https://github.com/nix-community/rnix-lsp rnix-lsp] | |||
* [https://github.com/nix-community/nixd nixd] | |||
== Emacs == | == Emacs == | ||
Line 6: | Line 12: | ||
* [https://github.com/shlevy/nix-buffer nix-buffer] | * [https://github.com/shlevy/nix-buffer nix-buffer] | ||
* [https://github.com/jwiegley/nix-update-el nix-update-el] | * [https://github.com/jwiegley/nix-update-el nix-update-el] | ||
== Vim == | == Vim == | ||
=== vim-addon-nix === | === vim-addon-nix === | ||
Line 45: | Line 47: | ||
]; | ]; | ||
}</syntaxHighlight> | }</syntaxHighlight> | ||
== Neovim == | |||
In addition to the Vim plugins listed above, [https://github.com/nvim-treesitter/nvim-treesitter nvim-treesitter] also has support for nix. | |||
<syntaxHighlight lang="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) | |||
]; | |||
}; | |||
}; | |||
} | |||
</syntaxHighlight> | |||
== IntelliJ IDEA == | == IntelliJ IDEA == | ||
Line 65: | Line 83: | ||
* [https://github.com/seitz/nanonix nanonix] | * [https://github.com/seitz/nanonix nanonix] | ||
[[Category:Nix | == micro == | ||
Syntax highlighting is built-in. LSP support is available through the [https://github.com/AndCake/micro-plugin-lsp <code>lsp</code> plugin]. | |||
== Codemirror == | |||
* [https://github.com/replit/codemirror-lang-nix codemirror-lang-nix] | |||
== Zed == | |||
* [https://github.com/hasit/zed-nix zed-nix on github] | |||
== Relevant pages == | |||
* [[Overview of the Nix Expression Language]] | |||
* [[Nix Expression Language: Tips & Tricks]] | |||
* [[Nix Expression Language: Learning resources|Learning resources]] | |||
[[Category:Nix Language]] | |||
[[Category:Guide]] | [[Category:Guide]] | ||
[[Category:Text Editor]] |
Latest revision as of 20:09, 25 June 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 language 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
Howl
Far2l
nano
micro
Syntax highlighting is built-in. LSP support is available through the lsp
plugin.