2009-07-11 03:11:31 -04:00
|
|
|
"============================================================================
|
2013-07-24 16:01:57 -04:00
|
|
|
"File: ruby.vim
|
2009-07-11 03:11:31 -04:00
|
|
|
"Description: Syntax checking plugin for syntastic.vim
|
2009-12-16 05:02:36 -05:00
|
|
|
"Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
2009-07-11 03:11:31 -04:00
|
|
|
"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.
|
|
|
|
"
|
|
|
|
"============================================================================
|
2009-07-11 03:09:20 -04:00
|
|
|
|
2015-03-25 12:44:34 -04:00
|
|
|
if exists('g:loaded_syntastic_eruby_ruby_checker')
|
2013-02-21 10:50:41 -05:00
|
|
|
finish
|
|
|
|
endif
|
2014-01-03 04:29:08 -05:00
|
|
|
let g:loaded_syntastic_eruby_ruby_checker = 1
|
2013-02-21 10:50:41 -05:00
|
|
|
|
2014-01-03 04:29:08 -05:00
|
|
|
let s:save_cpo = &cpo
|
|
|
|
set cpo&vim
|
|
|
|
|
2013-10-28 11:30:25 -04:00
|
|
|
function! SyntaxCheckers_eruby_ruby_IsAvailable() dict
|
2014-06-24 12:02:42 -04:00
|
|
|
if !exists('g:syntastic_eruby_ruby_exec') && exists('g:syntastic_ruby_exec')
|
|
|
|
let g:syntastic_eruby_ruby_exec = g:syntastic_ruby_exec
|
2014-10-07 13:49:02 -04:00
|
|
|
call self.log('g:syntastic_eruby_ruby_exec =', g:syntastic_eruby_ruby_exec)
|
2014-02-13 10:38:47 -05:00
|
|
|
endif
|
2014-07-07 12:04:22 -04:00
|
|
|
return executable(self.getExec())
|
2014-06-24 12:02:42 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! SyntaxCheckers_eruby_ruby_GetLocList() dict
|
2015-01-23 04:39:42 -05:00
|
|
|
if !exists('s:ruby_new')
|
|
|
|
let s:ruby_new = syntastic#util#versionIsAtLeast(self.getVersion(), [1, 9])
|
|
|
|
endif
|
|
|
|
|
2017-02-15 01:48:45 -05:00
|
|
|
let buf = bufnr('')
|
|
|
|
let fname = "'" . escape(bufname(buf), "\\'") . "'"
|
2013-08-01 10:26:51 -04:00
|
|
|
|
|
|
|
" TODO: encodings became useful in ruby 1.9 :)
|
2015-01-23 04:39:42 -05:00
|
|
|
if s:ruby_new
|
2015-03-25 12:44:34 -04:00
|
|
|
let enc = &fileencoding !=# '' ? &fileencoding : &encoding
|
2013-08-01 10:26:51 -04:00
|
|
|
let encoding_spec = ', :encoding => "' . (enc ==? 'utf-8' ? 'UTF-8' : 'BINARY') . '"'
|
|
|
|
else
|
|
|
|
let encoding_spec = ''
|
|
|
|
endif
|
|
|
|
|
|
|
|
"gsub fixes issue #7, rails has it's own eruby syntax
|
|
|
|
let makeprg =
|
2014-07-07 12:04:22 -04:00
|
|
|
\ self.getExecEscaped() . ' -rerb -e ' .
|
2013-08-01 10:26:51 -04:00
|
|
|
\ syntastic#util#shescape('puts ERB.new(File.read(' .
|
|
|
|
\ fname . encoding_spec .
|
|
|
|
\ ').gsub(''<%='',''<%''), nil, ''-'').src') .
|
2014-09-16 07:12:41 -04:00
|
|
|
\ ' | ' . self.getExecEscaped() . ' -w -c'
|
2012-09-24 22:34:14 -04:00
|
|
|
|
2014-09-16 11:12:50 -04:00
|
|
|
let errorformat = '%-G%\m%.%#warning: %\%%(possibly %\)%\?useless use of a literal in void context,'
|
2014-09-16 07:12:41 -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 .=
|
2013-05-14 12:36:20 -04:00
|
|
|
\ '%-GSyntax OK,'.
|
|
|
|
\ '%E-:%l: syntax error\, %m,%Z%p^,'.
|
|
|
|
\ '%W-:%l: warning: %m,'.
|
|
|
|
\ '%Z%p^,'.
|
|
|
|
\ '%-C%.%#'
|
2009-07-11 03:09:20 -04:00
|
|
|
|
2014-07-07 12:04:22 -04:00
|
|
|
let env = syntastic#util#isRunningWindows() ? {} : { 'RUBYOPT': '' }
|
|
|
|
|
2013-06-08 14:08:45 -04:00
|
|
|
return SyntasticMake({
|
|
|
|
\ 'makeprg': makeprg,
|
|
|
|
\ 'errorformat': errorformat,
|
2014-07-07 12:04:22 -04:00
|
|
|
\ 'env': env,
|
2017-02-15 01:48:45 -05:00
|
|
|
\ 'defaults': { 'bufnr': buf, 'vcol': 1 } })
|
2009-07-11 03:09:20 -04:00
|
|
|
endfunction
|
2013-01-27 15:08:30 -05:00
|
|
|
|
|
|
|
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
2013-01-30 12:03:36 -05:00
|
|
|
\ 'filetype': 'eruby',
|
2013-01-27 15:08:30 -05:00
|
|
|
\ 'name': 'ruby'})
|
2014-01-03 04:29:08 -05:00
|
|
|
|
|
|
|
let &cpo = s:save_cpo
|
|
|
|
unlet s:save_cpo
|
|
|
|
|
2015-01-04 05:46:54 -05:00
|
|
|
" vim: set sw=4 sts=4 et fdm=marker:
|