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.
1 " Author: Markus Doits - https://github.com/doits
2 " Description: slim-lint for Slim files
4 function! ale_linters#slim#slimlint#GetCommand(buffer) abort
5 let l:command = 'slim-lint %t'
7 let l:rubocop_config = ale#path#FindNearestFile(a:buffer, '.rubocop.yml')
9 " Set SLIM_LINT_RUBOCOP_CONF variable as it is needed for slim-lint to
10 " pick up the rubocop config.
12 " See https://github.com/sds/slim-lint/blob/master/lib/slim_lint/linter/README.md#rubocop
13 if !empty(l:rubocop_config)
15 let l:command = 'set SLIM_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config) . ' && ' . l:command
17 let l:command = 'SLIM_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config) . ' ' . l:command
24 function! ale_linters#slim#slimlint#Handle(buffer, lines) abort
25 " Matches patterns like the following:
26 " <path>:5 [W] LineLength: Line is too long. [150/120]
27 let l:pattern = '\v^.*:(\d+) \[([EW])\] (.+)$'
30 for l:match in ale#util#GetMatches(a:lines, l:pattern)
32 \ 'lnum': l:match[1] + 0,
37 let l:code_match = matchlist(l:item.text, '\v^([^:]+): (.+)$')
39 if !empty(l:code_match)
40 let l:item.code = l:code_match[1]
41 let l:item.text = l:code_match[2]
44 call add(l:output, l:item)
50 call ale#linter#Define('slim', {
52 \ 'executable': 'slim-lint',
53 \ 'command': function('ale_linters#slim#slimlint#GetCommand'),
54 \ 'callback': 'ale_linters#slim#slimlint#Handle'