]> git.madduck.net Git - etc/vim.git/blob - ale_linters/yaml/gitlablint.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 / yaml / gitlablint.vim
1 call ale#Set('yaml_gitlablint_executable', 'gll')
2 call ale#Set('yaml_gitlablint_options', '')
3
4 function! ale_linters#yaml#gitlablint#GetCommand(buffer) abort
5     return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_gitlablint_options'))
6     \   . ' -p %t'
7 endfunction
8
9 function! ale_linters#yaml#gitlablint#Handle(buffer, lines) abort
10     " Matches patterns line the following:
11     " (<unknown>): mapping values are not allowed in this context at line 68 column 8
12     " jobs:build:dev config contains unknown keys: ony
13     let l:pattern = '^\(.*\) at line \(\d\+\) column \(\d\+\)$'
14     let l:output = []
15
16     for l:line in a:lines
17         let l:match = matchlist(l:line, l:pattern)
18
19         if !empty(l:match)
20             let l:item = {
21             \   'lnum': l:match[2] + 0,
22             \   'col': l:match[3] + 0,
23             \   'text': l:match[1],
24             \   'type': 'E',
25             \}
26             call add(l:output, l:item)
27         else
28             if l:line isnot# 'GitLab CI configuration is invalid'
29                 let l:item = {
30                 \   'lnum': 0,
31                 \   'col': 0,
32                 \   'text': l:line,
33                 \   'type': 'E',
34                 \}
35                 call add(l:output, l:item)
36             endif
37         endif
38     endfor
39
40     return l:output
41 endfunction
42
43 call ale#linter#Define('yaml', {
44 \   'name': 'gitlablint',
45 \   'executable': {b -> ale#Var(b, 'yaml_gitlablint_executable')},
46 \   'command': function('ale_linters#yaml#gitlablint#GetCommand'),
47 \   'callback': 'ale_linters#yaml#gitlablint#Handle',
48 \   'output_stream': 'stderr',
49 \})