]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/handlers/atools.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] / autoload / ale / handlers / atools.vim
1 " Author: Leo <thinkabit.ukim@gmail.com>
2 " Description: Handlers for output expected from atools
3
4 function! ale#handlers#atools#Handle(buffer, lines) abort
5     " Format: SEVERITY:[TAG]:PATH:LINENUM:MSG
6     " Example: MC:[AL5]:./APKBUILD:12:variable set to empty string: install=
7     let l:pattern = '\([^:]\+\):\([^:]\+\):\([^:]\+\):\(\d\+\):\(.\+\)$'
8     let l:output = []
9
10     for l:match in ale#util#GetMatches(a:lines, l:pattern)
11         " We are expected to receive 2 characters, the first character
12         " can be 'S', 'I', 'M' 'T', which are respectively:
13         " Serious (Error)
14         " Important (Error)
15         " Minor (Warning)
16         " Style (Warning)
17         "
18         " The second character can be either 'C' or 'P', which are respectively:
19         " Certain (Error)
20         " Possible (Warning)
21         let l:severity = matchstr(l:match[1], '^.')
22         let l:certainty = matchstr(l:match[1], '.$')
23
24         let l:type = 'E'
25         " If the tag returns 'Minor' or 'Style' or is 'Possible'
26         " then return a warning
27
28         if l:severity is# 'M' || l:severity is# 'T' || l:certainty is# 'P'
29             let l:type = 'W'
30         endif
31
32         call add(l:output, {
33         \    'lnum': l:match[4] + 0,
34         \    'text': l:match[5],
35         \    'type': l:type,
36         \    'code': matchstr(l:match[2], 'AL[0-9]*'),
37         \})
38     endfor
39
40     return l:output
41 endfunction