LoginSignup
52
49

More than 5 years have passed since last update.

私が使う Vim プラグインまとめ

Last updated at Posted at 2018-07-28

はじめに

Neovim の設定を一年以上サボっていたので、久しぶりに整理しました。
入れているのに全く使っていなかったプラグインや、上手く活用できていなかったプラグインがあることに気づき、改めてプラグインの使い方をおさらいしてみました。

※ 前回書いた記事の続きとなっておりますので、そちらもご覧ください。
=> Neovim の設定を綺麗に整理してみた

やったこと

  • Vim プラグインの使用方法の調査
  • キーマッピング

環境

  • macOS Sierra: v10.12.6
  • Neovim: v0.3.0
  • Python2: v2.7.10
  • Python3: v3.7.0
  • Ruby: v2.4.4p296
  • Node.js: v10.6.0

プラグイン紹介

tpope/vim-endwise

do ブロック や def、 if 文などを作成するときに end を自動で入力してくれるプラグインです。

デモンストレーション

vim-endwise.gif

Townk/vim-autoclose

括弧の自動で補完してくれるプラグインです。
" を打つと "" に自動補完してくれますし、 ( を打つと () に自走補完してくれます。

デモンストレーション

vim-autoclose.gif

joshdick/onedark.vim

説明

Atom の One Dark というカラースキームにインスパイアされて作られた Vim / Neovim のカラースキームです。
目に優しい感じが好きで愛用しています。

w0rp/ale

説明

非同期で syntax チェックを行うプラグインです。
Neovim や Vim8 で非同期な操作が可能になったことで、このプラグインがよく使われるようになったそうです。

airblade/vim-gitgutter

説明

Gitで管理しているファイルを編集する際に、差分を表現する記号を左端に表示してくれるプラグインです。
~が変更があった行、+が追加行、-が削除された行であることを示しています。

それだけではなく、差分がある行にすぐに移動できたり、差分を元に戻すこともできます。

デモンストレーション

vim-gitgutter.gif

設定ファイル

~/.config/nvim/plugins/gitgutter.vim
set signcolumn=yes
set updatetime=1000

nnoremap [gitgutter] <Nop>
nmap <C-h> [gitgutter]
nmap [gitgutter]j <Plug>GitGutterNextHunk
nmap [gitgutter]k <Plug>GitGutterPrevHunk
nmap [gitgutter]u <Plug>GitGutterUndoHunk

tpope/vim-fugitive

説明

vim から git を呼べるようにするラッパープラグインです。
fugitive を使うと git を操作するためにいちいち vim から抜けなくてよくなります。

中でも私は Gblame を愛用しています。
Gblame で開いたウィンドウ内で O を打つと、コミットの内容まで表示してくれます。

デモンストレーション

git-fugitive.gif

設定ファイル

~/.config/nvim/plugins/fugitive.vim
command Gst :Gstatus
command Gdf :Gdiff
command Gbl :Gblame

Shougo/denite.nvim

説明

vim 用の統合ユーザインターフェースを実現してくれるプラグインです。
様々なデータを同じインタフェースで操作することができるようになります。

例えば、ファイルをファイル名で絞り込んで検索できたり、文字を grep して検索することもできます。また検索したファイルを同じインターフェースで開いたりすることもできます。

デモンストレーション

denite.gif

設定ファイル

~/.config/nvim/plugins/denite.vim
nnoremap [denite] <Nop>
nmap <C-d> [denite]
nnoremap <silent> [denite]g :<C-u>Denite grep -buffer-name=search-buffer-denite<CR>
nnoremap <silent> [denite]r :<C-u>Denite -resume -buffer-name=search-buffer-denite<CR>
nnoremap <silent> [denite]p :<C-u>Denite file_rec<CR>

call denite#custom#option('default', 'prompt', '>')
call denite#custom#option('_', 'highlight_matched_range', 'None')
call denite#custom#option('_', 'highlight_matched_char', 'None')

call denite#custom#map('insert', "<Tab>", '<denite:move_to_next_line>')
call denite#custom#map('insert', "<S-Tab>", '<denite:move_to_previous_line>')
call denite#custom#map('insert', "<C-t>", '<denite:do_action:tabopen>')
call denite#custom#map('insert', "<C-v>", '<denite:do_action:vsplit>')
call denite#custom#map('normal', "v", '<denite:do_action:vsplit>')

call denite#custom#var('grep', 'command', ['pt', '--follow', '--nogroup', '--nocolor', '--hidden'])
call denite#custom#var('grep', 'default_opts', [])
call denite#custom#var('grep', 'recursive_opts', [])
call denite#custom#var('file_rec', 'command', ['pt', '--follow', '--nocolor', '--nogroup', '--hidden', '-g', ''])

補足

私は高速 grep ツールとして the_platinum_searcher を採用しています。
理由は the_silver_searcherhighway よりも速いという記事をよく見かけるからです。

osyo-manga/vim-anzu

説明

検索時にマッチした個数とそれが何番目であるかの情報を表示してくれるプラグインです。
今までマッチした個数や何番目であるかが分からず、 n を押しっぱなしで迷子になっていたので、非常に助かってます。

デモンストレーション

anzu.gif

設定ファイル

~/.config/nvim/plugins/anzu.vim
nmap n <Plug>(anzu-n-with-echo)
nmap N <Plug>(anzu-N-with-echo)
nmap * <Plug>(anzu-star)
nmap # <Plug>(anzu-sharp)

Shougo/deoplete.nvim

説明

deoplete は拡張可能で非同期の補完フレームワークを提供してくれる Vim プラグインです。
別途補完ソース用のプラグインを追加することで、補完機能を強化することもできます。

デモンストレーション

deoplete.gif

設定ファイル

~/.config/nvim/plugins/deoplete.vim
let g:deoplete#enable_at_startup = 1
inoremap <expr><Tab> pumvisible() ? "\<DOWN>" : "\<Tab>"
inoremap <expr><S-Tab> pumvisible() ? "\<UP>" : "\<S-Tab>"
52
49
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
52
49