diff options
author | Johannes Wienke <languitar@semipol.de> | 2017-12-17 16:49:57 +0100 |
---|---|---|
committer | Johannes Wienke <languitar@semipol.de> | 2017-12-17 16:49:57 +0100 |
commit | 96b90b45db5070c964adb14f1a0ac67c61571648 (patch) | |
tree | ca4986326a7b316b49f7710b3a7638842fee0ff5 /autoload | |
parent | c4956657dc519aaae679b5a04af9b63b0aacabbe (diff) | |
download | ale-96b90b45db5070c964adb14f1a0ac67c61571648.zip |
Use JSON output with vale
Switches all vale instances to JSON output and provides an appropriate
handler for that. Without JSON, no end_col is provided and text
highlighting only catches the first character of every result.
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/handlers/vale.vim | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/autoload/ale/handlers/vale.vim b/autoload/ale/handlers/vale.vim new file mode 100644 index 00000000..c8420572 --- /dev/null +++ b/autoload/ale/handlers/vale.vim @@ -0,0 +1,36 @@ +" Author: Johannes Wienke <languitar@semipol.de> +" Description: output handler for the vale JSON format + +function! ale#handlers#vale#GetType(severity) abort + if a:severity is? 'warning' + return 'W' + endif + + return 'E' +endfunction + +function! ale#handlers#vale#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 = [] + for l:error in l:errors[keys(l:errors)[0]] + call add(l:output, { + \ 'lnum': l:error['Line'], + \ 'col': l:error['Span'][0], + \ 'end_col': l:error['Span'][1], + \ 'code': l:error['Check'], + \ 'text': l:error['Message'], + \ 'type': ale#handlers#vale#GetType(l:error['Severity']), + \}) + endfor + + return l:output +endfunction |