Skip to content

Instantly share code, notes, and snippets.

@mybeky
Created April 3, 2013 12:53
Show Gist options
  • Save mybeky/5300954 to your computer and use it in GitHub Desktop.
Save mybeky/5300954 to your computer and use it in GitHub Desktop.
rubocop checker for syntastic.vim.
"============================================================================
"File: rubocop.vim
"Description: rubocop checker for syntastic.vim
"Author: mybeky <mybeky at gmail.com>
"
"============================================================================
if exists("g:loaded_syntastic_ruby_robocop_checker")
finish
endif
let g:loaded_syntastic_ruby_robocop_checker=1
function! SyntaxCheckers_ruby_rubocop_IsAvailable()
return executable('rubocop')
endfunction
function! SyntaxCheckers_ruby_rubocop_GetLocList()
let makeprg = syntastic#makeprg#build({
\ 'exe': 'rubocop',
\ 'args': ' -e -s' })
let errorformat = '%f:%l: %t: %m'
let loclist=SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
let n = len(loclist) - 1
while n >= 0
let loclist[n]['type'] = loclist[n]['type'] == 'C' ? 'W' : 'E'
let n -= 1
endwhile
return sort(loclist, 's:CmpLoclist')
endfunction
function! s:CmpLoclist(a, b)
return a:a['lnum'] - a:b['lnum']
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'ruby',
\ 'name': 'rubocop' })
@mybeky
Copy link
Author

mybeky commented Apr 4, 2013

add let g:syntastic_ruby_checkers=['rubocop'] to your .vimrc

@bbatsov
Copy link

bbatsov commented Apr 28, 2013

Someone has contributed a RuboCop checker upstream last week vim-syntastic/syntastic@02dbc64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment