]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/thrift/thriftcheck.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:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / ale_linters / thrift / thriftcheck.vim
1 " Author: Jon Parise <jon@indelible.org>
2
3 call ale#Set('thrift_thriftcheck_executable', 'thriftcheck')
4 call ale#Set('thrift_thriftcheck_options', '')
5
6 function! ale_linters#thrift#thriftcheck#GetCommand(buffer) abort
7     return '%e'
8     \   . ale#Pad(ale#Var(a:buffer, 'thrift_thriftcheck_options'))
9     \   . ' --stdin-filename %s'
10     \   . ' %t'
11 endfunction
12
13 function! ale_linters#thrift#thriftcheck#Handle(buffer, lines) abort
14     " Matches lines like the following:
15     "
16     " file.thrift:1:1: error: "py" namespace must match "^idl\\." (namespace.pattern)
17     " file.thrift:3:5: warning: 64-bit integer constant -2147483649 may not work in all languages (int.64bit)
18     let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+): ?([^:]+): (.+) \(([^\)]+)\)$'
19
20     let l:output = []
21
22     for l:match in ale#util#GetMatches(a:lines, l:pattern)
23         if l:match[3] is# 'warning'
24             let l:type = 'W'
25         else
26             let l:type = 'E'
27         endif
28
29         call add(l:output, {
30         \   'lnum': l:match[1] + 0,
31         \   'col': l:match[2] + 0,
32         \   'type': l:type,
33         \   'text': l:match[4],
34         \   'code': l:match[5],
35         \})
36     endfor
37
38     return l:output
39 endfunction
40
41 call ale#linter#Define('thrift', {
42 \   'name': 'thriftcheck',
43 \   'executable': {b -> ale#Var(b, 'thrift_thriftcheck_executable')},
44 \   'command': function('ale_linters#thrift#thriftcheck#GetCommand'),
45 \   'callback': 'ale_linters#thrift#thriftcheck#Handle',
46 \})