]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/handlers/vale.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 / vale.vim
1 " Author: Johannes Wienke <languitar@semipol.de>
2 " Description: output handler for the vale JSON format
3
4 function! ale#handlers#vale#GetType(severity) abort
5     if a:severity is? 'warning'
6         return 'W'
7     elseif a:severity is? 'suggestion'
8         return 'I'
9     endif
10
11     return 'E'
12 endfunction
13
14 function! ale#handlers#vale#Handle(buffer, lines) abort
15     try
16         let l:errors = json_decode(join(a:lines, ''))
17     catch
18         return []
19     endtry
20
21     if empty(l:errors)
22         return []
23     endif
24
25     let l:output = []
26
27     for l:error in l:errors[keys(l:errors)[0]]
28         call add(l:output, {
29         \   'lnum': l:error['Line'],
30         \   'col': l:error['Span'][0],
31         \   'end_col': l:error['Span'][1],
32         \   'code': l:error['Check'],
33         \   'text': l:error['Message'],
34         \   'type': ale#handlers#vale#GetType(l:error['Severity']),
35         \})
36     endfor
37
38     return l:output
39 endfunction