From d9d641fe0a3fe0033c5dbe8bb3f556e334dc28fb Mon Sep 17 00:00:00 2001 From: Grzegorz Smajdor Date: Tue, 18 Jun 2013 14:06:47 +0200 Subject: [PATCH 1/3] provide a syntax check for eruby file (cherry picked from commit e6ff3de83b9fee4f92dbc3042cf5fbcc48464f73) --- syntax_checkers/eruby/eruby.vim | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 syntax_checkers/eruby/eruby.vim diff --git a/syntax_checkers/eruby/eruby.vim b/syntax_checkers/eruby/eruby.vim new file mode 100644 index 00000000..47c7a785 --- /dev/null +++ b/syntax_checkers/eruby/eruby.vim @@ -0,0 +1,54 @@ +"============================================================================ +"File: eruby.vim +"Description: Syntax checking plugin for syntastic.vim +"Author: Martin Grenfell +"Modifier: Grzegorz Smajdor +"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_eruby_ruby_checker") + finish +endif +let g:loaded_syntastic_eruby_ruby_checker=1 + +if !exists("g:syntastic_ruby_exec") + let g:syntastic_ruby_exec = "ruby" +endif + +function! SyntaxCheckers_eruby_ruby_IsAvailable() + return executable(expand(g:syntastic_ruby_exec)) +endfunction + +function! SyntaxCheckers_eruby_ruby_GetLocList() + let exe = expand(g:syntastic_ruby_exec) + if !has('win32') + let exe = 'RUBYOPT= ' . exe + endif + + let fname = fnameescape(expand('%')) + + let enc = &fileencoding != '' ? &fileencoding : &encoding + let encoding_string = enc ==# 'utf-8' ? ', :encoding => "UTF-8"' : '' + + let makeprg = 'erb -xT - ' . shellescape(fnameescape(fname)) . ' \| ruby -c' + + let errorformat = + \ '%-GSyntax OK,'. + \ '%E-:%l: syntax error\, %m,%Z%p^,'. + \ '%W-:%l: warning: %m,'. + \ '%Z%p^,'. + \ '%-C%.%#' + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'defaults': { 'bufnr': bufnr(""), 'vcol': 1 } }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'eruby', + \ 'name': 'ruby'}) From e7a3fd62a6f94cf9e7a705ca76161b34fa80c2d0 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Tue, 18 Jun 2013 19:47:05 +0300 Subject: [PATCH 2/3] Clean erb checker. --- syntax_checkers/eruby/eruby.vim | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/syntax_checkers/eruby/eruby.vim b/syntax_checkers/eruby/eruby.vim index 47c7a785..8f9084b4 100644 --- a/syntax_checkers/eruby/eruby.vim +++ b/syntax_checkers/eruby/eruby.vim @@ -1,5 +1,5 @@ "============================================================================ -"File: eruby.vim +"File: erb.vim "Description: Syntax checking plugin for syntastic.vim "Author: Martin Grenfell "Modifier: Grzegorz Smajdor @@ -10,31 +10,32 @@ " See http://sam.zoy.org/wtfpl/COPYING for more details. "============================================================================ -if exists("g:loaded_syntastic_eruby_ruby_checker") +if exists("g:loaded_syntastic_eruby_erb_checker") finish endif -let g:loaded_syntastic_eruby_ruby_checker=1 +let g:loaded_syntastic_eruby_erb_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_ruby_exec)) +function! SyntaxCheckers_eruby_erb_IsAvailable() + return executable(expand(g:syntastic_ruby_exec)) && executable(expand(g:syntastic_ruby_exec)) endfunction -function! SyntaxCheckers_eruby_ruby_GetLocList() - let exe = expand(g:syntastic_ruby_exec) - if !has('win32') - let exe = 'RUBYOPT= ' . exe - endif - - let fname = fnameescape(expand('%')) - +function! SyntaxCheckers_eruby_erb_GetLocList() let enc = &fileencoding != '' ? &fileencoding : &encoding - let encoding_string = enc ==# 'utf-8' ? ', :encoding => "UTF-8"' : '' - let makeprg = 'erb -xT - ' . shellescape(fnameescape(fname)) . ' \| ruby -c' + let makeprg = syntastic#makeprg#build({ + \ 'exe': g:syntastic_erb_exec, + \ 'args': '-x -T -' . (enc ==# 'utf-8' ? ' -U' : ''), + \ 'tail': '\| ' . g:syntastic_ruby_exec . ' -c', + \ 'filetype': 'eruby', + \ 'subchecker': 'erb' }) let errorformat = \ '%-GSyntax OK,'. @@ -51,4 +52,4 @@ endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ \ 'filetype': 'eruby', - \ 'name': 'ruby'}) + \ 'name': 'erb'}) From c21f9e0f86bb3dfe584c4200e5bd688ba5a26ecb Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Tue, 18 Jun 2013 19:47:26 +0300 Subject: [PATCH 3/3] Rename eruby.vim -> erb.vim. --- syntax_checkers/eruby/{eruby.vim => erb.vim} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename syntax_checkers/eruby/{eruby.vim => erb.vim} (100%) diff --git a/syntax_checkers/eruby/eruby.vim b/syntax_checkers/eruby/erb.vim similarity index 100% rename from syntax_checkers/eruby/eruby.vim rename to syntax_checkers/eruby/erb.vim