2012-03-02 12:36:11 -05:00
|
|
|
"============================================================================
|
|
|
|
"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.
|
|
|
|
"
|
|
|
|
"============================================================================
|
2013-02-21 10:50:41 -05:00
|
|
|
|
|
|
|
if exists("g:loaded_syntastic_ruby_mri_checker")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let g:loaded_syntastic_ruby_mri_checker=1
|
|
|
|
|
2012-10-15 07:49:22 -04:00
|
|
|
if !exists("g:syntastic_ruby_exec")
|
2013-02-28 20:29:58 -05:00
|
|
|
let g:syntastic_ruby_exec = "ruby"
|
2012-10-15 07:49:22 -04:00
|
|
|
endif
|
|
|
|
|
2013-01-27 18:59:25 -05:00
|
|
|
function! SyntaxCheckers_ruby_mri_IsAvailable()
|
2013-01-27 15:08:30 -05:00
|
|
|
return executable(expand(g:syntastic_ruby_exec))
|
|
|
|
endfunction
|
2012-10-15 07:49:22 -04:00
|
|
|
|
2013-01-27 15:08:30 -05:00
|
|
|
function! SyntaxCheckers_ruby_mri_GetLocList()
|
2013-01-20 06:07:05 -05:00
|
|
|
let exe = expand(g:syntastic_ruby_exec)
|
2012-07-17 17:36:55 -04:00
|
|
|
if !has('win32')
|
2013-01-20 06:07:05 -05:00
|
|
|
let exe = 'RUBYOPT= ' . exe
|
2012-03-02 12:36:11 -05:00
|
|
|
endif
|
|
|
|
|
2013-01-20 06:07:05 -05:00
|
|
|
let makeprg = syntastic#makeprg#build({
|
|
|
|
\ 'exe': exe,
|
|
|
|
\ 'args': '-w -T1 -c',
|
|
|
|
\ 'subchecker': 'mri' })
|
|
|
|
|
2012-07-17 17:36:55 -04:00
|
|
|
"this is a hack to filter out a repeated useless warning in rspec files
|
|
|
|
"containing lines like
|
|
|
|
"
|
|
|
|
" foo.should == 'bar'
|
|
|
|
"
|
2012-07-19 06:10:05 -04:00
|
|
|
"Which always generate the warning below. Note that ruby >= 1.9.3 includes
|
|
|
|
"the word "possibly" in the warning
|
|
|
|
let errorformat = '%-G%.%#warning: %\(possibly %\)%\?useless use of == in void context'
|
2012-07-17 17:36:55 -04:00
|
|
|
|
ruby/mri: ignore efm lines that start ...
If the line a ruby error occurs on is 'too long' it will truncate the line it
displays in the error output and wrap it in `...`. This breaks %p from finding
the correct column so this patch ignores lines starting with `...`
e.g. %p working
```
ruby -w -T1 -c broken.rb
broken.rb:2: syntax error, unexpected tIDENTIFIER, expecting $end
puts sprintf "%d, %.2f, %.2f, %.2f, %d" k, v
^
```
%p not working
```
ruby -w -T1 -c broken.rb
broken.rb:2: syntax error, unexpected tIDENTIFIER, expecting $end
...tf "%d, %.2f, %.2f, %.2f, %d" k, v[:cost], v[:val], v[:carri...
... ^
```
2012-09-25 09:21:46 -04:00
|
|
|
" 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'
|
|
|
|
let errorformat .= ',%Z%p^,%W%f:%l: warning: %m,%Z%p^,%W%f:%l: %m,%-C%.%#'
|
2012-03-02 12:36:11 -05:00
|
|
|
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
|
|
|
endfunction
|
2013-01-27 15:08:30 -05:00
|
|
|
|
|
|
|
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
|
|
|
\ 'filetype': 'ruby',
|
|
|
|
\ 'name': 'mri'})
|