Vim/en: Difference between revisions

FuzzyBot (talk | contribs)
Updating to match new version of source page
Tags: Mobile edit Mobile web edit
 
FuzzyBot (talk | contribs)
Updating to match new version of source page
Line 5: Line 5:


=== Basic Install ===
=== Basic Install ===
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:


<syntaxhighlight lang="nix>
<syntaxhighlight lang="nix>
Line 19: Line 36:


Vim can easily be set up using [[Special:MyLanguage/Home Manager|Home Manager]]. Here's a minimal example:
Vim can easily be set up using [[Special:MyLanguage/Home Manager|Home Manager]]. Here's a minimal example:
<syntaxhighlight lang="nix>
<syntaxhighlight lang="nix>
   programs.vim = {
   programs.vim = {
Line 59: Line 77:
in
in
{
{
   home.file."${config.xdg.configHome}/nvim/spell/fr.utf-8.spl".source = nvim-spell-fr-utf8-dictionary;
   xdg.configFile."nvim/spell/fr.utf-8.spl".source = nvim-spell-fr-utf8-dictionary;
   home.file."${config.xdg.configHome}/nvim/spell/fr.utf-8.sug".source = nvim-spell-fr-utf8-suggestions;
   xdg.configFile."nvim/spell/fr.utf-8.sug".source = nvim-spell-fr-utf8-suggestions;
   home.file."${config.xdg.configHome}/nvim/spell/fr.latin1.spl".source = nvim-spell-fr-latin1-dictionary;
   xdg.configFile."nvim/spell/fr.latin1.spl".source = nvim-spell-fr-latin1-dictionary;
   home.file."${config.xdg.configHome}/nvim/spell/fr.latin1.sug".source = nvim-spell-fr-latin1-suggestions;
   xdg.configFile."nvim/spell/fr.latin1.sug".source = nvim-spell-fr-latin1-suggestions;
}
}
</syntaxHighlight>
</syntaxHighlight>
Line 74: Line 92:


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">
<syntaxHighlight lang="nix">
{ pkgs, ... }:
{ pkgs, ... }:
{
{
   environment.variables = { EDITOR = "vim"; };
   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">
{ pkgs, ... }:
{
  environment.variables = { EDITOR = "vim";
   environment.systemPackages = with pkgs; [
   environment.systemPackages = with pkgs; [
     ((vim_configurable.override {  }).customize{
     ((vim_configurable.override {  }).customize{
Line 104: Line 151:
{ pkgs, ... }:
{ pkgs, ... }:
{
{
   environment.variables = { EDITOR = "vim"; };
   programs.neovim = {
 
    enable = true;
  environment.systemPackages = with pkgs; [
    defaultEditor = true;
     (neovim.override {
     vimAlias = true;
      vimAlias = true;
    configure = {
       extraConfig = ''
       customRC = ''
         " your custom vimrc
         " your custom vimrc
         set nocompatible
         set nocompatible
Line 115: Line 162:
         " ...
         " ...
       '';
       '';
       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>
Line 215: Line 260:


There is a pathogen implementation as well, but its startup is slower and [VAM] has more features.  
There is a pathogen implementation as well, but its startup is slower and [VAM] has more features.  
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
vimrcConfig.pathogen.knownPlugins = vimPlugins; # optional
vimrcConfig.pathogen.knownPlugins = vimPlugins; # optional
Line 255: Line 301:
     };
     };
   };
   };
in {
in {
   users.users.<yourNickname>.packages = [
   users.users.<yourNickname>.packages = [
Line 349: Line 394:
Then put the following expression in <code>environment.systemPackages</code> or in the home-manager package list,
Then put the following expression in <code>environment.systemPackages</code> or in the home-manager package list,
to install python-language-server:
to install python-language-server:
 
<syntaxHighlight  lang="nix">
<syntaxHighlight  lang="nix">
(python3.withPackages(ps: [
(python3.withPackages(ps: [
Line 373: Line 418:


If you have defined your vim configuration in a `./my_vim.nix` file you can install vim with the python 3 support instead of python2 by overriding the python version like the following:
If you have defined your vim configuration in a `./my_vim.nix` file you can install vim with the python 3 support instead of python2 by overriding the python version like the following:
 
<syntaxHighlight  lang="nix">
<syntaxHighlight  lang="nix">
(pkgs.callPackage ./my_vim.nix {                                                                                                                                                           
(pkgs.callPackage ./my_vim.nix {                                                                                                                                                           
Line 383: Line 428:


<code>gvim</code> and <code>gview</code> may be installed using the <code>[https://search.nixos.org/packages/?query=vimHugeX vimHugeX]</code> attribute name (package name <code>[https://search.nixos.org/packages/?query=vim_configurable vim_configurable]</code>).
<code>gvim</code> and <code>gview</code> may be installed using the <code>[https://search.nixos.org/packages/?query=vimHugeX vimHugeX]</code> attribute name (package name <code>[https://search.nixos.org/packages/?query=vim_configurable vim_configurable]</code>).
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
$ nix-env -iA nixos.vimHugeX
$ nix-env -iA nixos.vimHugeX
Line 388: Line 434:


If you are using <code>vim_configurable.customize</code>, you can enable <code>wrapGui</code> to make <code>gvim</code> available, though this won't give you <code>gview</code>:
If you are using <code>vim_configurable.customize</code>, you can enable <code>wrapGui</code> to make <code>gvim</code> available, though this won't give you <code>gview</code>:
<syntaxhighlight lang=nix>
<syntaxhighlight lang=nix>
vim_configured = pkgs.vim_configurable.customize {
vim_configured = pkgs.vim_configurable.customize {
Line 393: Line 440:
   wrapGui = true;
   wrapGui = true;
};
};
</syntaxhighlight>
</syntaxhighlight


[[Category:Applications]]
[[Category:Applications]]
[[Category:Text Editor{{#translation:}}]]
[[Category:Text Editor{{#translation:}}]]