From 4abed357972bc7e307792d571fd67930763090e4 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Thu, 1 Aug 2013 17:26:51 +0300 Subject: [PATCH] Undo most of the changes to eruby/ruby. The new proprocess option is not useful here. --- syntax_checkers/eruby/ruby.vim | 44 ++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/syntax_checkers/eruby/ruby.vim b/syntax_checkers/eruby/ruby.vim index 05f29eb9..74e77a06 100644 --- a/syntax_checkers/eruby/ruby.vim +++ b/syntax_checkers/eruby/ruby.vim @@ -15,34 +15,37 @@ if exists("g:loaded_syntastic_eruby_ruby_checker") endif let g:loaded_syntastic_eruby_ruby_checker=1 -if !exists("g:syntastic_erb_exec") - let g:syntastic_erb_exec = "erb" -endif - if !exists("g:syntastic_ruby_exec") let g:syntastic_ruby_exec = "ruby" endif function! SyntaxCheckers_eruby_ruby_IsAvailable() - return executable(expand(g:syntastic_erb_exec)) && executable(expand(g:syntastic_ruby_exec)) -endfunction - -function! SyntaxCheckers_eruby_ruby_Preprocess(errors) - let out = copy(a:errors) - for n in range(len(out)) - let out[n] = substitute(out[n], '\V<%=', '<%', 'g') - endfor - return out + return executable(expand(g:syntastic_ruby_exec)) endfunction function! SyntaxCheckers_eruby_ruby_GetLocList() - " TODO: do something about the encoding - let makeprg = syntastic#makeprg#build({ - \ 'exe': expand(g:syntastic_erb_exec), - \ 'args': '-x -T -', - \ 'tail': ' | ' . expand(g:syntastic_ruby_exec) . ' -c', - \ 'filetype': 'eruby', - \ 'subchecker': 'ruby' }) + let exe = expand(g:syntastic_ruby_exec) + if !has('win32') + let exe = 'RUBYOPT= ' . exe + endif + + let fname = "'" . escape(expand('%'), "\\'") . "'" + + " TODO: encodings became useful in ruby 1.9 :) + if syntastic#util#versionIsAtLeast(syntastic#util#parseVersion('ruby --version'), [1, 9]) + let enc = &fileencoding != '' ? &fileencoding : &encoding + 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 = + \ exe . ' -rerb -e ' . + \ syntastic#util#shescape('puts ERB.new(File.read(' . + \ fname . encoding_spec . + \ ').gsub(''<%='',''<%''), nil, ''-'').src') . + \ ' | ' . exe . ' -c' let errorformat = \ '%-GSyntax OK,'. @@ -54,7 +57,6 @@ function! SyntaxCheckers_eruby_ruby_GetLocList() return SyntasticMake({ \ 'makeprg': makeprg, \ 'errorformat': errorformat, - \ 'preprocess': 'SyntaxCheckers_eruby_ruby_Preprocess', \ 'defaults': { 'bufnr': bufnr(""), 'vcol': 1 } }) endfunction