summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-04-05 12:34:45 +0100
committerGitHub <noreply@github.com>2018-04-05 12:34:45 +0100
commit8baab691e9bba61d928388572725b72aa5ce9268 (patch)
treeb83a28e7ba5563bc8c31e9d7b1993bd625cd9717 /ale_linters
parent95ec9bb780198d0ebc0f175debc286b43dd5fc27 (diff)
parent8d4852a127d9f4d9793f8ee585fdb18a916aa7e9 (diff)
downloadale-8baab691e9bba61d928388572725b72aa5ce9268.zip
Merge pull request #1429 from stewy33/master
Add support for Mercury language using mmc as a linter.
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/mercury/mmc.vim45
1 files changed, 45 insertions, 0 deletions
diff --git a/ale_linters/mercury/mmc.vim b/ale_linters/mercury/mmc.vim
new file mode 100644
index 00000000..c7bfc59d
--- /dev/null
+++ b/ale_linters/mercury/mmc.vim
@@ -0,0 +1,45 @@
+" 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#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'mercury_mmc_executable')
+endfunction
+
+function! ale_linters#mercury#mmc#GetCommand(buffer) abort
+ let l:module_name = expand('#' . a:buffer . ':t:r')
+
+ return ale#path#BufferCdString(a:buffer)
+ \ . ale_linters#mercury#mmc#GetExecutable(a:buffer)
+ \ . ' --errorcheck-only '
+ \ . ale#Var(a:buffer, 'mercury_mmc_options')
+ \ . ' ' . l:module_name
+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',
+\ 'executable_callback': 'ale_linters#mercury#mmc#GetExecutable',
+\ 'command_callback': 'ale_linters#mercury#mmc#GetCommand',
+\ 'callback': 'ale_linters#mercury#mmc#Handle',
+\ 'lint_file': 1,
+\})