diff options
author | w0rp <devw0rp@gmail.com> | 2017-07-07 00:28:22 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-07-07 00:28:22 +0100 |
commit | 130928590b3b0afac75a15393ff4d30278e3df15 (patch) | |
tree | b0374460a016f0e10adb7677d451da32c3827d1c | |
parent | 8315c0e3377921435af06a3182bdc0f1f0f222fc (diff) | |
download | ale-130928590b3b0afac75a15393ff4d30278e3df15.zip |
#710 - Show warnings as warnings for ghc
-rw-r--r-- | autoload/ale/handlers/haskell.vim | 14 | ||||
-rw-r--r-- | test/handler/test_ghc_handler.vader | 21 |
2 files changed, 27 insertions, 8 deletions
diff --git a/autoload/ale/handlers/haskell.vim b/autoload/ale/handlers/haskell.vim index 17d9d242..bd2414a8 100644 --- a/autoload/ale/handlers/haskell.vim +++ b/autoload/ale/handlers/haskell.vim @@ -35,17 +35,21 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort continue endif - let l:errors = matchlist(l:match[4], '\(warning:\|error:\)\(.*\)') + let l:errors = matchlist(l:match[4], '\v([wW]arning|[eE]rror): ?(.*)') if len(l:errors) > 0 - let l:type = l:errors[1] + let l:ghc_type = l:errors[1] let l:text = l:errors[2] else - let l:type = '' - let l:text = l:match[4] + let l:ghc_type = '' + let l:text = l:match[4][:0] ==# ' ' ? l:match[4][1:] : l:match endif - let l:type = l:type ==# '' ? 'E' : toupper(l:type[0]) + if l:ghc_type ==? 'Warning' + let l:type = 'W' + else + let l:type = 'E' + endif call add(l:output, { \ 'lnum': l:match[2] + 0, diff --git a/test/handler/test_ghc_handler.vader b/test/handler/test_ghc_handler.vader index 524f08b7..bf54386e 100644 --- a/test/handler/test_ghc_handler.vader +++ b/test/handler/test_ghc_handler.vader @@ -25,13 +25,13 @@ Execute(The ghc handler should handle ghc 8 output): \ 'lnum': 6, \ 'type': 'E', \ 'col': 1, - \ 'text': ' Failed to load interface for ‘GitHub.Data’ Use -v to see a list of the files searched for.', + \ 'text': 'Failed to load interface for ‘GitHub.Data’ Use -v to see a list of the files searched for.', \ }, \ { \ 'lnum': 7, \ 'type': 'W', \ 'col': 1, - \ 'text': ' Failed to load interface for ‘GitHub.Endpoints.PullRequests’ Use -v to see a list of the files searched for.', + \ 'text': 'Failed to load interface for ‘GitHub.Endpoints.PullRequests’ Use -v to see a list of the files searched for.', \ }, \ ], \ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [ @@ -54,10 +54,25 @@ Execute(The ghc handler should handle ghc 7 output): \ 'lnum': 168, \ 'type': 'E', \ 'col': 1, - \ 'text': ' parse error (possibly incorrect indentation or mismatched brackets)', + \ 'text': 'parse error (possibly incorrect indentation or mismatched brackets)', + \ }, + \ { + \ 'lnum': 84, + \ 'col': 1, + \ 'type': 'W', + \ 'text': 'Top-level binding with no type signature:^@ myLayout :: Choose Tall (Choose (Mirror Tall) Full) a', + \ }, + \ { + \ 'lnum': 94, + \ 'col': 5, + \ 'type': 'E', + \ 'text': 'Some other error', \ }, \ ], \ ale#handlers#haskell#HandleGHCFormat(bufnr(''), [ \ 'src/Main.hs:168:1:', \ ' parse error (possibly incorrect indentation or mismatched brackets)', + \ 'src/Main.hs:84:1:Warning: Top-level binding with no type signature:^@ myLayout :: Choose Tall (Choose (Mirror Tall) Full) a', + \ 'src/Main.hs:94:5:Error:', + \ ' Some other error', \ ]) |