1
0
Fork 0
mirror of synced 2024-11-23 17:25:35 -05:00
ultimate-vim/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim

45 lines
1.3 KiB
VimL
Raw Permalink Normal View History

" 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#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, {
2024-10-06 04:25:50 -04:00
\ 'lnum': str2nr(l:match[1]),
\ 'text': l:match[3],
\ 'type': empty(l:match[2]) ? 'E' : 'W',
\})
endfor
return l:loclist
endfunction
2024-10-06 04:25:50 -04:00
function! s:GetExecutable(buffer) abort
return ale#Var(a:buffer, 'erlang_syntaxerl_executable')
endfunction
function! s:GetCommand(buffer) abort
let l:Callback = function('s:GetCommandFromHelpOutput')
return ale#command#Run(a:buffer, '%e -h', l:Callback, {
\ 'executable': s:GetExecutable(a:buffer),
\})
endfunction
function! s:GetCommandFromHelpOutput(buffer, output, metadata) abort
let l:has_b_option = match(a:output, '\V\C-b, --base\>') > -1
return l:has_b_option ? '%e -b %s %t' : '%e %t'
endfunction
call ale#linter#Define('erlang', {
\ 'name': 'syntaxerl',
\ 'callback': 'ale_linters#erlang#syntaxerl#Handle',
2024-10-06 04:25:50 -04:00
\ 'executable': function('s:GetExecutable'),
\ 'command': function('s:GetCommand'),
\})