1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

dein.vimでプラグイン管理

Last updated at Posted at 2019-07-21

vimでは既に多くのプラグインが存在するのでプラグインを管理するためのプラグインというものを作ってくれた方がいる。私もそのお知恵を拝借することにした。

ネットで検索してみると以下の2つのプラグイン管理が存在する。

多くの記事においてNeoBundleベースで記述されていたので、私もNeoBundleを使用することにした。ところが、Githubサイトを確認したところ、2017年以降はbugfixしかしないのでdeinを使用せよという熱いメッセージが記載されていたため、情報は少ないがそれほど難しくなさそうだったのでdeinで行くことにした。

「a dark powered vim/neovim plugin manager」という事で、めちゃくちゃパワフルなツールなのだろう。フォースを感じる。。

必要条件

vim 8.0以上との事。Git bashに標準のvim(私の環境)は問題なく使える。

$ vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 30 2018 15:10:52)

また、Windows環境の場合はxcopyがpathで通っている必要がある。
githubやvim.orgのプラグインを使いたい場合はgitコマンドもPATHで通っている必要がある。

※後でわかったことだが、dein.vimのインストーラーでgitは必須。これもGit bashなので問題なし。

インストール

ではインストール、、、Windows環境の説明ないな。。Linux/MacOSXの手順しかない。。。Git bashで同じようにインストールできるか確認してみる。
curlも必要みたい。

curl - command line tool and library for transferring data with URLs

※curlは自分でインストールするのだよ。私の場合は以下にインストールしている。

$ which curl
/c/Users/satom/apps/curl-7.64.0-win64-mingw/bin/curl

$ curl --version
curl 7.64.0 (x86_64-pc-win32) libcurl/7.64.0 OpenSSL/1.1.1a (Schannel) zlib/1.2.11 brotli/1.0.7 WinIDN libssh2/1.8.0 nghttp2/1.36.0
Release-Date: 2019-02-06

では、curlを使ってインストーラーをダウンロードする。

$ curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2233  100  2233    0     0  25375      0 --:--:-- --:--:-- --:--:-- 25375

続けてインストール。インストール先は「~/.cache/dein」とした。

$ sh ./installer.sh ~/.cache/dein
Install to "/c/Users/satom/.cache/dein/repos/github.com/Shougo/dein.vim"...

git is /mingw64/bin/git

Begin fetching dein...
Cloning into 'C:/Users/satom/.cache/dein/repos/github.com/Shougo/dein.vim'...
remote: Enumerating objects: 26, done.
remote: Counting objects: 100% (26/26), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 5351 (delta 8), reused 17 (delta 5), pack-reused 5325
Receiving objects: 100% (5351/5351), 1.06 MiB | 1.33 MiB/s, done.
Resolving deltas: 100% (3052/3052), done.
Done.

Please add the following settings for dein to the top of your vimrc (Vim) or init.vim (NeoVim) file:


"dein Scripts-----------------------------
if &compatible
  set nocompatible               " Be iMproved
endif

" Required:
set runtimepath+=/c/Users/satom/.cache/dein/repos/github.com/Shougo/dein.vim

" Required:
if dein#load_state('/c/Users/satom/.cache/dein')
  call dein#begin('/c/Users/satom/.cache/dein')

  " Let dein manage dein
  " Required:
  call dein#add('/c/Users/satom/.cache/dein/repos/github.com/Shougo/dein.vim')

  " Add or remove your plugins here like this:
  "call dein#add('Shougo/neosnippet.vim')
  "call dein#add('Shougo/neosnippet-snippets')

  " 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

"End dein Scripts-------------------------


Done.
Complete setup dein!

インストール時のメッセージ曰く、「"deni Scripts---...」から「"End dein Script---...」までを.vimに追加しろと。あと、スタートアップ時にインストールしたい場合は最後のコメントアウトを外す必要があるらしい。
以下、追加したスクリプト。

"------------------------------------------------------------
"dein Scripts

if &compatible
  set nocompatible               " Be iMproved
endif

" Required:
set runtimepath+=/c/Users/satom/.cache/dein/repos/github.com/Shougo/dein.vim

" Required:
if dein#load_state('/c/Users/satom/.cache/dein')
  call dein#begin('/c/Users/satom/.cache/dein')

  " Let dein manage dein
  " Required:
  call dein#add('/c/Users/satom/.cache/dein/repos/github.com/Shougo/dein.vim')

  " Add or remove your plugins here like this:
  "call dein#add('Shougo/neosnippet.vim')
  "call dein#add('Shougo/neosnippet-snippets')

  " 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

"---------- End dein Scripts

よし。
次の記事で、node.js開発環境としてvimにディレクトリツリーを表示させるプラグインを入れてみる。
暗黒パワーでガっと動いてくれることを願いつつ。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?