summaryrefslogtreecommitdiff
path: root/ale_linters/haskell
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-07-18 13:14:02 +0100
committerw0rp <devw0rp@gmail.com>2017-07-18 13:14:02 +0100
commitaa94d0902a557bc8d65b51a868cf1e122edd2306 (patch)
tree0c632c55dba2e8464b57687a0e8713e657ba9c3d /ale_linters/haskell
parent5a6ffc2804597e3b2a0ee2f6a9d5e8f52ec4c65b (diff)
downloadale-aa94d0902a557bc8d65b51a868cf1e122edd2306.zip
Fix #710 - Show hlint suggestions as info items, and include end line and column numbers
Diffstat (limited to 'ale_linters/haskell')
-rw-r--r--ale_linters/haskell/hlint.vim21
1 files changed, 17 insertions, 4 deletions
diff --git a/ale_linters/haskell/hlint.vim b/ale_linters/haskell/hlint.vim
index 77952cf4..accae374 100644
--- a/ale_linters/haskell/hlint.vim
+++ b/ale_linters/haskell/hlint.vim
@@ -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