2018-03-31 10:55:20 -04:00
|
|
|
" Author: Dmitri Vereshchagin <dmitri.vereshchagin@gmail.com>
|
|
|
|
" Description: SyntaxErl linter for Erlang files
|
|
|
|
|
|
|
|
call ale#Set('erlang_syntaxerl_executable', 'syntaxerl')
|
|
|
|
|
2019-05-17 10:09:13 -04:00
|
|
|
function! ale_linters#erlang#syntaxerl#RunHelpCommand(buffer) abort
|
|
|
|
let l:executable = ale#Var(a:buffer, 'erlang_syntaxerl_executable')
|
|
|
|
|
|
|
|
return ale#command#Run(
|
|
|
|
\ a:buffer,
|
|
|
|
\ ale#Escape(l:executable) . ' -h',
|
|
|
|
\ function('ale_linters#erlang#syntaxerl#GetCommand'),
|
|
|
|
\)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#erlang#syntaxerl#GetCommand(buffer, output, meta) abort
|
2018-03-31 10:55:20 -04:00
|
|
|
let l:use_b_option = match(a:output, '\C\V-b, --base\>') > -1
|
|
|
|
|
2018-08-25 12:13:42 -04:00
|
|
|
return '%e' . (l:use_b_option ? ' -b %s %t' : ' %t')
|
2018-03-31 10:55:20 -04:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort
|
|
|
|
let l:pattern = '\v\C:(\d+):( warning:)? (.+)'
|
|
|
|
let l:loclist = []
|
|
|
|
|
|
|
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
|
|
|
call add(l:loclist, {
|
|
|
|
\ 'lnum': l:match[1] + 0,
|
|
|
|
\ 'text': l:match[3],
|
|
|
|
\ 'type': empty(l:match[2]) ? 'E' : 'W',
|
|
|
|
\})
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return l:loclist
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('erlang', {
|
|
|
|
\ 'name': 'syntaxerl',
|
2019-03-08 06:04:56 -05:00
|
|
|
\ 'executable': {b -> ale#Var(b, 'erlang_syntaxerl_executable')},
|
2019-05-17 10:09:13 -04:00
|
|
|
\ 'command': {b -> ale_linters#erlang#syntaxerl#RunHelpCommand(b)},
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'callback': 'ale_linters#erlang#syntaxerl#Handle',
|
|
|
|
\})
|