Neovim: Difference between revisions

imported>Onny
Restructure and cleanup
imported>Onny
Add example system configuration
Line 30: Line 30:


== Configuration ==
== Configuration ==
Neovim shares most of its configuration with Vim. See the [[Vim|Vim page]] for more details on the use of both.


=== With Home Manager ===
=== With Home Manager ===
Neovim shares most of its configuration with Vim. See the [[Vim|Vim page]] for more details on the use of both.


The Home Manager module does not expose many configuration options. Therefore, the easiest way to get started is to use the [https://nix-community.github.io/home-manager/options.html#opt-programs.neovim.extraConfig extraConfig] option.
The Home Manager module does not expose many configuration options. Therefore, the easiest way to get started is to use the [https://nix-community.github.io/home-manager/options.html#opt-programs.neovim.extraConfig extraConfig] option.
Line 70: Line 70:
In addition to the official packages, there are several user maintained repositories, such as [https://github.com/m15a/nixpkgs-vim-extra-plugins vim-extra-plugins] or [https://github.com/NixNeovim/NixNeovimPlugins NixNeovimPlugins].
In addition to the official packages, there are several user maintained repositories, such as [https://github.com/m15a/nixpkgs-vim-extra-plugins vim-extra-plugins] or [https://github.com/NixNeovim/NixNeovimPlugins NixNeovimPlugins].


=== With Home Manager ===
=== System-wide ===


The NixOS module does not have an <code>extraConfig</code> option as the Home Manager module does.
The NixOS module does not have an <code>extraConfig</code> option as the Home Manager module does.
Instead, you can use the <code>programs.neovim.configure</code> option as described [https://search.nixos.org/options?show=programs.neovim.configure&type=packages&query=neovim here].
Instead, you can use the <code>programs.neovim.configure</code> option as described [https://search.nixos.org/options?show=programs.neovim.configure&type=packages&query=neovim here].
The following example configures RC commands and enables the plugin <code>vim-nix</code> to support syntax highlighting for Nix files
  programs.neovim = {
    enable = true;
    configure = {
      customRC = ''
        set number
        set cc=80
        set list
        set listchars=tab:→\ ,space:·,nbsp:␣,trail:•,eol:¶,precedes:«,extends:»
        if &diff
          colorscheme blue
        endif
      '';
      packages.myVimPackage = with pkgs.vimPlugins; {
        start = [ vim-nix ];
      };
    };
  };


Similarly to the Home Manager module, to set Neovim as your default editor you have to set the <code>EDITOR</code> environment variable like this:
Similarly to the Home Manager module, to set Neovim as your default editor you have to set the <code>EDITOR</code> environment variable like this: