mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Removed syntastic and replaced it with ale
Read more here: https://github.com/w0rp/ale
This commit is contained in:
25
sources_non_forked/ale/ale_linters/eruby/erb.vim
Normal file
25
sources_non_forked/ale/ale_linters/eruby/erb.vim
Normal file
@ -0,0 +1,25 @@
|
||||
" Author: Matthias Guenther - https://wikimatze.de, Eddie Lebow https://github.com/elebow
|
||||
" Description: ERB from the Ruby standard library, for eruby/erb files
|
||||
|
||||
function! ale_linters#eruby#erb#GetCommand(buffer) abort
|
||||
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
|
||||
|
||||
if empty(l:rails_root)
|
||||
return 'erb -P -T - -x %t | ruby -c'
|
||||
endif
|
||||
|
||||
" Rails-flavored eRuby does not comply with the standard as understood by
|
||||
" ERB, so we'll have to do some substitution. This does not reduce the
|
||||
" effectiveness of the linter—the translated code is still evaluated.
|
||||
return 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('eruby', {
|
||||
\ 'name': 'erb',
|
||||
\ 'aliases': ['erubylint'],
|
||||
\ 'executable': 'erb',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'command_callback': 'ale_linters#eruby#erb#GetCommand',
|
||||
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
|
||||
\})
|
||||
|
35
sources_non_forked/ale/ale_linters/eruby/erubi.vim
Normal file
35
sources_non_forked/ale/ale_linters/eruby/erubi.vim
Normal file
@ -0,0 +1,35 @@
|
||||
" Author: Eddie Lebow https://github.com/elebow
|
||||
" Description: eruby checker using `erubi`
|
||||
|
||||
function! ale_linters#eruby#erubi#CheckErubi(buffer) abort
|
||||
return 'ruby -r erubi/capture_end -e ' . ale#Escape('""')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#eruby#erubi#GetCommand(buffer, check_erubi_output) abort
|
||||
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
|
||||
|
||||
if (!empty(a:check_erubi_output))
|
||||
" The empty command in CheckErubi returns nothing if erubi runs and
|
||||
" emits an error if erubi is not present
|
||||
return ''
|
||||
endif
|
||||
|
||||
if empty(l:rails_root)
|
||||
return 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read).src') . '< %t | ruby -c'
|
||||
endif
|
||||
|
||||
" Rails-flavored eRuby does not comply with the standard as understood by
|
||||
" Erubi, so we'll have to do some substitution. This does not reduce the
|
||||
" effectiveness of the linter---the translated code is still evaluated.
|
||||
return 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('eruby', {
|
||||
\ 'name': 'erubi',
|
||||
\ 'executable': 'ruby',
|
||||
\ 'command_chain': [
|
||||
\ {'callback': 'ale_linters#eruby#erubi#CheckErubi'},
|
||||
\ {'callback': 'ale_linters#eruby#erubi#GetCommand', 'output_stream': 'stderr'},
|
||||
\ ],
|
||||
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
|
||||
\})
|
23
sources_non_forked/ale/ale_linters/eruby/erubis.vim
Normal file
23
sources_non_forked/ale/ale_linters/eruby/erubis.vim
Normal file
@ -0,0 +1,23 @@
|
||||
" Author: Jake Zimmerman <jake@zimmerman.io>, Eddie Lebow https://github.com/elebow
|
||||
" Description: eruby checker using `erubis`, instead of `erb`
|
||||
|
||||
function! ale_linters#eruby#erubis#GetCommand(buffer) abort
|
||||
let l:rails_root = ale#ruby#FindRailsRoot(a:buffer)
|
||||
|
||||
if empty(l:rails_root)
|
||||
return 'erubis -x %t | ruby -c'
|
||||
endif
|
||||
|
||||
" Rails-flavored eRuby does not comply with the standard as understood by
|
||||
" Erubis, so we'll have to do some substitution. This does not reduce the
|
||||
" effectiveness of the linter - the translated code is still evaluated.
|
||||
return 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . '< %t | ruby -c'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('eruby', {
|
||||
\ 'name': 'erubis',
|
||||
\ 'executable': 'erubis',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'command_callback': 'ale_linters#eruby#erubis#GetCommand',
|
||||
\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors',
|
||||
\})
|
Reference in New Issue
Block a user