dein.toml
をdein_lazy.toml
に分けた
dein.toml
とは
dein.vim
で導入するプラグインをtoml形式でまとめたもの
導入するプラグインをまとめているだけなら1つのファイルでいいじゃないかとも思うが、vimの起動時にtomlの読み込みを行うため、記述量が増えると起動が遅くなる。
そこで、起動時に必ずしも必要ではないプラグインを遅延読み込みさせることで起動をできるだけ早くしようというのがdein_lazy.toml
である。(vimrc
で読み込みを行うときにファイル名指定をしているので必ずしもdein.toml
かdein_lazy.toml
というファイル名である必要はないみたい)
実際に分けてみる
分ける前のdein.toml
は以下のようになっていた
dein.toml(before)
[[plugins]]hook_add='''
augroup colorcshemeSetting
autocmd!
autocmd VimEnter * ++nested colorscheme night-owl
autocmd Colorscheme * highlight Normal ctermbg=none
autocmd Colorscheme * highlight NonText ctermbg=none
autocmd Colorscheme * highlight LineNr ctermbg=none
autocmd Colorscheme * highlight Folded ctermbg=none
autocmd Colorscheme * highlight EndOfBuffer ctermbg=none
augroup END
'''repo='haishanh/night-owl.vim'[[plugins]]repo='vim-jp/vimdoc-ja'[[plugins]]repo='cocopon/vaffle.vim'[[plugins]]repo='prabirshrestha/vim-lsp'[[plugins]]repo='mattn/vim-lsp-settings'[[plugins]]repo='mattn/vim-lsp-icons'[[plugins]]repo='prabirshrestha/asyncomplete.vim'[[plugins]]repo='prabirshrestha/asyncomplete-lsp.vim'[[plugins]]repo="markonm/traces.vim"[[plugins]]repo='cespare/vim-toml'[[plugins]]hook_add='''
let g:rufo_auto_formatting = 1
'''repo="ruby-formatter/rufo-vim"[[plugins]]repo="tpope/vim-endwise"[[plugins]]repo="mindriot101/vim-yapf"[[plugins]]hook_add='''
let g:shfmt_extra_args = '-i 4 -ci -bn -s'
let g:shfmt_fmt_on_save = 1
'''repo="z0mbix/vim-shfmt"
これのうち言語設定関連のものをdein_lazy.toml
に分離させた
dein_lazy.toml
[[plugins]]on_ft='toml'repo='cespare/vim-toml'[[plugins]]hook_add='''
let g:rufo_auto_formatting = 1
'''on_ft="ruby"repo="ruby-formatter/rufo-vim"[[plugins]]repo="tpope/vim-endwise"on_ft="ruby"[[plugins]]on_ft="python"repo="mindriot101/vim-yapf"[[plugins]]hook_add='''
let g:shfmt_extra_args = '-i 4 -ci -bn -s'
let g:shfmt_fmt_on_save = 1
'''on_ft=["sh","bash"]repo="z0mbix/vim-shfmt"
(tomlの各キーの順番はフォーマッタでソートされているようでrepo
が後ろに来ている)
おそらく言語設定だけではなく他のプラグインも移せるものがあるだろうが、今回はこの程度にしておく。
起動時間はそもそもそんなにプラグインを入れていたわけではないので大した変化はなかった。しかし、チリツモで今後重くなることを防いだと考えれば無意味ではないと思う。