blob: 41aca0c8e70acc52c02bc96006d13ae16c682294 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
" Author: Roeland Moors - https://github.com/roelandmoors
" Description: ERB Lint, support for https://github.com/Shopify/erb-lint
call ale#Set('eruby_erblint_executable', 'erblint')
call ale#Set('eruby_erblint_options', '')
" Erblint fixer outputs diagnostics first and then the fixed
" output. These are delimited by something like this:
" ================ /path/to/demo.html.erb ==================
" We only need the output after this
function! ale#fixers#erblint#PostProcess(buffer, output) abort
let l:line = 0
for l:output in a:output
let l:line = l:line + 1
if l:output =~# "^=\\+.*=\\+$"
break
endif
endfor
return a:output[l:line :]
endfunction
function! ale#fixers#erblint#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'eruby_erblint_executable')
let l:options = ale#Var(a:buffer, 'eruby_erblint_options')
return ale#ruby#EscapeExecutable(l:executable, 'erblint')
\ . (!empty(l:options) ? ' ' . l:options : '')
\ . ' --autocorrect --stdin %s'
endfunction
function! ale#fixers#erblint#Fix(buffer) abort
return {
\ 'command': ale#fixers#erblint#GetCommand(a:buffer),
\ 'process_with': 'ale#fixers#erblint#PostProcess'
\}
endfunction
|