]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/fixers/erblint.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

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