]> git.madduck.net Git - etc/vim.git/blob - ale_linters/mercury/mmc.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / ale_linters / mercury / mmc.vim
1 " Author: stewy33 <slocumstewy@gmail.com>
2 " Description: Lints mercury files using mmc
3
4 call ale#Set('mercury_mmc_executable', 'mmc')
5 call ale#Set('mercury_mmc_options', '--make --output-compile-error-lines 100')
6
7 function! ale_linters#mercury#mmc#GetCommand(buffer) abort
8     return '%e --errorcheck-only '
9     \ . ale#Var(a:buffer, 'mercury_mmc_options')
10     \ . ' %s:t:r'
11 endfunction
12
13 function! ale_linters#mercury#mmc#Handle(buffer, lines) abort
14     " output format
15     " <filename>:<line>:   <issue type>: <message>
16     let l:pattern = '\v^\w+\.m:(\d+):\s+([W|w]arning|.*[E|e]rror.*): (.*)'
17     let l:output = []
18
19     for l:match in ale#util#GetMatches(a:lines, l:pattern)
20         call add(l:output, {
21         \   'lnum': substitute(l:match[1], '\v^0*', '', '') + 0,
22         \   'type': l:match[2][0] =~? 'W' ? 'W' : 'E',
23         \   'text': l:match[2] . ': ' . l:match[3]
24         \})
25     endfor
26
27     return l:output
28 endfunction
29
30 call ale#linter#Define('mercury', {
31 \   'name': 'mmc',
32 \   'output_stream': 'stderr',
33 \   'executable': {b -> ale#Var(b, 'mercury_mmc_executable')},
34 \   'cwd': '%s:h',
35 \   'command': function('ale_linters#mercury#mmc#GetCommand'),
36 \   'callback': 'ale_linters#mercury#mmc#Handle',
37 \   'lint_file': 1,
38 \})