Created
April 3, 2013 12:53
-
-
Save mybeky/5300954 to your computer and use it in GitHub Desktop.
rubocop checker for syntastic.vim.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"============================================================================ | |
"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' }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add
let g:syntastic_ruby_checkers=['rubocop']
to your .vimrc