Neovim 入門3 plugin
neovimでもvimと同じようにpluginが使える。
vimで使用していたdein.vimはNeovimもサポートしているので、これをそのまま使う。
https://github.com/Shougo/dein.vim
deinのインストール
dein.vimのインストールは公式サイトを参考にinit.vimに追加
なお、pluginはTOMLファイルに記述していく。
let s:dein_cache_path = expand('~/.cache/nvim/dein') let g:home = expand('~') let g:nvim_home = g:home .'/.config/nvim' let s:dein_dir = expand(g:home . '/.cache/dein') let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim' if &runtimepath !~# '/dein.vim' if !isdirectory(s:dein_repo_dir) execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_dir endif execute 'set runtimepath^=' . fnamemodify(s:dein_repo_dir, ':p') endif let g:rc_dir = g:nvim_home . '/rc' let g:dein#install_max_processes = 16 let g:dein#install_progress_type = 'title' let g:dein#enable_notification = 1 let s:toml = g:rc_dir . '/dein.toml' let s:lazy_toml = g:rc_dir . '/dein_lazy.toml' if dein#load_state(s:dein_dir) call dein#begin(s:dein_dir, [s:toml, s:lazy_toml]) call dein#load_toml(s:toml, {'lazy' : 0}) call dein#load_toml(s:lazy_toml, {'lazy' : 1}) call dein#end() call dein#save_state() endif if dein#check_install() call dein#install() endif #plugin毎の設定ロード for plugin in glob(g:rc_dir . '/plugins/*', 1, 1) execute "source " . plugin endfor filetype plugin indent on #plugin毎に設定ファイルを分け、それを読み込む for plugin in glob(g:rc_dir . '/plugins/*', 1, 1) execute "source " . plugin endfor
neoterm
せっかくなのでNeovimぽいpluginを入れてみる。
Neovimではvimの中のshellを実行できるので(TERMINALモード)、それを便利にするpluginを入れる。
今回入れるのはneotermというplugin。
https://github.com/kassio/neoterm
dein.tomlに下記を追加
[[plugins]] repo = 'kassio/neoterm'
これでnvimを起動したタイミングでdein.vimがpluginをダウンロードして来てくれる。
neotermの設定を記述(公式サイトのexampleから必要そうなのだけをもってきただけ)
let g:neoterm_position = 'horizontal' " Useful maps " hide/close terminal nnoremap <silent> ,th :call neoterm#close()<cr> " clear terminal nnoremap <silent> ,tl :call neoterm#clear()<cr> " kills the current job (send a <c-c>) nnoremap <silent> ,tc :call neoterm#kill()<cr> " Git commands command! -nargs=+ Tg :T git <args>
まとめ
とりあえずこれで、初期設定とpluginのインストールはできたので、あとは必要なpluginや設定を適宜追加していくだけまではできた。
フォルダ構成としては現状は以下になっている。
nvim ├── init.vim └── rc ├── color.vim ├── dein.toml ├── dein_lazy.toml ├── filetypes.vim ├── mapping.vim ├── plugins │ └── neoterm.vim └── settings.vim