Last Updated: February 25, 2016
·
974
· tacahiroy

Vim: Check your Chef cookbooks using foodcritic

I've been using foodcritic to detect something wrong in a cookbook.
Firstly, you must install foodcritic.

gem install foodcritic

And also, you must put following code in your .vimrc.

" $HOME/.vimrc
autocmd BufRead,BufNewFile *
      \  if expand('%:p:h') =~# '.*/cookbooks/.*'
      \|   setlocal makeprg=foodcritic\ $*\ %
      \|   setlocal errorformat=%m:\ %f:%l
      \| endif

And then, you can use:

:make
:copen

If your cookbook has errors you will get messages in the Quickfix List:
Picture