]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/handlers/spectral.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 / spectral.vim
1 " Author: t2h5 <https://github.com/t2h5>
2 " Description: Integration of Stoplight Spectral CLI with ALE.
3
4 function! ale#handlers#spectral#HandleSpectralOutput(buffer, lines) abort
5     " Matches patterns like the following:
6     " openapi.yml:1:1 error oas3-schema "Object should have required property `info`."
7     " openapi.yml:1:1 warning oas3-api-servers "OpenAPI `servers` must be present and non-empty array."
8     let l:pattern = '\v^.*:(\d+):(\d+) (error|warning) (.*)$'
9     let l:output = []
10
11     for l:match in ale#util#GetMatches(a:lines, l:pattern)
12         let l:obj = {
13         \   'lnum': l:match[1] + 0,
14         \   'col': l:match[2] + 0,
15         \   'type': l:match[3] is# 'error' ? 'E' : 'W',
16         \   'text': l:match[4],
17         \}
18
19         let l:code_match = matchlist(l:obj.text, '\v^(.+) "(.+)"$')
20
21         if !empty(l:code_match)
22             let l:obj.code = l:code_match[1]
23             let l:obj.text = l:code_match[2]
24         endif
25
26         call add(l:output, l:obj)
27     endfor
28
29     return l:output
30 endfunction
31