]> git.madduck.net Git - etc/vim.git/blob - ale_linters/erlang/syntaxerl.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 / erlang / syntaxerl.vim
1 " Author: Dmitri Vereshchagin <dmitri.vereshchagin@gmail.com>
2 " Description: SyntaxErl linter for Erlang files
3
4 call ale#Set('erlang_syntaxerl_executable', 'syntaxerl')
5
6 function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort
7     let l:pattern = '\v\C:(\d+):( warning:)? (.+)'
8     let l:loclist = []
9
10     for l:match in ale#util#GetMatches(a:lines, l:pattern)
11         call add(l:loclist, {
12         \   'lnum': str2nr(l:match[1]),
13         \   'text': l:match[3],
14         \   'type': empty(l:match[2]) ? 'E' : 'W',
15         \})
16     endfor
17
18     return l:loclist
19 endfunction
20
21 function! s:GetExecutable(buffer) abort
22     return ale#Var(a:buffer, 'erlang_syntaxerl_executable')
23 endfunction
24
25 function! s:GetCommand(buffer) abort
26     let l:Callback = function('s:GetCommandFromHelpOutput')
27
28     return ale#command#Run(a:buffer, '%e -h', l:Callback, {
29     \   'executable': s:GetExecutable(a:buffer),
30     \})
31 endfunction
32
33 function! s:GetCommandFromHelpOutput(buffer, output, metadata) abort
34     let l:has_b_option = match(a:output, '\V\C-b, --base\>') > -1
35
36     return l:has_b_option ? '%e -b %s %t' : '%e %t'
37 endfunction
38
39 call ale#linter#Define('erlang', {
40 \   'name': 'syntaxerl',
41 \   'callback': 'ale_linters#erlang#syntaxerl#Handle',
42 \   'executable': function('s:GetExecutable'),
43 \   'command': function('s:GetCommand'),
44 \})