LoginSignup
9
11

More than 5 years have passed since last update.

dein.vimでプラグイン管理

Last updated at Posted at 2018-02-27

はじめに

  • dein.vimというvimのプラグイン管理ツールの導入方法をまとめる
  • もともとUbuntuで使ってて違う環境で使うときに迷ったから備忘録
  • dein.tomlを利用した管理方法を書く

動作環境

  • vim7.4
  • ubuntu 16.04 LTS
  • (macでもできたけど細かい環境は覚えてない)

セットアップ方法

  • 基本的には本家のREADME.mdを参考にするのが良いんだろうけど自分の環境でうまく行った方法を残しておく
  1. 以下のコマンドを実行

    $ curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh
    $ sh ./installer.sh .vim/dein/
    
  2. .vimrcに以下を追記する

    .vimrc
    
    " プラグインが実際にインストールされるディレクトリ
    let s:dein_dir = expand('~/.vim/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 ファイル
      let g:rc_dir    = expand('~/.vim/rc')
      let s:toml      = g:rc_dir . '/dein.toml'
      " TOML を読み込み、キャッシュしておく
      call dein#load_toml(s:toml,      {'lazy': 0}) 
    
      " 設定終了
      call dein#end()
      call dein#save_state()
    endif
    
    " もし、未インストールものものがあったらインストール
    if dein#check_install()
      call dein#install()
    endif
    
  3. dein.tomlファイルにプラグインを追記する

    dein.toml
    [[plugins]]
    repo = 'davidhalter/jedi-vim'
    on_ft = 'python'
    
    [[plugins]]
    repo = 'simeji/winresizer'
    
    [[plugins]]
    repo = 'scrooloose/nerdtree'
    
    [[plugins]]
    repo = 'nathanaelkane/vim-indent-guides'
    
    [[plugins]]
    repo = 'vim-syntastic/syntastic'
    
    [[plugins]]
    repo = 'nvie/vim-flake8'
    
  4. 諸々プラグインのインストール

    $ cd .vim/dein/repos
    $ git clone 'プラグインのgithubリポジトリ'
    

ディレクトリ構成

  • 大雑把には下の様になる

    .vim
    ├── dein
    │   └── repos
    │       └── github.com
    │           ├── Shougo
    │           │   └── dein.vim # dein.vim
    │           ├── davidhalter
    │           │   └── jedi-vim # pythonの補完とか
    │           ├── nathanaelkane
    │           │   └── vim-indent-guides # インデントを可視化
    │           ├── nvie
    │           │   └── vim-flake8 # flake8を指摘してくれる
    │           ├── scrooloose
    │           │   └── nerdtree # ディレクトリツリーを表示できる
    │           ├── simeji
    │           │   └── winresizer # 画面分割時のウィンドウサイズ変更を簡単に
    │           ├── vim-scripts
    │           │   └── vcscommand.vim
    │           └── vim-syntastic
    │               └── syntastic # エラーとかチェックしてくれる
    └── rc
        ├── dein.toml
        └── dein_lazy.toml
    

終わりに

ざっくりとしか書いてないけど多分これで使えるようになるはず。まだまだ全然プラグイン入れてないし把握もできてないから調査してもっと便利にしたい。

9
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
11