diff options
Diffstat (limited to 'vim/bundle/syntastic/syntax_checkers/ruby')
-rw-r--r-- | vim/bundle/syntastic/syntax_checkers/ruby/flog.vim | 72 | ||||
-rw-r--r-- | vim/bundle/syntastic/syntax_checkers/ruby/jruby.vim | 50 | ||||
-rw-r--r-- | vim/bundle/syntastic/syntax_checkers/ruby/macruby.vim | 49 | ||||
-rw-r--r-- | vim/bundle/syntastic/syntax_checkers/ruby/mri.vim | 82 | ||||
-rw-r--r-- | vim/bundle/syntastic/syntax_checkers/ruby/reek.vim | 56 | ||||
-rw-r--r-- | vim/bundle/syntastic/syntax_checkers/ruby/rubocop.vim | 57 | ||||
-rw-r--r-- | vim/bundle/syntastic/syntax_checkers/ruby/rubylint.vim | 45 |
7 files changed, 411 insertions, 0 deletions
diff --git a/vim/bundle/syntastic/syntax_checkers/ruby/flog.vim b/vim/bundle/syntastic/syntax_checkers/ruby/flog.vim new file mode 100644 index 0000000..127cdbd --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/ruby/flog.vim @@ -0,0 +1,72 @@ +"============================================================================ +"File: flog.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Tim Carry <tim at pixelastic dot com> +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +"============================================================================ + +if exists('g:loaded_syntastic_ruby_flog_checker') + finish +endif +let g:loaded_syntastic_ruby_flog_checker = 1 + +if !exists('g:syntastic_ruby_flog_threshold_warning') + let g:syntastic_ruby_flog_threshold_warning = 45 +endif + +if !exists('g:syntastic_ruby_flog_threshold_error') + let g:syntastic_ruby_flog_threshold_error = 90 +endif + +if !exists('g:syntastic_ruby_flog_sort') + let g:syntastic_ruby_flog_sort = 1 +endif + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_ruby_flog_GetLocList() dict + let makeprg = self.makeprgBuild({ 'args': '-a' }) + + " Example output: + " 93.25: MyClass::my_method my_file:42 + let errorformat = '%\m%\s%#%m: %.%# %f:%l' + + let loclist = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'subtype': 'Style' }) + + let trail_w = syntastic#util#float2str(g:syntastic_ruby_flog_threshold_warning) . ')' + let trail_e = syntastic#util#float2str(g:syntastic_ruby_flog_threshold_error) . ')' + for e in loclist + let score = syntastic#util#str2float(e['text']) + + let e['text'] = 'Complexity is too high (' . syntastic#util#float2str(score) . '/' + if score < g:syntastic_ruby_flog_threshold_warning + let e['valid'] = 0 + elseif score < g:syntastic_ruby_flog_threshold_error + let e['type'] = 'W' + let e['text'] .= trail_w + else + let e['type'] = 'E' + let e['text'] .= trail_e + endif + endfor + + return loclist +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'ruby', + \ 'name': 'flog'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/ruby/jruby.vim b/vim/bundle/syntastic/syntax_checkers/ruby/jruby.vim new file mode 100644 index 0000000..d9d2aee --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/ruby/jruby.vim @@ -0,0 +1,50 @@ +"============================================================================ +"File: jruby.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Leonid Shevtsov <leonid at shevtsov dot me> +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +"============================================================================ + +if exists('g:loaded_syntastic_ruby_jruby_checker') + finish +endif +let g:loaded_syntastic_ruby_jruby_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_ruby_jruby_GetLocList() dict + let makeprg = self.makeprgBuild({ + \ 'args': (syntastic#util#isRunningWindows() ? '-T1 -W1' : '-W1'), + \ 'args_after': '-c' }) + + let errorformat = + \ '%-GSyntax OK for %f,'. + \ '%ESyntaxError in %f:%l: syntax error\, %m,'. + \ '%Z%p^,'. + \ '%W%f:%l: warning: %m,'. + \ '%Z%p^,'. + \ '%W%f:%l: %m,'. + \ '%-C%.%#' + + let env = syntastic#util#isRunningWindows() ? {} : { 'RUBYOPT': '' } + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'env': env }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'ruby', + \ 'name': 'jruby'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/ruby/macruby.vim b/vim/bundle/syntastic/syntax_checkers/ruby/macruby.vim new file mode 100644 index 0000000..c51188f --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/ruby/macruby.vim @@ -0,0 +1,49 @@ +"============================================================================ +"File: macruby.vim +"Description: Syntax checking plugin for syntastic.vim +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +"============================================================================ + +if exists('g:loaded_syntastic_ruby_macruby_checker') + finish +endif +let g:loaded_syntastic_ruby_macruby_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_ruby_macruby_GetLocList() dict + let makeprg = self.makeprgBuild({ + \ 'args': '-W1', + \ 'args_after': '-c' }) + + let errorformat = + \ '%-GSyntax OK,'. + \ '%E%f:%l: syntax error\, %m,'. + \ '%Z%p^,'. + \ '%W%f:%l: warning: %m,'. + \ '%Z%p^,'. + \ '%W%f:%l: %m,'. + \ '%-C%.%#' + + let env = { 'RUBYOPT': '' } + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'env': env }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'ruby', + \ 'name': 'macruby'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/ruby/mri.vim b/vim/bundle/syntastic/syntax_checkers/ruby/mri.vim new file mode 100644 index 0000000..563ed4f --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/ruby/mri.vim @@ -0,0 +1,82 @@ +"============================================================================ +"File: mri.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com> +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +"============================================================================ + +if exists('g:loaded_syntastic_ruby_mri_checker') + finish +endif +let g:loaded_syntastic_ruby_mri_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_ruby_mri_IsAvailable() dict + if !exists('g:syntastic_ruby_mri_exec') && exists('g:syntastic_ruby_exec') + let g:syntastic_ruby_mri_exec = g:syntastic_ruby_exec + call self.log('g:syntastic_ruby_exec =', g:syntastic_ruby_exec) + endif + return executable(self.getExec()) +endfunction + +function! SyntaxCheckers_ruby_mri_GetHighlightRegex(i) + if stridx(a:i['text'], 'assigned but unused variable') >= 0 + let term = split(a:i['text'], ' - ')[1] + return '\V\<' . escape(term, '\') . '\>' + endif + + return '' +endfunction + +function! SyntaxCheckers_ruby_mri_GetLocList() dict + let makeprg = self.makeprgBuild({ + \ 'args': '-w -T1', + \ 'args_after': '-c' }) + + "this is a hack to filter out a repeated useless warning in rspec files + "containing lines like + " + " foo.should == 'bar' + " + "Which always generate the warning below. Note that ruby >= 1.9.3 includes + "the word "possibly" in the warning + let errorformat = '%-G%\m%.%#warning: %\%%(possibly %\)%\?useless use of == in void context,' + + " filter out lines starting with ... + " long lines are truncated and wrapped in ... %p then returns the wrong + " column offset + let errorformat .= '%-G%\%.%\%.%\%.%.%#,' + + let errorformat .= + \ '%-GSyntax OK,'. + \ '%E%f:%l: syntax error\, %m,'. + \ '%Z%p^,'. + \ '%W%f:%l: warning: %m,'. + \ '%Z%p^,'. + \ '%W%f:%l: %m,'. + \ '%-C%.%#' + + let env = syntastic#util#isRunningWindows() ? {} : { 'RUBYOPT': '' } + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'env': env }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'ruby', + \ 'name': 'mri', + \ 'exec': 'ruby'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/ruby/reek.vim b/vim/bundle/syntastic/syntax_checkers/ruby/reek.vim new file mode 100644 index 0000000..d9a564a --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/ruby/reek.vim @@ -0,0 +1,56 @@ +"============================================================================ +"File: reek.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Mindaugas Mozūras +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +"============================================================================ + +if exists('g:loaded_syntastic_ruby_reek_checker') + finish +endif +let g:loaded_syntastic_ruby_reek_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_ruby_reek_IsAvailable() dict + if !executable(self.getExec()) + return 0 + endif + return syntastic#util#versionIsAtLeast(self.getVersion(), [1, 3, 0]) +endfunction + +function! SyntaxCheckers_ruby_reek_GetLocList() dict + let makeprg = self.makeprgBuild({ 'args_before': '--no-color --line-number --single-line' }) + + let errorformat = + \ '%E%.%#: Racc::ParseError: %f:%l :: %m,' . + \ '%W%f:%l: %m' + + let loclist = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'returns': [0, 2] }) + + for e in loclist + if e['type'] ==? 'W' + let e['subtype'] = 'Style' + endif + endfor + + return loclist +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'ruby', + \ 'name': 'reek'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/ruby/rubocop.vim b/vim/bundle/syntastic/syntax_checkers/ruby/rubocop.vim new file mode 100644 index 0000000..56f54bf --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/ruby/rubocop.vim @@ -0,0 +1,57 @@ +"============================================================================ +"File: rubocop.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Recai Oktaş <roktas@bil.omu.edu.tr> +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +"============================================================================ + +if exists('g:loaded_syntastic_ruby_rubocop_checker') + finish +endif +let g:loaded_syntastic_ruby_rubocop_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_ruby_rubocop_IsAvailable() dict + if !executable(self.getExec()) + return 0 + endif + return syntastic#util#versionIsAtLeast(self.getVersion(), [0, 12, 0]) +endfunction + +function! SyntaxCheckers_ruby_rubocop_GetLocList() dict + let makeprg = self.makeprgBuild({ 'args_after': '--format emacs' }) + + let errorformat = '%f:%l:%c: %t: %m' + + let loclist = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'subtype': 'Style'}) + + " convert rubocop severities to error types recognized by syntastic + for e in loclist + if e['type'] ==# 'F' + let e['type'] = 'E' + elseif e['type'] !=# 'W' && e['type'] !=# 'E' + let e['type'] = 'W' + endif + endfor + + return loclist +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'ruby', + \ 'name': 'rubocop'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/ruby/rubylint.vim b/vim/bundle/syntastic/syntax_checkers/ruby/rubylint.vim new file mode 100644 index 0000000..2e74f87 --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/ruby/rubylint.vim @@ -0,0 +1,45 @@ +"============================================================================ +"File: rubylint.vim +"Description: Checks Ruby source code using ruby-lint +"Maintainer: Yorick Peterse <yorickpeterse@gmail.com> +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +"============================================================================ + +if exists('g:loaded_syntastic_ruby_rubylint_checker') + finish +endif + +let g:loaded_syntastic_ruby_rubylint_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_ruby_rubylint_GetLocList() dict + if !exists('s:rubylint_new') + let s:rubylint_new = syntastic#util#versionIsAtLeast(self.getVersion(), [2]) + endif + let makeprg = self.makeprgBuild({ + \ 'args': (s:rubylint_new ? '' : 'analyze '), + \ 'args_after': '--presenter=syntastic' }) + + let errorformat = '%f:%t:%l:%c: %m' + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'ruby', + \ 'name': 'rubylint', + \ 'exec': 'ruby-lint'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: |