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

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / ale_linters / openapi / ibm_validator.vim
1 " Author: Horacio Sanson <hsanson@gmail.com>
2
3 call ale#Set('openapi_ibm_validator_executable', 'lint-openapi')
4 call ale#Set('openapi_ibm_validator_options', '')
5
6 function! ale_linters#openapi#ibm_validator#GetCommand(buffer) abort
7     return '%e' . ale#Pad(ale#Var(a:buffer, 'openapi_ibm_validator_options'))
8     \ . ' %t'
9 endfunction
10
11 function! ale_linters#openapi#ibm_validator#Handle(buffer, lines) abort
12     let l:output = []
13     let l:type = 'E'
14     let l:message = ''
15     let l:nr = -1
16
17     for l:line in a:lines
18         let l:match = matchlist(l:line, '^errors$')
19
20         if !empty(l:match)
21             let l:type = 'E'
22         endif
23
24         let l:match = matchlist(l:line, '^warnings$')
25
26         if !empty(l:match)
27             let l:type = 'W'
28         endif
29
30         let l:match = matchlist(l:line, '^ *Message : *\(.\+\)$')
31
32         if !empty(l:match)
33             let l:message = l:match[1]
34         endif
35
36         let l:match = matchlist(l:line, '^ *Line *: *\(\d\+\)$')
37
38         if !empty(l:match)
39             let l:nr = l:match[1]
40
41             call add(l:output, {
42             \   'lnum': l:nr + 0,
43             \   'col': 0,
44             \   'text': l:message,
45             \   'type': l:type,
46             \})
47         endif
48     endfor
49
50     return l:output
51 endfunction
52
53 call ale#linter#Define('openapi', {
54 \   'name': 'ibm_validator',
55 \   'executable': {b -> ale#Var(b, 'openapi_ibm_validator_executable')},
56 \   'command': function('ale_linters#openapi#ibm_validator#GetCommand'),
57 \   'callback': 'ale_linters#openapi#ibm_validator#Handle',
58 \})