Quantcast
Channel: Vimタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 5699

dein.tomlをdein_lazy.tomlに分ける

$
0
0

dein.tomldein_lazy.tomlに分けた

dein.tomlとは

dein.vimで導入するプラグインをtoml形式でまとめたもの

導入するプラグインをまとめているだけなら1つのファイルでいいじゃないかとも思うが、vimの起動時にtomlの読み込みを行うため、記述量が増えると起動が遅くなる。
そこで、起動時に必ずしも必要ではないプラグインを遅延読み込みさせることで起動をできるだけ早くしようというのがdein_lazy.tomlである。(vimrcで読み込みを行うときにファイル名指定をしているので必ずしもdein.tomldein_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が後ろに来ている)

おそらく言語設定だけではなく他のプラグインも移せるものがあるだろうが、今回はこの程度にしておく。

起動時間はそもそもそんなにプラグインを入れていたわけではないので大した変化はなかった。しかし、チリツモで今後重くなることを防いだと考えれば無意味ではないと思う。


Viewing all articles
Browse latest Browse all 5699

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>