1
0
Fork 0
mirror of synced 2024-11-25 10:15:35 -05:00
ultimate-vim/sources_non_forked/ale/ale_linters/mercury/mmc.vim

39 lines
1.2 KiB
VimL
Raw Normal View History

2018-06-14 06:31:12 -04:00
" Author: stewy33 <slocumstewy@gmail.com>
" Description: Lints mercury files using mmc
call ale#Set('mercury_mmc_executable', 'mmc')
call ale#Set('mercury_mmc_options', '--make --output-compile-error-lines 100')
function! ale_linters#mercury#mmc#GetCommand(buffer) abort
2021-05-05 04:25:00 -04:00
return '%e --errorcheck-only '
2018-06-14 06:31:12 -04:00
\ . ale#Var(a:buffer, 'mercury_mmc_options')
2021-05-05 04:25:00 -04:00
\ . ' %s:t:r'
2018-06-14 06:31:12 -04:00
endfunction
function! ale_linters#mercury#mmc#Handle(buffer, lines) abort
" output format
" <filename>:<line>: <issue type>: <message>
let l:pattern = '\v^\w+\.m:(\d+):\s+([W|w]arning|.*[E|e]rror.*): (.*)'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': substitute(l:match[1], '\v^0*', '', '') + 0,
\ 'type': l:match[2][0] =~? 'W' ? 'W' : 'E',
\ 'text': l:match[2] . ': ' . l:match[3]
\})
endfor
return l:output
endfunction
call ale#linter#Define('mercury', {
\ 'name': 'mmc',
\ 'output_stream': 'stderr',
2019-03-08 06:04:56 -05:00
\ 'executable': {b -> ale#Var(b, 'mercury_mmc_executable')},
2021-05-05 04:25:00 -04:00
\ 'cwd': '%s:h',
2019-03-08 06:04:56 -05:00
\ 'command': function('ale_linters#mercury#mmc#GetCommand'),
2018-06-14 06:31:12 -04:00
\ 'callback': 'ale_linters#mercury#mmc#Handle',
\ 'lint_file': 1,
\})