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: Patrick Lewis - https://github.com/patricklewis, thenoseman - https://github.com/thenoseman
2 " Description: haml-lint for Haml files
4 call ale#Set('haml_hamllint_executable', 'haml-lint')
6 function! ale_linters#haml#hamllint#GetExecutable(buffer) abort
7 return ale#Var(a:buffer, 'haml_hamllint_executable')
10 function! ale_linters#haml#hamllint#GetCommand(buffer) abort
13 let l:rubocop_config_file_path = ale#path#FindNearestFile(a:buffer, '.rubocop.yml')
14 let l:hamllint_config_file_path = ale#path#FindNearestFile(a:buffer, '.haml-lint.yml')
16 " Set HAML_LINT_RUBOCOP_CONF variable as it is needed for haml-lint to
17 " pick up the rubocop config.
19 " See https://github.com/brigade/haml-lint/blob/master/lib/haml_lint/linter/rubocop.rb#L89
20 " HamlLint::Linter::RuboCop#rubocop_flags
21 if !empty(l:rubocop_config_file_path)
23 let l:prefix = 'set HAML_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config_file_path) . ' &&'
25 let l:prefix = 'HAML_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config_file_path)
29 return (!empty(l:prefix) ? l:prefix . ' ' : '')
30 \ . ale_linters#haml#hamllint#GetExecutable(a:buffer)
31 \ . (!empty(l:hamllint_config_file_path) ? ' --config ' . ale#Escape(l:hamllint_config_file_path) : '')
35 function! ale_linters#haml#hamllint#Handle(buffer, lines) abort
36 " Matches patterns like the following:
37 " <path>:51 [W] RuboCop: Use the new Ruby 1.9 hash syntax.
38 let l:pattern = '\v^.*:(\d+) \[([EW])\] (.+)$'
41 for l:match in ale#util#GetMatches(a:lines, l:pattern)
43 \ 'lnum': l:match[1] + 0,
52 call ale#linter#Define('haml', {
54 \ 'executable': function('ale_linters#haml#hamllint#GetExecutable'),
55 \ 'command': function('ale_linters#haml#hamllint#GetCommand'),
56 \ 'callback': 'ale_linters#haml#hamllint#Handle'