LoginSignup
2
2

More than 5 years have passed since last update.

vim(windows編)からrubyの規約チェック

Posted at

rubocop の導入

ところが普通にインストールすると

gem install rubocop

以下のようなエラーとともにDevKitが必要だと言われるので素直に導入する。

Fetching: rainbow-2.0.0.gem (100%)
Fetching: ast-1.1.0.gem (100%)
Fetching: slop-3.4.7.gem (100%)
Fetching: parser-2.1.4.gem (100%)
Fetching: powerpack-0.0.9.gem (100%)
Fetching: json-1.8.1.gem (100%)
ERROR:  Error installing rubocop:
        The 'json' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

Devkit インストール

  1. DevKit-tdm-32-4.5.2-20111229-1559-sfx.exeをダウンロード
  2. フォルダを作って適当に展開
  3. ruby dk.rb initを実行
  4. 生成されたconfig.ymlの中身を確認
  5. ruby dk.rb installを実行

make

さらにmakeが入っていないと怒られるので、こちらも素直に導入する。

Make for Windows
http://gnuwin32.sourceforge.net/packages/make.htm
→ Complete package をインストール

json

さらに権限がないよとまた怒られる。
だが、そもそも以下のフォルダがなかったので

Temporarily enhancing PATH to include DevKit...
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/.gitignore

改めてjsonをインストールする。

gem install json

ここまでやってrubocopが想定通りインストールできた。

vim へ組み込む

syntasticの設定

すでにsyntasticを使っていたためsyntasticに設定する。

let g:syntastic_mode_map = { 'mode': 'active' }
let g:syntastic_ruby_checkers = ['rubocop']

後はファイルを保存する度に、チェックしてくれるようになりました。

設定ファイル

必要に応じて.rubocop.ymlで動作をカスタマイズする。

rubocop.yml
# Use only ascii symbols in comments.
AsciiComments:
  Enabled: false

参考

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