Fix #710 - Show hlint suggestions as info items, and include end line and column numbers

This commit is contained in:
w0rp
2017-07-18 13:14:02 +01:00
parent 5a6ffc2804
commit aa94d0902a
2 changed files with 97 additions and 4 deletions

View File

@@ -2,17 +2,30 @@
" Description: hlint for Haskell files
function! ale_linters#haskell#hlint#Handle(buffer, lines) abort
if empty(a:lines)
return []
endif
let l:errors = json_decode(join(a:lines, ''))
let l:output = []
for l:error in l:errors
if l:error.severity ==# 'Error'
let l:type = 'E'
elseif l:error.severity ==# 'Suggestion'
let l:type = 'I'
else
let l:type = 'W'
endif
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:error.startLine + 0,
\ 'col': l:error.startColumn + 0,
\ 'lnum': str2nr(l:error.startLine),
\ 'col': str2nr(l:error.startColumn),
\ 'end_lnum': str2nr(l:error.endLine),
\ 'end_col': str2nr(l:error.endColumn),
\ 'text': l:error.severity . ': ' . l:error.hint . '. Found: ' . l:error.from . ' Why not: ' . l:error.to,
\ 'type': l:error.severity ==# 'Error' ? 'E' : 'W',
\ 'type': l:type,
\})
endfor