無限グミ

メモとか備忘録とか日記

【vim】 deinでプラグインを管理

dein

これまでNeoBundleを使っていたがdeinの方が早いらしいのでdeinでプラグインの管理をしてみる。

インストーラーでdeinを導入

% curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh
% sh ./installer.sh ~/.vim/dein

.vimrc に設定

" ------------------ dein setting -------------------------
if &compatible
    set nocompatible
endif
set runtimepath^=$HOME/.vim/dein/repos/github.com/Shougo/dein.vim


" neobundle の設定
call dein#begin(expand('$HOME/.vim/dein'))
call dein#add('Shougo/dein.vim')

" ==================== plugins ===============================
call dein#add('Shougo/unite.vim') " ファイル操作とか
call dein#add('Shougo/neocomplete.vim') " 補完
call dein#add('Shougo/neosnippet.vim') " スニペット
call dein#add('Shougo/neosnippet-snippets') " スニペット
call dein#add('itchyny/lightline.vim') " 情報を見やすく
call dein#add('nathanaelkane/vim-indent-guides') " インデントを色分け
call dein#add('Townk/vim-autoclose') " カッコを自動で閉じる
call dein#add('honza/vim-snippets') " スニペット
call dein#add('ujihisa/neco-look') " 英単語の補完
" ============================================================
call dein#end()
filetype plugin indent on

" 未インストールのプラグインをインストール
if dein#check_install()
    call dein#install()
endif

これで次回起動時に未インストールのプラグインを導入してくれる。 それぞれのプラグインには設定が必要なものもあるので注意。

Neocompleteとuniteはよく使うので必須。
lightlineは今のモードや開いているファイル名を表示してくれるのでとても便利。
vim-indent-guidesはインデントが色分けされるので管理がしやすい。
pythonとかだととってもわかりやすい。
neo-lookは報告書とかREADMEに英語で書くときに保管してくれるのでめちゃくちゃ助かる。

今のところの.vimrc

" syntax
syntax enable
colorscheme jellybeans
" lightline
set laststatus=2
let g:lightline = {
    \ 'colorscheme' : 'wombat'
    \ }
" indent colors
let g:indent_guides_enable_on_vim_startup=1
" indent setting
set autoindent
set expandtab
set shiftwidth=4
set tabstop=4

" disp setting
set number
set ruler
set list
set listchars=tab:>-,trail:-,nbsp:%,extends:>,precedes:<,eol:<
set scrolloff=5

" cursor setting
set whichwrap=b,s,<,>,[,]
set backspace=indent,eol,start

" encoding
set encoding=utf8
set fileencoding=utf8

" hilight setting
set matchtime=3

" set binary mode
augroup BinnaryXXD
  autocmd!
  autocmd BufReadPre  *.bin let &binary =1
  autocmd BufReadPost * if &binary | silent %!xxd -g 1
  autocmd BufReadPost * set ft=xxd | endif
  autocmd BufWritePre * if &binary | %!xxd -r | endif
  autocmd BufWritePost * if &binary | silent %!xxd -g 1
  autocmd BufWritePost * set nomod | endif
augroup END

" .mdファイルをmarkdownとして認識してもらう
autocmd BufNewFile,BufRead *.{md,mdwn,mkd,mark*} set filetype=markdown
" -------------------------------------------------------------
" -------------- dein setting ----------------------------
if &compatible
    set nocompatible
endif
set runtimepath^=$HOME/.vim/dein/repos/github.com/Shougo/dein.vim


" neobundle の設定
call dein#begin(expand('$HOME/.vim/dein'))
call dein#add('Shougo/dein.vim')

" ==================== plugins ===============================
call dein#add('Shougo/unite.vim')
call dein#add('Shougo/neomru.vim')
call dein#add('Shougo/neocomplete.vim')
call dein#add('Shougo/neosnippet.vim')
call dein#add('Shougo/neosnippet-snippets')
" NeoBundle 'Shougo/vimproc')
call dein#add('itchyny/lightline.vim')
call dein#add('nathanaelkane/vim-indent-guides')
call dein#add('Townk/vim-autoclose')
call dein#add('honza/vim-snippets')
call dein#add('ujihisa/neco-look')
" ============================================================
call dein#end()
filetype plugin indent on

" 未インストールのプラグインをインストール
if dein#check_install()
    call dein#install()
endif

" ------------------------------------------------------------
" ### neocomplete
    let g:acp_enableAtStartup=0
    let g:neocomplete#enable_at_startup=1
    let g:neocomplete#enable_smart_case=1
    let g:neocomplete#sources#syntax#min_keyword_lenth=2
    let gLneocomplete#lock_buffer_name_pattern='\*ku\*'
    if !exists('g:neocomplete#keyword_patterns')
       let g:neocomplete#keyword_patterns={}
    endif
    let g:neocomplete#keyword_patterns['default']='\h\w*'
    inoremap <expr><C-g> neocomplete#undo_completion()
    inoremap <expr><C-l> neocomplete#complete_common_string()
    inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"

" ### neco-look
    if !exists('g:neocomplete#text_mode_filetypes')
        let g:neocomplete#text_mode_filetypes={}
    endif
    let g:neocomplete#text_mode_filetypes={
        \ 'rst' : 1,
        \ 'markdown' : 1,
        \ 'gitrebase' : 1,
        \ 'gitcommit' : 1,
        \ 'vcs-commit' : 1,
        \ 'hybrid' : 1,
        \ 'text' : 1,
        \ 'help' : 1,
        \ 'tex' : 1,
        \ }

filetype plugin indent on