Vim: Difference between revisions
Improve translation support |
Replace dead link. |
||
| (12 intermediate revisions by 6 users not shown) | |||
| Line 7: | Line 7: | ||
=== Basic Install === <!--T:3--> | === Basic Install === <!--T:3--> | ||
</translate> | </translate> | ||
<syntaxhighlight lang="nix> | <syntaxhighlight lang="nix> | ||
| Line 16: | Line 13: | ||
<translate> | <translate> | ||
<!--T:74--> | |||
or | or | ||
</translate> | </translate> | ||
<syntaxhighlight lang="nix> | <syntaxhighlight lang="nix"> | ||
programs.vim = { | programs.vim = { | ||
enable = true; | enable = true; | ||
package = pkgs. | package = pkgs.vim-full; | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<translate> | <translate> | ||
| Line 39: | Line 29: | ||
</translate> | </translate> | ||
<syntaxhighlight lang="nix> | <syntaxhighlight lang="nix"> | ||
environment.systemPackages = with pkgs; [ | environment.systemPackages = with pkgs; [ vim-full ]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<translate> | <translate> | ||
| Line 68: | Line 58: | ||
<!--T:11--> | <!--T:11--> | ||
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: | ||
</translate> | </translate> | ||
| Line 113: | Line 103: | ||
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:. | ||
<!--T:76--> | |||
On unstable: | On unstable: | ||
</translate> | </translate> | ||
< | <syntaxhighlight lang="nix"> | ||
{ pkgs, ... }: | { pkgs, ... }: | ||
{ | { | ||
| Line 122: | Line 113: | ||
enable = true; | enable = true; | ||
defaultEditor = true; | defaultEditor = true; | ||
package = (pkgs. | package = (pkgs.vim-full.override { }).customize{ | ||
name = "vim"; | name = "vim"; | ||
<translate> | <translate> | ||
# Install plugins for example for syntax highlighting of nix files | <!--T:77--> | ||
# Install plugins for example for syntax highlighting of nix files | |||
</translate> | </translate> | ||
vimrcConfig.packages.myplugins = with pkgs.vimPlugins; { | vimrcConfig.packages.myplugins = with pkgs.vimPlugins; { | ||
| Line 133: | Line 125: | ||
vimrcConfig.customRC = '' | vimrcConfig.customRC = '' | ||
<translate> | <translate> | ||
" your custom vimrc | <!--T:78--> | ||
" your custom vimrc | |||
</translate> | </translate> | ||
set nocompatible | set nocompatible | ||
set backspace=indent,eol,start | set backspace=indent,eol,start | ||
<translate> | <translate> | ||
" Turn on syntax highlighting by default | <!--T:79--> | ||
" Turn on syntax highlighting by default | |||
</translate> | </translate> | ||
syntax on | syntax on | ||
| Line 146: | Line 140: | ||
}; | }; | ||
} | } | ||
</ | </syntaxhighlight> | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
{ pkgs, ... }: | { pkgs, ... }: | ||
| Line 193: | Line 151: | ||
customRC = '' | customRC = '' | ||
<translate> | <translate> | ||
" your custom vimrc | <!--T:84--> | ||
" your custom vimrc | |||
</translate> | </translate> | ||
set nocompatible | set nocompatible | ||
| Line 232: | Line 191: | ||
<!--T:27--> | <!--T:27--> | ||
A lot of documentation about package management and configuration of vim in nix is stored at [https://github.com/NixOS/nixpkgs/blob/master/ | 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. | ||
=== Customizations === <!--T:28--> | === Customizations === <!--T:28--> | ||
| Line 243: | Line 202: | ||
</translate> | </translate> | ||
< | <syntaxhighlight lang="nix"> | ||
{ | { | ||
packageOverrides = pkgs: with pkgs; { | packageOverrides = pkgs: with pkgs; { | ||
myVim = | myVim = vim-full.customize { | ||
name = "vim-with-plugins"; | name = "vim-with-plugins"; | ||
<translate> | <translate> | ||
# add here code from the example section | <!--T:85--> | ||
# add here code from the example section | |||
</translate> | </translate> | ||
}; | }; | ||
| Line 256: | Line 216: | ||
customRC = '' | customRC = '' | ||
<translate> | <translate> | ||
# here your custom configuration goes! | <!--T:86--> | ||
# here your custom configuration goes! | |||
</translate> | </translate> | ||
''; | ''; | ||
packages.myVimPackage = with pkgs.vimPlugins; { | packages.myVimPackage = with pkgs.vimPlugins; { | ||
<translate> | <translate> | ||
# see examples below how to use custom packages | <!--T:87--> | ||
# see examples below how to use custom packages | |||
</translate> | </translate> | ||
start = [ ]; | start = [ ]; | ||
| Line 270: | Line 232: | ||
}; | }; | ||
} | } | ||
</ | </syntaxhighlight> | ||
<translate> | <translate> | ||
| Line 284: | Line 246: | ||
</translate> | </translate> | ||
< | <syntaxhighlight lang="nix"> | ||
vim-full.customize { | |||
name = "vim-with-plugins"; | name = "vim-with-plugins"; | ||
<translate> | <translate> | ||
# add custom .vimrc lines like this: | <!--T:88--> | ||
# add custom .vimrc lines like this: | |||
</translate> | </translate> | ||
vimrcConfig.customRC = '' | vimrcConfig.customRC = '' | ||
| Line 295: | Line 258: | ||
''; | ''; | ||
} | } | ||
</ | </syntaxhighlight> | ||
<translate> | <translate> | ||
| Line 304: | Line 267: | ||
</translate> | </translate> | ||
< | <syntaxhighlight lang="nix"> | ||
vim-full.customize { | |||
vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; { | vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; { | ||
<translate> | <translate> | ||
# loaded on launch | <!--T:89--> | ||
# loaded on launch | |||
</translate> | </translate> | ||
start = [ YouCompleteMe fugitive ]; | start = [ YouCompleteMe fugitive ]; | ||
<translate> | <translate> | ||
# manually loadable by calling `:packadd $plugin-name` | <!--T:90--> | ||
# manually loadable by calling `:packadd $plugin-name` | |||
</translate> | </translate> | ||
opt = [ phpCompletion elm-vim ]; | opt = [ phpCompletion elm-vim ]; | ||
<translate> | <translate> | ||
# To automatically load a plugin when opening a filetype, add vimrc lines like: | <!--T:91--> | ||
# To automatically load a plugin when opening a filetype, add vimrc lines like: | |||
</translate> | </translate> | ||
# autocmd FileType php :packadd phpCompletion | # autocmd FileType php :packadd phpCompletion | ||
} | } | ||
}; | }; | ||
</ | </syntaxhighlight> | ||
<translate> | <translate> | ||
| Line 350: | Line 316: | ||
<!--T:46--> | <!--T:46--> | ||
Please see https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/vim.section.md. | |||
==== Notes Regarding Plugins ==== <!--T:47--> | ==== Notes Regarding Plugins ==== <!--T:47--> | ||
| Line 369: | Line 329: | ||
</translate> | </translate> | ||
< | <syntaxhighlight lang="nix"> | ||
let | let | ||
vim-better-whitespace = pkgs.vimUtils.buildVimPlugin { | vim-better-whitespace = pkgs.vimUtils.buildVimPlugin { | ||
| Line 382: | Line 342: | ||
in { | in { | ||
users.users.<yourNickname>.packages = [ | users.users.<yourNickname>.packages = [ | ||
(pkgs. | (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 389: | Line 349: | ||
]; | ]; | ||
}; | }; | ||
</ | </syntaxhighlight> | ||
<translate> | <translate> | ||
| Line 451: | Line 411: | ||
<!--T:59--> | <!--T:59--> | ||
The following snippet will make a full featured python IDE. | The following snippet will make a full featured [[python]] IDE. | ||
==== Using language client ==== <!--T:60--> | ==== Using language client ==== <!--T:60--> | ||
</translate> | </translate> | ||
< | <syntaxhighlight lang="nix"> | ||
vim-full.customize { | |||
vimrcConfig = { | vimrcConfig = { | ||
customRC = '' | customRC = '' | ||
| Line 475: | Line 435: | ||
} | } | ||
}; | }; | ||
</ | </syntaxhighlight> | ||
<translate> | <translate> | ||
| Line 487: | Line 447: | ||
ps.python-language-server | ps.python-language-server | ||
<translate> | <translate> | ||
# the following plugins are optional, they provide type checking, import sorting and code formatting | <!--T:92--> | ||
# the following plugins are optional, they provide type checking, import sorting and code formatting | |||
</translate> | </translate> | ||
ps.pyls-mypy ps.pyls-isort ps.pyls-black | ps.pyls-mypy ps.pyls-isort ps.pyls-black | ||
| Line 498: | Line 459: | ||
<!--T:64--> | <!--T:64--> | ||
* [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] | ||
<!--T:99--> | |||
* [https://github.com/andrewrk/dotfiles/blob/master/.nixpkgs/config.nix andrewrk's config] | * [https://github.com/andrewrk/dotfiles/blob/master/.nixpkgs/config.nix andrewrk's config] | ||
<!--T:100--> | |||
* [https://github.com/wagnerf42/nixos-config/blob/master/config/my_vim.nix wagnerf42's config (good for rust language)] | * [https://github.com/wagnerf42/nixos-config/blob/master/config/my_vim.nix wagnerf42's config (good for rust language)] | ||
| Line 508: | Line 473: | ||
<!--T:67--> | <!--T:67--> | ||
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] | 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] | ||
== gvim and gview == <!--T:70--> | == gvim and gview == <!--T:70--> | ||
<!--T:71--> | <!--T:71--> | ||
<code> | You can enable <code>guiSupport</code> to make <code>gvim</code> available, though this won't give you <code>gview</code>: | ||
</translate> | </translate> | ||
<syntaxhighlight lang= | <syntaxhighlight lang="nix"> | ||
(pkgs.vim-full.customize { | |||
guiSupport = true; | |||
}) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
<translate> | <translate> | ||
</translate> | </translate> | ||
[[Category:Applications]] | [[Category:Applications]] | ||
[[Category:CLI Applications]] | |||
[[Category:Text Editor{{#translation:}}]] | [[Category:Text Editor{{#translation:}}]] | ||