]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/handlers/yamllint.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 / yamllint.vim
1 function! ale#handlers#yamllint#GetCommand(buffer) abort
2     return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_yamllint_options'))
3     \   . ' -f parsable %t'
4 endfunction
5
6 function! ale#handlers#yamllint#Handle(buffer, lines) abort
7     " Matches patterns line the following:
8     " something.yaml:1:1: [warning] missing document start "---" (document-start)
9     " something.yml:2:1: [error] syntax error: expected the node content, but found '<stream end>'
10     let l:pattern = '\v^.*:(\d+):(\d+): \[(error|warning)\] (.+)$'
11     let l:output = []
12
13     for l:match in ale#util#GetMatches(a:lines, l:pattern)
14         let l:item = {
15         \   'lnum': l:match[1] + 0,
16         \   'col': l:match[2] + 0,
17         \   'text': l:match[4],
18         \   'type': l:match[3] is# 'error' ? 'E' : 'W',
19         \}
20
21         let l:code_match = matchlist(l:item.text, '\v^(.+) \(([^)]+)\)$')
22
23         if !empty(l:code_match)
24             if l:code_match[2] is# 'trailing-spaces'
25             \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
26                 " Skip warnings for trailing whitespace if the option is off.
27                 continue
28             endif
29
30             let l:item.text = l:code_match[1]
31             let l:item.code = l:code_match[2]
32         endif
33
34         call add(l:output, l:item)
35     endfor
36
37     return l:output
38 endfunction
39