PrsPrsBK’s blog

Princess Princess Burn Knuckle

Neobundle から dein.vim に移行したときの話

お話

Firefox アドオン開発を web-ext に移行する話の初歩その続きを書いたら Vim の話を思い出した。移行したの二か月くらい前だし今更書いても役に立たない気がしたがどうでもよくなった。書いておく。

github のプロジェクトのページを見た。

(各プラグインの)インストールフォルダを決める。例:"~/.vim/bundles" or "~/.cache/dein" or "~/.local/share/dein"。 回避する例: "~/.vim/plugin"、"~/.config/nvim/plugin" の下。結果、"~/.vim/bundles" にした。NeoBundle のフォルダ "~/.vim/bundle"(sがない) とは別になる。

Readme.md には "If you are using Unix/Linux or Mac OS X."、https://github.com/Shougo/dein.vim/blob/master/bin/installer.sh を取得して sh ./installer.sh {specify the installation directory} する、とある。

Windows については記述がなかった。Git/bin/sh.exe でやっても良いかもしれないけど installer.sh を見たら何するか分かったので手作業でやった。インストールフォルダを作って、その下の repos/github.com/Shougo/dein.vim フォルダに git clone https://github.com/Shougo/dein.vim すればいい。インストールフォルダと git clone 以外は「vimrc にこういう設定書いてね」という案内なので見て、あとで _vimrc にコピペして編集することにした。

1. NeoBundle の除去: 設定消すだけ

プラグインフォルダは dein とは別なのでそのままにしておき移行後エクスプローラから消すことにした。先に消すなら _vimrc から NeoBundle 'foo/bar-vim' 等を削除して NeoBundleClean すれば消える。

2.dein 設定を _vimrc に書く

NeoBundle 設定時点。元々あまりプラグインを使っていないがたまに増減するので、管理が楽になって助かっている。

if has('vim_starting')
    set runtimepath+=~/bin-local/vimfiles/bundle/neobundle.vim/
endif

call neobundle#rc(expand('~/bin-local/vimfiles/bundle/'))

NeoBundleFetch 'Shougo/neobundle.vim'

NeoBundle 'kana/vim-surround'
NeoBundle 'koron/codic-vim'
NeoBundle 'tomasr/molokai'
NeoBundle 'Yggdroot/indentLine'

NeoBundleCheck

if neobundle#is_installed('molokai')
    colorscheme molokai
    autocmd GUIEnter * colorscheme molokai
endif
(その他の設定)

NeoBundle 設定を消してこのようにした。if neobundle#is_installed('molokai') はどう変えるかすぐ分からず、インストール後 dein のヘルプ見てから tap() で良かろうとなり、後で足した。ググると情報があり、vimrc は各人の考え方や事情などがあるようで沢山見ると迷ってしまう (特に分かるようにならない) ので、分かる範囲のことをやりたい。単純に上記の installer.sh とヘルプに従った。喫緊の課題ではないのであとで改善すれば良い。

" Required:
if has('vim_starting')
    set runtimepath+=~/bin-local/vimfiles/bundles/repos/github.com/Shougo/dein.vim/
endif
" Required:
if dein#load_state('~/bin-local/vimfiles/bundles/')
    call dein#begin('~/bin-local/vimfiles/bundles/')
" Let dein manage dein
" Required:
    call dein#add('~/bin-local/vimfiles/bundles/repos/github.com/Shougo/dein.vim/')
" Add or remove your plugins here:
    call dein#add('kana/vim-surround')
    call dein#add('koron/codic-vim')
    call dein#add('tomasr/molokai')
    call dein#add('Yggdroot/indentLine')
" You can specify revision/branch/tag.
"  call dein#add('Shougo/vimshell', { 'rev': '3787e5' })
" Required:
    call dein#end()
    call dein#save_state()
endif
" 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

if dein#tap('molokai')
    colorscheme molokai
    autocmd GUIEnter * colorscheme molokai
endif
(その他の設定)

TOML はとりあえず使わない。

_gvimrc は set guifont などしか書かれておらず関係ないのでそのまま。

Vim を開いて:call dein#install() せよとあるが vimrc に書いたので Vim 再起動で済ませる。ダイアログウィンドウが表示されてメッセージが出た。OK 押したら起動した。後は問題なし。

3. 一応 source $MYVIMRC してみる

この時点でおかしくなるかどうか調べただけ。dein#check_update はあとでいいか、で終わり。

あと、はてなブログ

code タグの CSS が全然反映されないのが分からないけどまあいいか。