
こんにちわlisです!
Vimのプラグイン管理を行うために、dein.vimを導入しました!
今回はdein.vimのインストールと初期設定です!
dein.vimのインストール
公式のQuick startを参考にインストールしました。
今回は~/.cache/deinにdeinをインストールすることにしました。
$ mkdir ~/.vim/plugins $ cd ~/.vim/plugins $ curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh $ sh ./installer.sh ~/.cache/dein
tomlファイルを準備する
tomlというファイルフォーマットがあるんですね。
dein.vimではプラグイン情報をtomlファイルに記述することで、vim設定ファイルから外部化できます。
設定ファイルを編集する前に、空でいいのでtomlファイルを作成しておきます。
$HOME/.vim/にdein.tomlとdein_lazy.tomlを作成しておきます。
$ touch ~/.vim/dein.toml $ touch ~/.vim/dein_lazy.toml
dein.vimの設定を書く
インストール時($ sh ./installer.sh ~/.cache/dein)に出力される
"dein Scripts-----------------------------
if &compatible
set nocompatible " Be iMproved
endif
" Required:
set runtimepath+=/home/sy/.cache/dein/repos/github.com/Shougo/dein.vim
" Required:
call dein#begin('/home/sy/.cache/dein')
" Let dein manage dein
" Required:
call dein#add('/home/sy/.cache/dein/repos/github.com/Shougo/dein.vim')
" Add or remove your plugins here like this:
"call dein#add('Shougo/neosnippet.vim')
"call dein#add('Shougo/neosnippet-snippets')
" Required:
call dein#end()
" Required:
filetype plugin indent on
syntax enable
" If you want to install not installed plugins on startup.
"if dein#check_install()
" call dein#install()
"endif
"End dein Scripts-------------------------
を.vimrcやinit.vimにコピペして、編集することで設定が完了するようです。
しかし随所に同じパスへのフルパスが書かれていたりするので冗長的です。
ということでこちらの設定を参考に、設定ファイルへの記述を行いました。
.vimrcに書く
~/.vimrcや~/.config/nvim/init.vimの1番下にこれを追記。
let s:dein_dir = expand('$HOME/.cache/dein')
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
"if &compatible
" set nocompatible " Be iMproved
"endif
" dein.vimがない場合githubからDL
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
" 設定開始
if dein#load_state(s:dein_dir)
call dein#begin(s:dein_dir)
" プラグインリスト(toml)
let g:rc_dir = expand('$HOME/.vim')
let s:toml = g:rc_dir . '/dein.toml'
let s:lazy_toml = g:rc_dir . '/dein_lazy.toml'
" 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
" Required:
filetype plugin indent on
syntax enable
" 未インストールがあればインストール
if dein#check_install()
call dein#install()
endif
letで変数にセットしたパスを使いまわしたりしているためスマートです。
オリジナルから編集しながら書きましたが、よくわからんが不要そうなものはコメントアウトでとりあえず削除しています。
ちなみにぼくはneovimを入れてみたものの、完全移行するかあやふやなので、.vimrcとinit.vimの両方に書きました。
参考
コチラを参考にしました。ありがとうございました!
あとがき
dein.vimのインストール・初期設定手順でした!
Vim歴短いですが、色々カスタマイズできる凄いヤツだったんですね!
便利になるようにもっとカスタマイズしていきたいです!