Vim: Difference between revisions

imported>Aabccd021
No edit summary
imported>Harärmat
Move section about system-wide configuration higher up and make it work
Line 66: Line 66:
For NeoVim use this home manager config:
For NeoVim use this home manager config:
https://github.com/NixOS/nixpkgs/issues/98166#issuecomment-725319238
https://github.com/NixOS/nixpkgs/issues/98166#issuecomment-725319238
== System wide vim/nvim configuration ==
If you want a system wide "baseline" configuration for vim/nvim here are two examples:.
<syntaxHighlight lang="nix">
{ pkgs, ... }:
{
  environment.variables = { EDITOR = "vim"; };
  environment.systemPackages = with pkgs; [
    ((vim_configurable.override {  }).customize{
      name = "vim";
      # Install plugins for example for syntax highlighting of nix files
      vimrcConfig.packages.myplugins = with pkgs.vimPlugins; {
        start = [ vim-nix vim-lastplace ];
        opt = [];
      };
      vimrcConfig.customRC = ''
        " your custom vimrc
        set nocompatible
        set backspace=indent,eol,start
        " Turn on syntax highlighting by default
        syntax on
        " ...
      '';
    }
  )];
}
</syntaxHighlight>
<syntaxHighlight lang="nix">
{ pkgs, ... }:
{
  environment.variables = { EDITOR = "vim"; };
  environment.systemPackages = with pkgs; [
    (neovim.override {
      vimAlias = true;
      configure = {
        packages.myPlugins = with pkgs.vimPlugins; {
          start = [ vim-lastplace vim-nix ];
          opt = [];
        };
        customRC = ''
          " your custom vimrc
          set nocompatible
          set backspace=indent,eol,start
          " ...
        '';
      };
    }
  )];
}
</syntaxHighlight>
import these in your <code>configuration.nix</code> and
<syntaxHighlight lang="nix">
{   
  imports =   
    [
      ./vim.nix
    ];
  # ...
}
</syntaxHighlight>


== Custom setup without using Home Manager ==
== Custom setup without using Home Manager ==
Line 323: Line 389:
};
};
</syntaxhighlight>
</syntaxhighlight>
=== System wide vim/nvim configuration ===
If you want a system wide "baseline" configuration for vim/nvim here are two examples:
The vim example has python3 support as mentioned above.
<syntaxHighlight lang="nix">
{ pkgs, ... }:
{
  environment.variables = { EDITOR = "vim"; };
  environment.systemPackages = with pkgs; [
    ((vim_configurable.override { python = python3; }).customize{
      name = "vim";
      vimrcConfig.packages.myplugins = with pkgs.vimPlugins; {
        start = [ vim-nix vim-lastplace ];
        opt = [];
      };
      vimrcConfig.customRC = ''
        " your custom vimrc
        set nocompatible
        set backspace=indent,eol,start
        " ...
      '';
    }
  )];
}
</syntaxHighlight>
<syntaxHighlight lang="nix">
{ pkgs, ... }:
{
  environment.variables = { EDITOR = "vim"; };
  environment.systemPackages = with pkgs; [
    (neovim.override {
      vimAlias = true;
      configure = {
        packages.myPlugins = with pkgs.vimPlugins; {
          start = [ vim-lastplace vim-nix ];
          opt = [];
        };
        customRC = ''
          " your custom vimrc
          set nocompatible
          set backspace=indent,eol,start
          " ...
        '';
      };
    }
  )];
}
</syntaxHighlight>
import these in your <code>configuration.nix</code> and
<syntaxHighlight lang="nix">
{   
  imports =   
    [
      ./vim.nix
    ];
  # ...
}
</syntaxHighlight>