2017-07-16 11:35:43 +00:00
|
|
|
" Author: Dmitri Vereshchagin <dmitri.vereshchagin@gmail.com>
|
|
|
|
" Description: SyntaxErl linter for Erlang files
|
|
|
|
|
|
|
|
call ale#Set('erlang_syntaxerl_executable', 'syntaxerl')
|
|
|
|
|
|
|
|
|
|
|
|
function! ale_linters#erlang#syntaxerl#GetExecutable(buffer) abort
|
|
|
|
return ale#Var(a:buffer, 'erlang_syntaxerl_executable')
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2017-08-19 17:54:23 +00:00
|
|
|
function! ale_linters#erlang#syntaxerl#FeatureCheck(buffer) abort
|
|
|
|
return s:GetEscapedExecutable(a:buffer) . ' -h'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
function! ale_linters#erlang#syntaxerl#GetCommand(buffer, output) abort
|
|
|
|
let l:use_b_option = match(a:output, '\C\V-b, --base\>') > -1
|
2017-08-19 14:48:29 +00:00
|
|
|
|
2017-08-19 17:54:23 +00:00
|
|
|
return s:GetEscapedExecutable(a:buffer) . (l:use_b_option ? ' -b %s %t' : ' %t')
|
2017-07-16 11:35:43 +00: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
|
|
|
|
|
|
|
|
|
2017-08-19 17:54:23 +00:00
|
|
|
function! s:GetEscapedExecutable(buffer) abort
|
|
|
|
return ale#Escape(ale_linters#erlang#syntaxerl#GetExecutable(a:buffer))
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2017-07-16 11:35:43 +00:00
|
|
|
call ale#linter#Define('erlang', {
|
|
|
|
\ 'name': 'syntaxerl',
|
|
|
|
\ 'executable_callback': 'ale_linters#erlang#syntaxerl#GetExecutable',
|
2017-08-19 17:54:23 +00:00
|
|
|
\ 'command_chain': [
|
|
|
|
\ {'callback': 'ale_linters#erlang#syntaxerl#FeatureCheck'},
|
|
|
|
\ {'callback': 'ale_linters#erlang#syntaxerl#GetCommand'},
|
|
|
|
\ ],
|
2017-07-16 11:35:43 +00:00
|
|
|
\ 'callback': 'ale_linters#erlang#syntaxerl#Handle',
|
|
|
|
\})
|