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