diff options
author | w0rp <w0rp@users.noreply.github.com> | 2017-07-16 15:06:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-16 15:06:55 +0100 |
commit | bd5ff5b1e52723c910f083bb4b37bad6a410900d (patch) | |
tree | 5af64ed202016f484517cd3c76f83dbead40cfc7 /ale_linters/erlang/syntaxerl.vim | |
parent | 7d174b00561f2cb6a6ad71b839b1b6fc6bd88e3b (diff) | |
parent | 1aea6a34ff22c9e79d20a018b4d46000c208caf2 (diff) | |
download | ale-bd5ff5b1e52723c910f083bb4b37bad6a410900d.zip |
Merge pull request #774 from dmitrivereshchagin/syntaxerl-linter
Add SyntaxErl linter
Diffstat (limited to 'ale_linters/erlang/syntaxerl.vim')
-rw-r--r-- | ale_linters/erlang/syntaxerl.vim | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/ale_linters/erlang/syntaxerl.vim b/ale_linters/erlang/syntaxerl.vim new file mode 100644 index 00000000..dd53d8e8 --- /dev/null +++ b/ale_linters/erlang/syntaxerl.vim @@ -0,0 +1,38 @@ +" 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 + + +function! ale_linters#erlang#syntaxerl#GetCommand(buffer) abort + return ale_linters#erlang#syntaxerl#GetExecutable(a:buffer) . ' %t' +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 + + +call ale#linter#Define('erlang', { +\ 'name': 'syntaxerl', +\ 'executable_callback': 'ale_linters#erlang#syntaxerl#GetExecutable', +\ 'command_callback': 'ale_linters#erlang#syntaxerl#GetCommand', +\ 'callback': 'ale_linters#erlang#syntaxerl#Handle', +\}) |