]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/haskell/hlint.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:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / ale_linters / haskell / hlint.vim
1 " Author: jparoz <jesse.paroz@gmail.com>
2 " Description: hlint for Haskell files
3
4 call ale#Set('haskell_hlint_executable', 'hlint')
5 call ale#Set('haskell_hlint_options', get(g:, 'hlint_options', ''))
6
7 function! ale_linters#haskell#hlint#Handle(buffer, lines) abort
8     let l:output = []
9
10     for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
11         if l:error.severity is# 'Error'
12             let l:type = 'E'
13         elseif l:error.severity is# 'Suggestion'
14             let l:type = 'I'
15         else
16             let l:type = 'W'
17         endif
18
19         call add(l:output, {
20         \   'lnum': str2nr(l:error.startLine),
21         \   'col': str2nr(l:error.startColumn),
22         \   'end_lnum': str2nr(l:error.endLine),
23         \   'end_col': str2nr(l:error.endColumn),
24         \   'text': l:error.severity . ': ' . l:error.hint . '. Found: ' . l:error.from . ' Why not: ' . l:error.to,
25         \   'type': l:type,
26         \})
27     endfor
28
29     return l:output
30 endfunction
31
32 function! ale_linters#haskell#hlint#GetCommand(buffer) abort
33     let l:hlintopts = '--color=never --json'
34
35     return ale#handlers#hlint#GetExecutable(a:buffer)
36     \      . ' ' . ale#Var(a:buffer, 'haskell_hlint_options')
37     \      . ' ' . l:hlintopts
38     \      . ' -'
39 endfunction
40
41 call ale#linter#Define('haskell', {
42 \   'name': 'hlint',
43 \   'executable': {b -> ale#Var(b, 'haskell_hlint_executable')},
44 \   'command': function('ale_linters#haskell#hlint#GetCommand') ,
45 \   'callback': 'ale_linters#haskell#hlint#Handle',
46 \})