Vim/ja: Difference between revisions
Haruki7049 (talk | contribs) Created page with "個々のスペルファイルをパッケージ化することで、ユーザーディレクトリにスペルファイルをインストールするようにhome-managerを設定することができます。以下はneovimとフランス語の例です:" |
Updating to match new version of source page |
||
Line 9: | Line 9: | ||
<span id="Basic_Install"></span> | <span id="Basic_Install"></span> | ||
=== ベーシックインストール === | === ベーシックインストール === | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
On unstable: | |||
</div> | |||
<syntaxhighlight lang="nix> | |||
programs.vim.enable = true; | |||
</syntaxhighlight> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
or | |||
</div> | |||
<syntaxhighlight lang="nix> | |||
programs.vim = { | |||
enable = true; | |||
package = pkgs.vim_configurable; | |||
}; | |||
</syntaxhighlight> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
On 24.05 or older: | |||
</div> | |||
<syntaxhighlight lang="nix> | <syntaxhighlight lang="nix> | ||
Line 23: | Line 46: | ||
=== Home Managerを使用した例 === | === Home Managerを使用した例 === | ||
<div class="mw-translate-fuzzy"> | |||
Vimは[[Special:MyLanguage/Home Manager|Home Manager]]を使用して簡単にセットアップ出来ます。以下は最低限の一例です: | Vimは[[Special:MyLanguage/Home Manager|Home Manager]]を使用して簡単にセットアップ出来ます。以下は最低限の一例です: | ||
<syntaxhighlight lang="nix> | |||
programs.vim = { | |||
enable = true; | |||
plugins = with pkgs.vimPlugins; [ vim-airline ]; | |||
settings = { ignorecase = true; }; | |||
extraConfig = '' | |||
set mouse=a | |||
''; | |||
}; | |||
</syntaxhighlight> | |||
</div> | |||
<syntaxhighlight lang="nix> | <syntaxhighlight lang="nix> | ||
programs.vim = { | programs.vim = { | ||
Line 44: | Line 80: | ||
個々のスペルファイルをパッケージ化することで、ユーザーディレクトリにスペルファイルをインストールするようにhome-managerを設定することができます。以下はneovimとフランス語の例です: | 個々のスペルファイルをパッケージ化することで、ユーザーディレクトリにスペルファイルをインストールするようにhome-managerを設定することができます。以下はneovimとフランス語の例です: | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
let | let | ||
Line 51: | Line 86: | ||
sha256 = "abfb9702b98d887c175ace58f1ab39733dc08d03b674d914f56344ef86e63b61"; | sha256 = "abfb9702b98d887c175ace58f1ab39733dc08d03b674d914f56344ef86e63b61"; | ||
}; | }; | ||
nvim-spell-fr-utf8-suggestions = builtins.fetchurl { | nvim-spell-fr-utf8-suggestions = builtins.fetchurl { | ||
url = "http://ftp.vim.org/vim/runtime/spell/fr.utf-8.sug"; | url = "http://ftp.vim.org/vim/runtime/spell/fr.utf-8.sug"; | ||
sha256 = "0294bc32b42c90bbb286a89e23ca3773b7ef50eff1ab523b1513d6a25c6b3f58"; | sha256 = "0294bc32b42c90bbb286a89e23ca3773b7ef50eff1ab523b1513d6a25c6b3f58"; | ||
}; | }; | ||
nvim-spell-fr-latin1-dictionary = builtins.fetchurl { | nvim-spell-fr-latin1-dictionary = builtins.fetchurl { | ||
url = "http://ftp.vim.org/vim/runtime/spell/fr.latin1.spl"; | url = "http://ftp.vim.org/vim/runtime/spell/fr.latin1.spl"; | ||
sha256 = "086ccda0891594c93eab143aa83ffbbd25d013c1b82866bbb48bb1cb788cc2ff"; | sha256 = "086ccda0891594c93eab143aa83ffbbd25d013c1b82866bbb48bb1cb788cc2ff"; | ||
}; | }; | ||
nvim-spell-fr-latin1-suggestions = builtins.fetchurl { | nvim-spell-fr-latin1-suggestions = builtins.fetchurl { | ||
url = "http://ftp.vim.org/vim/runtime/spell/fr.latin1.sug"; | url = "http://ftp.vim.org/vim/runtime/spell/fr.latin1.sug"; | ||
Line 74: | Line 103: | ||
in | in | ||
{ | { | ||
xdg.configFile."nvim/spell/fr.utf-8.spl".source = nvim-spell-fr-utf8-dictionary; | |||
xdg.configFile."nvim/spell/fr.utf-8.sug".source = nvim-spell-fr-utf8-suggestions; | |||
xdg.configFile."nvim/spell/fr.latin1.spl".source = nvim-spell-fr-latin1-dictionary; | |||
xdg.configFile."nvim/spell/fr.latin1.sug".source = nvim-spell-fr-latin1-suggestions; | |||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 97: | Line 125: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
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:. | ||
</div> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
On unstable: | |||
</div> | |||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
{ pkgs, ... }: | { pkgs, ... }: | ||
{ | { | ||
programs.vim = { | |||
enable = true; | |||
defaultEditor = true; | |||
package = (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> | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
On 24.05 or older: | |||
</div> | </div> | ||
<syntaxHighlight lang="nix"> | |||
environment.systemPackages = with pkgs; [ | { pkgs, ... }: | ||
{ | |||
environment.variables = { EDITOR = "vim"; | |||
environment.systemPackages = with pkgs; [ | |||
((vim_configurable.override { }).customize{ | ((vim_configurable.override { }).customize{ | ||
name = "vim"; | name = "vim"; | ||
# Install plugins for example for syntax highlighting of nix files | <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; { | vimrcConfig.packages.myplugins = with pkgs.vimPlugins; { | ||
start = [ vim-nix vim-lastplace ]; | start = [ vim-nix vim-lastplace ]; | ||
Line 114: | Line 182: | ||
}; | }; | ||
vimrcConfig.customRC = '' | vimrcConfig.customRC = '' | ||
" your custom vimrc | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
" your custom vimrc | |||
</div> | |||
set nocompatible | set nocompatible | ||
set backspace=indent,eol,start | set backspace=indent,eol,start | ||
" Turn on syntax highlighting by default | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
" Turn on syntax highlighting by default | |||
</div> | |||
syntax on | syntax on | ||
" ... | " ... | ||
Line 125: | Line 197: | ||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
{ pkgs, ... }: | { pkgs, ... }: | ||
{ | { | ||
programs.neovim = { | |||
enable = true; | |||
defaultEditor = true; | |||
vimAlias = true; | |||
configure = { | |||
customRC = '' | |||
<div lang="en" dir="ltr" class="mw-content-ltr"> | |||
" your custom vimrc | |||
</div> | </div> | ||
set nocompatible | set nocompatible | ||
set backspace=indent,eol,start | set backspace=indent,eol,start | ||
" ... | " ... | ||
''; | ''; | ||
packages.myPlugins = with pkgs.vimPlugins; { | |||
start = [ vim-lastplace vim-nix ]; | |||
opt = []; | |||
}; | }; | ||
} | }; | ||
}; | |||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
import these in your <code>configuration.nix</code> and | import these in your <code>configuration.nix</code> and | ||
</div> | |||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
{ | { | ||
Line 167: | Line 235: | ||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 197: | Line 264: | ||
</div> | </div> | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
{ | { | ||
Line 203: | Line 269: | ||
myVim = vim_configurable.customize { | myVim = vim_configurable.customize { | ||
name = "vim-with-plugins"; | name = "vim-with-plugins"; | ||
# add here code from the example section | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
# add here code from the example section | |||
</div> | |||
}; | }; | ||
myNeovim = neovim.override { | myNeovim = neovim.override { | ||
configure = { | configure = { | ||
customRC = '' | customRC = '' | ||
# here your custom configuration goes! | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
# here your custom configuration goes! | |||
</div> | |||
''; | ''; | ||
packages.myVimPackage = with pkgs.vimPlugins; { | packages.myVimPackage = with pkgs.vimPlugins; { | ||
# see examples below how to use custom packages | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
# see examples below how to use custom packages | |||
</div> | |||
start = [ ]; | start = [ ]; | ||
opt = [ ]; | opt = [ ]; | ||
Line 220: | Line 292: | ||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 238: | Line 309: | ||
</div> | </div> | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
vim_configurable.customize { | vim_configurable.customize { | ||
name = "vim-with-plugins"; | name = "vim-with-plugins"; | ||
# add custom .vimrc lines like this: | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
# add custom .vimrc lines like this: | |||
</div> | |||
vimrcConfig.customRC = '' | vimrcConfig.customRC = '' | ||
set hidden | set hidden | ||
Line 249: | Line 321: | ||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 259: | Line 330: | ||
</div> | </div> | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
vim_configurable.customize { | vim_configurable.customize { | ||
vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; { | vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; { | ||
# loaded on launch | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
# loaded on launch | |||
</div> | |||
start = [ YouCompleteMe fugitive ]; | start = [ YouCompleteMe fugitive ]; | ||
# manually loadable by calling `:packadd $plugin-name` | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
# manually loadable by calling `:packadd $plugin-name` | |||
</div> | |||
opt = [ phpCompletion elm-vim ]; | opt = [ phpCompletion elm-vim ]; | ||
# To automatically load a plugin when opening a filetype, add vimrc lines like: | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
# To automatically load a plugin when opening a filetype, add vimrc lines like: | |||
</div> | |||
# autocmd FileType php :packadd phpCompletion | # autocmd FileType php :packadd phpCompletion | ||
} | } | ||
}; | }; | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 283: | Line 358: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
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. | ||
</div> | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
vimrcConfig.pathogen.knownPlugins = vimPlugins; # optional | vimrcConfig.pathogen.knownPlugins = vimPlugins; # optional | ||
vimrcConfig.pathogen.pluginNames = [ "vim-addon-nix" "youcompleteme" ]; | vimrcConfig.pathogen.pluginNames = [ "vim-addon-nix" "youcompleteme" ]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 294: | Line 370: | ||
</div> | </div> | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
vimrcConfig.plug.plugins = with pkgs.vimPlugins; [vim-addon-nix youcompleteme]; | vimrcConfig.plug.plugins = with pkgs.vimPlugins; [vim-addon-nix youcompleteme]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 330: | Line 404: | ||
</div> | </div> | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
let | let | ||
Line 342: | Line 415: | ||
}; | }; | ||
}; | }; | ||
in { | in { | ||
users.users.<yourNickname>.packages = [ | users.users.<yourNickname>.packages = [ | ||
Line 355: | Line 425: | ||
}; | }; | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 361: | Line 430: | ||
</div> | </div> | ||
<code>configuration.nix</code>: | <code>configuration.nix</code>: | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
Line 385: | Line 453: | ||
}; | }; | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<code>flake.nix</code>: | <code>flake.nix</code>: | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
Line 398: | Line 464: | ||
}; | }; | ||
}; | }; | ||
outputs = inputs@{ nixpkgs, ... }: { | |||
outputs = inputs@{ nixpkgs, ... }: { | |||
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { | nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { | ||
system = "x86_64-linux"; | system = "x86_64-linux"; | ||
Line 414: | Line 478: | ||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 432: | Line 495: | ||
</div> | </div> | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
vim_configurable.customize { | vim_configurable.customize { | ||
Line 453: | Line 515: | ||
}; | }; | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
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: | ||
</div> | |||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
(python3.withPackages(ps: [ | (python3.withPackages(ps: [ | ||
ps.python-language-server | ps.python-language-server | ||
# the following plugins are optional, they provide type checking, import sorting and code formatting | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
# the following plugins are optional, they provide type checking, import sorting and code formatting | |||
</div> | |||
ps.pyls-mypy ps.pyls-isort ps.pyls-black | ps.pyls-mypy ps.pyls-isort ps.pyls-black | ||
])) | ])) | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 496: | Line 559: | ||
<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: | 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: | ||
</div> | |||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
(pkgs.callPackage ./my_vim.nix { | (pkgs.callPackage ./my_vim.nix { | ||
Line 502: | Line 566: | ||
}) | }) | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
Line 510: | Line 573: | ||
<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>). | <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> | <syntaxhighlight lang=bash> | ||
$ nix-env -iA nixos.vimHugeX | $ nix-env -iA nixos.vimHugeX | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <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>: | 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> | <syntaxhighlight lang=nix> | ||
vim_configured = pkgs.vim_configurable.customize { | vim_configured = pkgs.vim_configurable.customize { | ||
Line 522: | Line 588: | ||
wrapGui = true; | wrapGui = true; | ||
}; | }; | ||
</syntaxhighlight | </syntaxhighlight | ||
[[Category:Applications]] | [[Category:Applications]] | ||
[[Category:Text Editor{{#translation:}}]] | [[Category:Text Editor{{#translation:}}]] |