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: Dmitri Vereshchagin <dmitri.vereshchagin@gmail.com>
2 " Description: Elvis linter for Erlang files
4 call ale#Set('erlang_elvis_executable', 'elvis')
6 function! ale_linters#erlang#elvis#Handle(buffer, lines) abort
7 let l:pattern = '\v:(\d+):[^:]+:(.+)'
10 for l:match in ale#util#GetMatches(a:lines, l:pattern)
12 \ 'lnum': str2nr(l:match[1]),
13 \ 'text': s:AbbreviateMessage(l:match[2]),
15 \ 'sub_type': 'style',
22 function! s:AbbreviateMessage(text) abort
23 let l:pattern = '\v\c^(line \d+ is too long):.*$'
25 return substitute(a:text, l:pattern, '\1.', '')
28 function! s:GetCommand(buffer) abort
29 let l:cwd = s:GetCwd(a:buffer)
31 let l:file = !empty(l:cwd)
32 \ ? expand('#' . a:buffer . ':p')[len(l:cwd) + 1:]
33 \ : expand('#' . a:buffer . ':.')
35 return '%e rock --output-format=parsable ' . ale#Escape(l:file)
38 function! s:GetCwd(buffer) abort
39 let l:markers = ['elvis.config', 'rebar.lock', 'erlang.mk']
41 for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
42 for l:marker in l:markers
43 if filereadable(l:path . '/' . l:marker)
52 call ale#linter#Define('erlang', {
54 \ 'callback': 'ale_linters#erlang#elvis#Handle',
55 \ 'executable': {b -> ale#Var(b, 'erlang_elvis_executable')},
56 \ 'command': function('s:GetCommand'),
57 \ 'cwd': function('s:GetCwd'),