]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/handlers/inko.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 / inko.vim
1 " Author: Yorick Peterse <yorick@yorickpeterse.com>
2 " Description: output handlers for the Inko JSON format
3
4 function! ale#handlers#inko#GetType(severity) abort
5     if a:severity is? 'warning'
6         return 'W'
7     endif
8
9     return 'E'
10 endfunction
11
12 function! ale#handlers#inko#Handle(buffer, lines) abort
13     try
14         let l:errors = json_decode(join(a:lines, ''))
15     catch
16         return []
17     endtry
18
19     if empty(l:errors)
20         return []
21     endif
22
23     let l:output = []
24     let l:dir = expand('#' . a:buffer . ':p:h')
25
26     for l:error in l:errors
27         call add(l:output, {
28         \   'filename': ale#path#GetAbsPath(l:dir, l:error['file']),
29         \   'lnum': l:error['line'],
30         \   'col': l:error['column'],
31         \   'text': l:error['message'],
32         \   'type': ale#handlers#inko#GetType(l:error['level']),
33         \})
34     endfor
35
36     return l:output
37 endfunction