Skip to content

Instantly share code, notes, and snippets.

@delphinus
Created March 19, 2017 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save delphinus/56a0f8c830db4cf8eb646fcd0b7acebc to your computer and use it in GitHub Desktop.
Save delphinus/56a0f8c830db4cf8eb646fcd0b7acebc to your computer and use it in GitHub Desktop.
NeoBundle から dein.vim に乗り換えたら爆速だった話 ref: http://qiita.com/delphinus/items/00ff2c0ba972c6e41542
vim --startuptime /tmp/time.log +q
" vimrc に以下のように追記
" プラグインが実際にインストールされるディレクトリ
let s:dein_dir = expand('~/.cache/dein')
" dein.vim 本体
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
" dein.vim がなければ github から落としてくる
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 ファイル
" 予め TOML ファイル(後述)を用意しておく
let g:rc_dir = expand('~/.vim/rc')
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
" もし、未インストールものものがあったらインストール
if dein#check_install()
call dein#install()
endif
# dein.vim
/repos/github.com/author1/plugin1.vim
/repos/github.com/author2/plugin2.vim
...
" 「E117: 未知の関数です」と言われてしまう
call gista#client#register('GHE', 'https://github.example.com/api/v3')
" NeoBundle 用コード
let s:hooks = neobundle#get_hooks('vim-gista')
function s:hooks.on_source(bundle)
call gista#client#register('GHE', 'https://github.example.com/api/v3')
endfunction
" どこか最初の方に書いておく
augroup MyAutoCmd
autocmd!
augroup END
" プラグインごとに if 文を書く
if dein#tap('vim-gista')
" 実行すべき関数
function! s:gista_on_source() abort
call gista#client#register('GHE', 'https://github.example.com/api/v3')
endfunction
" g:dein#name にはプラグイン名が入る
execute 'autocmd MyAutoCmd User' 'dein#source#' . g:dein#name
\ 'call s:gista_on_source()'
endif
# 基本は github.com のレポジトリーを指定するだけ
[[plugins]]
repo = 'Shougo/dein.vim'
# git clone 後、実行すべきコマンドがある場合はこんな感じ
[[plugins]]
repo = 'Shougo/vimproc.vim'
hook_post_update = '''
if dein#util#_is_windows()
let cmd = 'tools\\update-dll-mingw'
elseif dein#util#_is_cygwin()
let cmd = 'make -f make_cygwin.mak'
elseif executable('gmake')
let cmd = 'gmake'
else
let cmd = 'make'
endif
let g:dein#plugin.build = cmd
'''
# ブランチやタグを指定したいとき
[[plugins]]
repo = 'delphinus35/typescript-vim'
rev = 'colorize-template-strings'
# 特定の条件で読み込みたいとき
[[plugins]]
repo = 'elzr/vim-json'
if = '''! has('kaoriya')'''
# 依存関係を指定したいとき
[[plugins]]
repo = 'vim-airline/vim-airline'
depends = ['vim-airline-themes']
# 依存関係を指定したからと言って、自動でインストールはされない(ここは NeoBundle と違う)
[[plugins]]
repo = 'vim-airline/vim-airline-themes'
# 特定のファイルタイプで読み込む
[[plugins]]
repo = 'Quramy/tsuquyomi'
on_ft = ['typescript']
# インサートモードに入ったら読み込む
[[plugins]]
repo = 'Shougo/neocomplete.vim'
on_i = 1
[[plugins]]
repo = 'Shougo/unite.vim'
# unite.vim を読み込んだら一緒に読み込む
[[plugins]]
repo = 'Shougo/neomru.vim'
on_source = ['unite.vim']
# 特定のコマンドを打ったら読み込む
[[plugins]]
repo = 'thinca/vim-prettyprint'
on_cmd = ['PP', 'PrettyPrint']
# 特定のマッピングを使ったら読み込む
# 又、gvim でしか利用しない
[[plugins]]
repo = 'thinca/vim-fontzoom'
on_cmd = ['Fontzoom']
on_map = ['<Plug>(fontzoom-']
gui = 1
# NeoBundle 用設定
[[plugins]]
repo = 'vim-airline/vim-airline'
depends = ['vim-airline/vim-airline-themes']
# dein 用設定
# depends の書式も微妙に違う
[[plugins]]
repo = 'vim-airline/vim-airline'
depends = ['/vim-airline-themes']
[[plugins]]
repo = 'vim-airline/vim-airline-themes'
[[plugins]]
repo = 'elzr/vim-json'
if = '''! has('kaoriya')'''
let l:path = neobundle#config#get('hoge').path
let l:path = dein#get('hoge').path
# NeoBundle
/plugin1.vim
/plugin2.vim
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment