Vim/ja: Difference between revisions

Haruki7049 (talk | contribs)
Created page with "これらのファイルを自分の<code>configuration.nix</code>でインポートする"
FuzzyBot (talk | contribs)
Updating to match new version of source page
 
(6 intermediate revisions by 2 users not shown)
Line 9: Line 9:
<span id="Basic_Install"></span>
<span id="Basic_Install"></span>
=== ベーシックインストール ===
=== ベーシックインストール ===
unstableでは:
<syntaxhighlight lang="nix>
<syntaxhighlight lang="nix>
   programs.vim.enable = true;
   programs.vim.enable = true;
Line 18: Line 15:
もしくは
もしくは


<syntaxhighlight lang="nix>
<syntaxhighlight lang="nix">
   programs.vim = {
   programs.vim = {
     enable = true;
     enable = true;
     package = pkgs.vim_configurable;
     package = pkgs.vim-full;
   };
   };
</syntaxhighlight>
24.05かそれよりも古い場合は:
<syntaxhighlight lang="nix>
  environment.systemPackages = with pkgs; [ vim ];
</syntaxhighlight>
</syntaxhighlight>


もしくは
もしくは


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


Line 60: Line 51:
=== Vimスペルファイル ===
=== Vimスペルファイル ===


<div class="mw-translate-fuzzy">
個々のスペルファイルをパッケージ化することで、ユーザーディレクトリにスペルファイルをインストールするようにhome-managerを設定することができます。以下はneovimとフランス語の例です:
個々のスペルファイルをパッケージ化することで、ユーザーディレクトリにスペルファイルをインストールするようにhome-managerを設定することができます。以下はneovimとフランス語の例です:
</div>


<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
Line 108: Line 101:
unstableでは:
unstableでは:


<syntaxHighlight lang="nix">
<syntaxhighlight lang="nix">
{ pkgs, ... }:
{ pkgs, ... }:
{
{
Line 114: Line 107:
     enable = true;
     enable = true;
     defaultEditor = true;
     defaultEditor = true;
     package = (pkgs.vim_configurable.override {  }).customize{
     package = (pkgs.vim-full.override {  }).customize{
       name = "vim";
       name = "vim";
       # 例として、Nixファイルのシンタックスハイライト表示用のプラグインをインストールする
       # 例として、Nixファイルのシンタックスハイライト表示用のプラグインをインストールする
Line 132: Line 125:
   };
   };
}
}
</syntaxHighlight>
</syntaxhighlight>
 
24.05かそれよりも古い場合は
 
<syntaxHighlight lang="nix">
{ pkgs, ... }:
{
  environment.variables = { EDITOR = "vim";
  environment.systemPackages = with pkgs; [
    ((vim_configurable.override {  }).customize{
      name = "vim";
      # 例としてNixファイルのシンタックスハイライト表示用のプラグインをインストールする
      vimrcConfig.packages.myplugins = with pkgs.vimPlugins; {
        start = [ vim-nix vim-lastplace ];
        opt = [];
      };
      vimrcConfig.customRC = ''
        " 自分のカスタムvimrc
        set nocompatible
        set backspace=indent,eol,start
        " シンタックスハイライトをデフォルトでオンにする
        syntax on
        " ...
      '';
    }
  )];
}
</syntaxHighlight>
 
<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
{ pkgs, ... }:
{ pkgs, ... }:
Line 195: Line 160:
</syntaxHighlight>
</syntaxHighlight>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Custom_setup_without_using_Home_Manager"></span>
== Custom setup without using Home Manager ==
== Home Managerを使用しないカスタムセットアップ ==
</div>


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


<div lang="en" dir="ltr" class="mw-content-ltr">
Vimプラグインはnixの助けを借りてインストールすることができます。vimプラグインマネージャーを使用せず、すべて<code>.nixpkgs/config</code>で行うことができます。
Vim plugins can be installed with the help of nix. You can omit using vim plugin managers and do everything in your <code>.nixpkgs/config</code>.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
A lot of documentation about package management and configuration of vim in nix is stored at [https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vim/plugins/vim-utils.nix] in nixpkgs.
A lot of documentation about package management and configuration of vim in nix is stored at [https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/vim.section.md] in nixpkgs.
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Customizations"></span>
=== Customizations ===
=== カスタマイズする ===
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
vimもneovimも、あなたの好きなプラグインや追加ライブラリを含むようにさらに設定することができます。利用可能な全ての vim プラグインをリストアップするには、<code>nix search nixpkgs#vimPlugins</code>を実行してください。
Both vim and neovim can be further configured to include your favorite plugins and additional libraries. To list all available vim plugins, run <code>nix search nixpkgs#vimPlugins</code>.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
以下のコードを<code>~/.nixpkgs/config.nix</code>に追加してください:
Add the following code to your <code>~/.nixpkgs/config.nix</code>:
</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 250: Line 207:
   };
   };
}
}
</syntaxHighlight>
</syntaxhighlight>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 268: Line 225:
</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 279: Line 236:
   '';
   '';
}
}
</syntaxHighlight>
</syntaxhighlight>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 289: Line 246:
</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 306: Line 263:
   }
   }
};
};
</syntaxHighlight>
</syntaxhighlight>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 338: Line 295:


<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.
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
* First run <code>./update.py</code>.
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
* Commit the changes with the commit message "vimPlugins: Update".
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
* 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)
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
* Run <code>./update.py</code> once again to generate the plugin's nix expression.
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
* Commit your changes one more time, this time with the message formated as such: "vimPlugins.[plugin-name]: init at [version]".
</div>
 
<div lang="en" dir="ltr" class="mw-content-ltr">
* 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 381: Line 314:
</div>
</div>


<syntaxHighlight lang="nix">
<syntaxhighlight lang="nix">
let
let
   vim-better-whitespace = pkgs.vimUtils.buildVimPlugin {
   vim-better-whitespace = pkgs.vimUtils.buildVimPlugin {
Line 394: Line 327:
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 401: Line 334:
   ];
   ];
};
};
</syntaxHighlight>
</syntaxhighlight>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 465: Line 398:


<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 472: Line 405:
</div>
</div>


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


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Line 537: Line 470:


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
== Python 3 support for vim ==
== gvim and gview ==
</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:
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="nix">
<syntaxhighlight lang="nix">
(pkgs.callPackage ./my_vim.nix {                                                                                                                                                        
(pkgs.vim-full.customize {
      vim_configurable = vim_configurable.override { python = python3; };                                                                                                                    
  guiSupport = true;
})
})
</syntaxHighlight>
<div lang="en" dir="ltr" class="mw-content-ltr">
== gvim and gview ==
</div>
<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>).
</div>
<syntaxhighlight lang=bash>
$ nix-env -iA nixos.vimHugeX
</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>
</syntaxhighlight>


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