Editor Modes for Nix Files: Difference between revisions

imported>Volth
No edit summary
The rnix repository was archived and is no longer maintained (can be seen be just clicking the link).
 
(21 intermediate revisions by 16 users not shown)
Line 1: Line 1:
This is a list of editor modes for Nix syntax.
{{Merge|Nix (language)}}


* Emacs
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.
* [https://github.com/NixOS/nix/blob/master/misc/emacs/nix-mode.el nix-mode official] available in [https://melpa.org/ melpa]
 
* [https://github.com/matthewbauer/nix-mode @matthewbauer's nix-mode]
== 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/nixd nixd]
* [https://github.com/nix-community/rnix-lsp rnix-lsp] (deprecated)
 
== Emacs ==
* [https://github.com/NixOS/nix-mode nix-mode official] available in [https://melpa.org/ melpa]
* [https://github.com/emacs-pe/nix-mode @marsam's nix-mode]
* [https://github.com/emacs-pe/nix-mode @marsam's nix-mode]
* [https://github.com/shlevy/nix-buffer nix-buffer]
* [https://github.com/shlevy/nix-buffer nix-buffer]
* Vim
* [https://github.com/jwiegley/nix-update-el nix-update-el]
* [https://github.com/LnL7/vim-nix vim-nix]


Usage:
== Vim ==


<pre class="nix">{ # /etc/nixos/configuration.nix
=== vim-addon-nix ===
This plugin supports syntax highlighting and simple syntax and undeclared variable checking.
* [https://github.com/MarcWeber/vim-addon-nix vim-addon-nix on github]
 
Usage with '''VAM''' package manager:
<syntaxHighlight lang="nix">{ # /etc/nixos/configuration.nix
   environment.systemPackages = [
   environment.systemPackages = [
     (pkgs.vim_configurable.customize {                                                                                                                                                                                                    
     (pkgs.vim_configurable.customize {
       name = &quot;vim&quot;;                                                                                                                                                                                                                                                                                                                               
       name = "vim";
       vimrcConfig.packages.myplugins = with pkgs.vimPlugins; {                                                                                                                                                                                                                                                                                                                                                                                                   
       vimrcConfig.vam.pluginDictionaries = [
         start = [ vim-nix ]; # load plugin on startup                                                                                                                                                                                                                                     
        # vim-nix handles indentation better but does not perform sanity
       };                                                                                                                                                                                                                                      
         { names = [ "vim-addon-nix" ]; ft_regex = "^nix\$"; }
       ];
     })
     })
   ];
   ];
}</pre>
}</syntaxHighlight>
* IntelliJ IDEA
=== vim-nix ===
* [https://github.com/NixOS/nix-idea nix-idea]
vim-nix *only* supports syntax-highighting.
* Eclipse
* [https://github.com/LnL7/vim-nix vim-nix on github]
* [https://github.com/NixOS/nix-eclipse nix-eclipse]
 
* Sublime Text
Usage with '''vim package manager''':
* [https://github.com/wmertens/sublime-nix sublime-nix]
 
* Atom
<syntaxHighlight lang="nix">{ # /etc/nixos/configuration.nix
* [https://github.com/wmertens/atom-nix atom-nix]
  environment.systemPackages = [
* Visual Studio Code
    (pkgs.vim_configurable.customize {
* [https://github.com/bbenoist/vscode-nix vscode-nix]
      name = "vim";
* Howl
      vimrcConfig.packages.myplugins = with pkgs.vimPlugins; {
* [https://github.com/rokf/howl-nix howl-nix]
        start = [ vim-nix ]; # load plugin on startup
* Far2l
      };
* [https://github.com/NixOS/nixpkgs/pull/28238]
    })
  ];
}</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 ==
* [https://github.com/NixOS/nix-idea nix-idea on github]
== Eclipse ==
* [https://github.com/NixOS/nix-eclipse nix-eclipse] - development stopped in 2010
== Sublime Text ==
* [https://github.com/wmertens/sublime-nix sublime-nix on github]
== Atom ==
* [https://github.com/wmertens/atom-nix atom-nix on github]
== Visual Studio Code ==
* [https://github.com/bbenoist/vscode-nix vscode-nix on github]
* [https://github.com/jnoortheen/vscode-nix-ide vscode-nix-ide on GitHub and VSCode Store] with support to format and lint
== Howl ==
* [https://github.com/rokf/howl-nix howl-nix on github]
== Far2l ==
* [https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/far2l/default.nix far2l with nix syntax highlighting patch in nixpkgs]
 
== nano ==
* [https://github.com/seitz/nanonix nanonix]
 
== 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:Text Editor]]