]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/eruby/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:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / ale_linters / eruby / erblint.vim
1 " Author: Roeland Moors - https://github.com/roelandmoors
2 " based on the ale ruumba and robocop linters
3 " Description: ERB Lint, support for https://github.com/Shopify/erb-lint
4
5 call ale#Set('eruby_erblint_executable', 'erblint')
6 call ale#Set('eruby_erblint_options', '')
7
8 function! ale_linters#eruby#erblint#GetCommand(buffer) abort
9     let l:executable = ale#Var(a:buffer, 'eruby_erblint_executable')
10
11     return ale#ruby#EscapeExecutable(l:executable, 'erblint')
12     \   . ' --format json '
13     \   . ale#Var(a:buffer, 'eruby_erblint_options')
14     \   . ' --stdin %s'
15 endfunction
16
17 function! ale_linters#eruby#erblint#Handle(buffer, lines) abort
18     if empty(a:lines)
19         return []
20     endif
21
22     let l:errors = ale#util#FuzzyJSONDecode(a:lines[0], [])
23
24     if !has_key(l:errors, 'summary')
25     \|| l:errors['summary']['offenses'] == 0
26     \|| empty(l:errors['files'])
27         return []
28     endif
29
30     let l:output = []
31
32     for l:error in l:errors['files'][0]['offenses']
33         call add(l:output, {
34         \   'lnum': l:error['location']['start_line'] + 0,
35         \   'col': l:error['location']['start_column'] + 0,
36         \   'end_col': l:error['location']['last_column'] + 0,
37         \   'code': l:error['linter'],
38         \   'text': l:error['message'],
39         \   'type': 'W',
40         \})
41     endfor
42
43     return l:output
44 endfunction
45
46 call ale#linter#Define('eruby', {
47 \   'name': 'erblint',
48 \   'executable': {b -> ale#Var(b, 'eruby_erblint_executable')},
49 \   'command': function('ale_linters#eruby#erblint#GetCommand'),
50 \   'callback': 'ale_linters#eruby#erblint#Handle',
51 \})