diff options
author | Patrick Lewis <patrick@endpoint.com> | 2017-03-03 15:27:07 -0500 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2017-03-03 20:27:07 +0000 |
commit | 9e9e15bc87571ec3beb95231fdbb6d818c2ea203 (patch) | |
tree | ca335493ce3a89a8f9f87644bae8ecf3a3c2ddcf /ale_linters/haml | |
parent | 2750c605c1ee320a8675fb40a224a60d27f8de6f (diff) | |
download | ale-9e9e15bc87571ec3beb95231fdbb6d818c2ea203.zip |
Add hamllint linter for Haml (#377)
* Add hamllint linter for Haml
* Simplify hamllint
Diffstat (limited to 'ale_linters/haml')
-rw-r--r-- | ale_linters/haml/hamllint.vim | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ale_linters/haml/hamllint.vim b/ale_linters/haml/hamllint.vim new file mode 100644 index 00000000..fead7472 --- /dev/null +++ b/ale_linters/haml/hamllint.vim @@ -0,0 +1,33 @@ +" Author: Patrick Lewis - https://github.com/patricklewis +" Description: haml-lint for Haml files + +function! ale_linters#haml#hamllint#Handle(buffer, lines) abort + " Matches patterns like the following: + " <path>:51 [W] RuboCop: Use the new Ruby 1.9 hash syntax. + let l:pattern = '\v^.*:(\d+) \[([EW])\] (.+)$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'type': l:match[2], + \ 'text': l:match[3] + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('haml', { +\ 'name': 'hamllint', +\ 'executable': 'haml-lint', +\ 'command': 'haml-lint %t', +\ 'callback': 'ale_linters#haml#hamllint#Handle' +\}) |