Vim: Difference between revisions

Tea (talk | contribs)
Use shorter syntax for setting xdg config files
Jopejoe1 (talk | contribs)
Use dedicated NixOS options instead of systemPackages
Line 7: Line 7:


=== Basic Install === <!--T:3-->
=== Basic Install === <!--T:3-->
On unstable:
<syntaxhighlight lang="nix>
  programs.vim.enable = true;
</syntaxhighlight>
or
<syntaxhighlight lang="nix>
  programs.vim = {
    enable = true;
    package = pkgs.vim_configurable;
  };
</syntaxhighlight>
On 24.05 or older:


<!--T:4-->
<!--T:4-->
Line 88: Line 105:
<!--T:19-->
<!--T:19-->
If you want a system wide "baseline" configuration for vim/nvim here are two examples:.
If you want a system wide "baseline" configuration for vim/nvim here are two examples:.
   
 
On unstable:
<syntaxHighlight lang="nix">
{ pkgs, ... }:
{
  programs.vim = {
    enable = true;
    defaultEditor = true;
    package = (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>
 
 
On 24.05 or older:
<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
{ pkgs, ... }:
{ pkgs, ... }:
Line 120: Line 166:
{ pkgs, ... }:
{ pkgs, ... }:
{
{
   environment.variables = { EDITOR = "vim"; };
   programs.neovim = {
 
    enable = true;
  <!--T:22-->
    defaultEditor = true;
environment.systemPackages = with pkgs; [
     vimAlias = true;
     (neovim.override {
    configure = {
      vimAlias = true;
       customRC = ''
       extraConfig = ''
         " your custom vimrc
         " your custom vimrc
         set nocompatible
         set nocompatible
Line 132: Line 177:
         " ...
         " ...
       '';
       '';
       configure = {
       packages.myPlugins = with pkgs.vimPlugins; {
        packages.myPlugins = with pkgs.vimPlugins; {
        start = [ vim-lastplace vim-nix ];  
          start = [ vim-lastplace vim-nix ];  
        opt = [];
          opt = [];
        };
       };
       };
     }
     };
   )];
   };
}
}
</syntaxHighlight>
</syntaxHighlight>