Vim/de: Difference between revisions

Jopejoe1 (talk | contribs)
Created page with "Vim kann sehr einfach mit Home Manager eingerichtet werden. Hier ist ein minimales Beispiel:"
FuzzyBot (talk | contribs)
Updating to match new version of source page
 
(8 intermediate revisions by 2 users not shown)
Line 8: Line 8:
<span id="Basic_Install"></span>
<span id="Basic_Install"></span>
=== Grundinstallation ===
=== Grundinstallation ===
Auf unstable:
<syntaxhighlight lang="nix>
<syntaxhighlight lang="nix>
   programs.vim.enable = true;
   programs.vim.enable = true;
Line 17: Line 14:
oder
oder


<syntaxhighlight lang="nix>
<syntaxhighlight lang="nix">
   programs.vim = {
   programs.vim = {
     enable = true;
     enable = true;
     package = pkgs.vim_configurable;
     package = pkgs.vim-full;
   };
   };
</syntaxhighlight>
Auf 24.05 oder älter:
<syntaxhighlight lang="nix>
  environment.systemPackages = with pkgs; [ vim ];
</syntaxhighlight>
</syntaxhighlight>


oder
oder


<syntaxhighlight lang="nix>
<syntaxhighlight lang="nix">
   environment.systemPackages = with pkgs; [ vim_configurable ];
   environment.systemPackages = with pkgs; [ vim-full ];
</syntaxhighlight>
</syntaxhighlight>


Line 56: Line 47:
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Vim_Spell_Files"></span>
=== Vim Spell Files ===
=== Vim Spell Dateien ===
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
You can configure home-manager to install spelling files into your user directory by packaging individual spell files.  Here' an example for neovim and French:
You can configure home-manager to install spelling files into your user directory by packaging individual spell files.  Here' an example for [[neovim]] and French:
</div>
</div>


Line 94: Line 84:
</syntaxHighlight>
</syntaxHighlight>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="NeoVim_with_Coc_for_Python"></span>
==== NeoVim with Coc for Python ====
==== NeoVim mit Coc für Python ====
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 103: Line 92:
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="System_wide_vim/nvim_configuration"></span>
== System wide vim/nvim configuration ==
== System weite vim/nvim Konfiguration ==
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 115: Line 103:
</div>
</div>


<syntaxHighlight lang="nix">
<syntaxhighlight lang="nix">
{ pkgs, ... }:
{ pkgs, ... }:
{
{
Line 121: Line 109:
     enable = true;
     enable = true;
     defaultEditor = true;
     defaultEditor = true;
     package = (pkgs.vim_configurable.override {  }).customize{
     package = (pkgs.vim-full.override {  }).customize{
       name = "vim";
       name = "vim";
       <div lang="en" dir="ltr" class="mw-content-ltr">
       # Installiere Plugins wie zum Beispiel für Syntaxhervorhebung von Nix Dateien
# Install plugins for example for syntax highlighting of nix files
</div>
       vimrcConfig.packages.myplugins = with pkgs.vimPlugins; {
       vimrcConfig.packages.myplugins = with pkgs.vimPlugins; {
         start = [ vim-nix vim-lastplace ];
         start = [ vim-nix vim-lastplace ];
Line 131: Line 117:
       };
       };
       vimrcConfig.customRC = ''
       vimrcConfig.customRC = ''
         <div lang="en" dir="ltr" class="mw-content-ltr">
         " deine benutzerdefinierte vimrc
" your custom vimrc
</div>
         set nocompatible
         set nocompatible
         set backspace=indent,eol,start
         set backspace=indent,eol,start
         <div lang="en" dir="ltr" class="mw-content-ltr">
         " Syntaxhervorhebung standardmäßig aktivieren
" Turn on syntax highlighting by default
</div>
         syntax on
         syntax on
         " ...
         " ...
Line 145: Line 127:
   };
   };
}
}
</syntaxHighlight>
</syntaxhighlight>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
On 24.05 or older:
</div>
 
<syntaxHighlight lang="nix">
{ pkgs, ... }:
{
  environment.variables = { EDITOR = "vim";
  environment.systemPackages = with pkgs; [
    ((vim_configurable.override {  }).customize{
      name = "vim";
      <div lang="en" dir="ltr" class="mw-content-ltr">
# Install plugins for example for syntax highlighting of nix files
</div>
      vimrcConfig.packages.myplugins = with pkgs.vimPlugins; {
        start = [ vim-nix vim-lastplace ];
        opt = [];
      };
      vimrcConfig.customRC = ''
        <div lang="en" dir="ltr" class="mw-content-ltr">
" your custom vimrc
</div>
        set nocompatible
        set backspace=indent,eol,start
        <div lang="en" dir="ltr" class="mw-content-ltr">
" Turn on syntax highlighting by default
</div>
        syntax on
        " ...
      '';
    }
  )];
}
</syntaxHighlight>
 
<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
{ pkgs, ... }:
{ pkgs, ... }:
Line 248: Line 194:
</div>
</div>


<syntaxHighlight lang="nix">
<syntaxhighlight lang="nix">
{
{
   packageOverrides = pkgs: with pkgs; {
   packageOverrides = pkgs: with pkgs; {
     myVim = vim_configurable.customize {
     myVim = vim-full.customize {
       name = "vim-with-plugins";
       name = "vim-with-plugins";
       <div lang="en" dir="ltr" class="mw-content-ltr">
       <div lang="en" dir="ltr" class="mw-content-ltr">
Line 275: Line 221:
   };
   };
}
}
</syntaxHighlight>
</syntaxhighlight>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 293: Line 239:
</div>
</div>


<syntaxHighlight lang="nix">
<syntaxhighlight lang="nix">
vim_configurable.customize {
vim-full.customize {
   name = "vim-with-plugins";
   name = "vim-with-plugins";
   <div lang="en" dir="ltr" class="mw-content-ltr">
   <div lang="en" dir="ltr" class="mw-content-ltr">
Line 304: Line 250:
   '';
   '';
}
}
</syntaxHighlight>
</syntaxhighlight>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 314: Line 260:
</div>
</div>


<syntaxHighlight lang="nix">
<syntaxhighlight lang="nix">
vim_configurable.customize {
vim-full.customize {
   vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; {
   vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; {
     <div lang="en" dir="ltr" class="mw-content-ltr">
     <div lang="en" dir="ltr" class="mw-content-ltr">
Line 331: Line 277:
   }
   }
};
};
</syntaxHighlight>
</syntaxhighlight>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 363: Line 309:


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
As per the instructions found in https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/vim.section.md
Please see https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/vim.section.md.
* First run <code>./update.py</code>.
* Commit the changes with the commit message "vimPlugins: Update".
* Add your plugin to ./vim-plugin-names (please try to maintain the list alphabetically sorted). You can customize the branch by appending for example <code>@main</code> to an entry (search the file for examples)
* Run <code>./update.py</code> once again to generate the plugin's nix expression.
* Commit your changes one more time, this time with the message formated as such: "vimPlugins.[plugin-name]: init at [version]".
* If you need to add additional code/patches to the generated code, add those lines to <code>pkgs/misc/vim-plugins/vim2nix/additional-nix-code</code> and rerun <code>./update.py</code>. They will be included in the generated code.
</div>
</div>


Line 388: Line 328:
</div>
</div>


<syntaxHighlight lang="nix">
<syntaxhighlight lang="nix">
let
let
   vim-better-whitespace = pkgs.vimUtils.buildVimPlugin {
   vim-better-whitespace = pkgs.vimUtils.buildVimPlugin {
Line 401: Line 341:
in {
in {
   users.users.<yourNickname>.packages = [
   users.users.<yourNickname>.packages = [
     (pkgs.vim_configurable.customize {
     (pkgs.vim-full.customize {
       vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; {
       vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; {
         start = [ vim-better-whitespace ];
         start = [ vim-better-whitespace ];
Line 408: Line 348:
   ];
   ];
};
};
</syntaxHighlight>
</syntaxhighlight>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 472: Line 412:


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
The following snippet will make a full featured python IDE.
The following snippet will make a full featured [[python]] IDE.
</div>
</div>


Line 479: Line 419:
</div>
</div>


<syntaxHighlight lang="nix">
<syntaxhighlight lang="nix">
vim_configurable.customize {
vim-full.customize {
   vimrcConfig = {
   vimrcConfig = {
     customRC = ''
     customRC = ''
Line 498: Line 438:
     }
     }
};
};
</syntaxHighlight>
</syntaxhighlight>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 521: Line 461:
<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
* [https://github.com/jagajaga/my_configs/blob/master/.nixpkgs/common.nix Jagajaga’s config]
* [https://github.com/jagajaga/my_configs/blob/master/.nixpkgs/common.nix Jagajaga’s config]
* [https://github.com/andrewrk/dotfiles/blob/master/.nixpkgs/config.nix andrewrk's config]
* [https://github.com/wagnerf42/nixos-config/blob/master/config/my_vim.nix wagnerf42's config (good for rust language)]
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
=== YouCompleteMe ===
* [https://github.com/andrewrk/dotfiles/blob/master/.nixpkgs/config.nix andrewrk's config]
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Currently the youcompleteme plugin uses [https://github.com/NixOS/nixpkgs/blob/8e7b1f2ac2e261d5a644fef860a0d050ea227c06/pkgs/misc/vim-plugins/default.nix#L695 unwrapped clang on linux]. This causes it to not find <code>stdlib.h</code>. There is a [https://github.com/andrewrk/genesis/blob/5f49cd9a8c2b61b9859a22102bc3f732add9461a/.ycm_extra_conf.py workaround] you can put in your <code>.ycm_extra_conf.py</code> file, which works by executing the C/C++ compiler and getting it to output the list of search paths - which includes the search path to find <code>stdlib.h</code>.
* [https://github.com/wagnerf42/nixos-config/blob/master/config/my_vim.nix wagnerf42's config (good for rust language)]
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
A better alternative to youcompleteme for C/C++ is to use [https://github.com/cquery-project/cquery/ cquery] in combination with the [https://github.com/autozimu/LanguageClient-neovim LanguageClient-neovim]. It will also find in c header files when used in a nix-shell if you install cquery from nixpkgs as it uses a custom [https://github.com/NixOS/nixpkgs/commit/04f3b76dcec21f2fcba6b1b0afbb3ed224165050#diff-11cdfc0385b9e017089c1ac09c5b838e shell wrapper]
=== YouCompleteMe ===
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
== Python 3 support for vim ==
Currently the youcompleteme plugin uses [https://github.com/NixOS/nixpkgs/blob/8e7b1f2ac2e261d5a644fef860a0d050ea227c06/pkgs/misc/vim-plugins/default.nix#L695 unwrapped clang on linux]. This causes it to not find <code>stdlib.h</code>. There is a [https://github.com/andrewrk/genesis/blob/5f49cd9a8c2b61b9859a22102bc3f732add9461a/.ycm_extra_conf.py workaround] you can put in your <code>.ycm_extra_conf.py</code> file, which works by executing the C/C++ compiler and getting it to output the list of search paths - which includes the search path to find <code>stdlib.h</code>.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
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:
A better alternative to youcompleteme for C/C++ is to use [https://github.com/cquery-project/cquery/ cquery] in combination with the [https://github.com/autozimu/LanguageClient-neovim LanguageClient-neovim]. It will also find in c header files when used in a nix-shell if you install cquery from nixpkgs as it uses a custom [https://github.com/NixOS/nixpkgs/commit/04f3b76dcec21f2fcba6b1b0afbb3ed224165050#diff-11cdfc0385b9e017089c1ac09c5b838e shell wrapper]
</div>
</div>
<syntaxHighlight  lang="nix">
(pkgs.callPackage ./my_vim.nix {                                                                                                                                                         
      vim_configurable = vim_configurable.override { python = python3; };                                                                                                                   
})
</syntaxHighlight>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 556: Line 488:


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
<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>).
You can enable <code>guiSupport</code> to make <code>gvim</code> available, though this won't give you <code>gview</code>:
</div>
</div>


<syntaxhighlight lang=bash>
<syntaxhighlight lang="nix">
$ nix-env -iA nixos.vimHugeX
(pkgs.vim-full.customize {
  guiSupport = true;
})
</syntaxhighlight>
</syntaxhighlight>
<div lang="en" dir="ltr" class="mw-content-ltr">
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>:
</div>
<syntaxhighlight lang=nix>
vim_configured = pkgs.vim_configurable.customize {
  name = "vim";
  wrapGui = true;
};
</syntaxhighlight


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