vimをずっと使ってみたいなーと思いつつもなかなかやる気が出なくて、環境構築を諦めてたけど、@yui540さんが解説動画的なのでサクサクvim使ってるのみてこの機会に使って見ることにした。
Neovimを入れる
brewを使って入れる。
brew install neovim
Dein.vimを入れる
ここで結構詰まった。
まず、neovimの設定ファイルをいじる。
場所は、~/.config/nvim/init.vim
多分ディレクトリ自体無いと思うので先に作る
mkdir ~/.config/nvim/init.vim
nvim ~/.config/nvim/init.vim
vimの画面になったら、iキーを押して挿入モードに切り替えて、
" reset augroup
augroup MyAutoCmd
autocmd!
augroup END
" ENV
let $CACHE = empty($XDG_CACHE_HOME) ? expand('$HOME/.cache') : $XDG_CACHE_HOME
let $CONFIG = empty($XDG_CONFIG_HOME) ? expand('$HOME/.config') : $XDG_CONFIG_HOME
let $DATA = empty($XDG_DATA_HOME) ? expand('$HOME/.local/share') : $XDG_DATA_HOME
" Load rc file
function! s:load(file) abort
let s:path = expand('$CONFIG/nvim/rc/' . a:file . '.vim')
if filereadable(s:path)
execute 'source' fnameescape(s:path)
endif
endfunction
call s:load('plugins')
これを貼り付ける
次に、plugin関連の設定ようファイルを作成
mkdir ~/.config/nvim/rc
nvim ~/.config/nvim/rc/plugins.vim
内容はこんな感じ
let s:dein_dir = expand('$DATA/dein')
if &runtimepath !~# '/dein.vim'
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
" Auto Download
if !isdirectory(s:dein_repo_dir)
execute '!git clone https://github.com/Shougo/dein.vim ' . s:dein_repo_dir
endif
execute 'set runtimepath^=' . s:dein_repo_dir
endif
let g:dein#install_max_processes = 16
let g:dein#install_message_type = 'none'
if !dein#load_state(s:dein_dir)
finish
endif
call dein#begin(s:dein_dir, expand('<sfile>'))
let s:toml_dir = expand('$CONFIG/nvim/dein')
call dein#load_toml(s:toml_dir . '/plugins.toml', {'lazy': 0})
call dein#load_toml(s:toml_dir . '/plugins_lazy.toml', {'lazy': 1})
if has('python3')
call dein#load_toml(s:toml_dir . '/python.toml', {'lazy': 1})
endif
call dein#end()
call dein#save_state()
if has('vim_starting') && dein#check_install()
call dein#install()
endif
最後にtomlファイルを作って入れるプラグインをかく。
mkdir ~/.config/nvim/dein
cd dein
touch plugins.toml
touch plugins_lazy.toml
touch python.toml
三つのファイルを作ったら、plugins.tomlに
[[plugins]]
repo = 'Shougo/dein.vim'
と書いて終わり。
あとはnvimでvimを起動すればプラグインとかが勝手にインストールされる