diff options
author | w0rp <devw0rp@gmail.com> | 2017-06-25 17:08:57 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-06-25 17:08:57 +0100 |
commit | 93473a410139f4c094ae491e690bb22b40648214 (patch) | |
tree | 946fdc5ecb87dcd5e351ccc5b454121797ee63f1 /autoload | |
parent | 229a1c092a6f7d5116590bed2cf0e97ad63bbc7c (diff) | |
download | ale-93473a410139f4c094ae491e690bb22b40648214.zip |
Fix #690 - Filter out errors from other files for Haskell
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/handlers/haskell.vim | 15 | ||||
-rw-r--r-- | autoload/ale/path.vim | 21 |
2 files changed, 29 insertions, 7 deletions
diff --git a/autoload/ale/handlers/haskell.vim b/autoload/ale/handlers/haskell.vim index cfddbdbf..17d9d242 100644 --- a/autoload/ale/handlers/haskell.vim +++ b/autoload/ale/handlers/haskell.vim @@ -6,10 +6,11 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort " "Appoint/Lib.hs:8:1: warning: "Appoint/Lib.hs:8:1: - let l:pattern = '^[^:]\+:\(\d\+\):\(\d\+\):\(.*\)\?$' + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+):(.*)?$' let l:output = [] let l:corrected_lines = [] + for l:line in a:lines if len(matchlist(l:line, l:pattern)) > 0 call add(l:corrected_lines, l:line) @@ -30,21 +31,25 @@ function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort continue endif - let l:errors = matchlist(l:match[3], '\(warning:\|error:\)\(.*\)') + if !ale#path#IsBufferPath(a:buffer, l:match[1]) + continue + endif + + let l:errors = matchlist(l:match[4], '\(warning:\|error:\)\(.*\)') if len(l:errors) > 0 let l:type = l:errors[1] let l:text = l:errors[2] else let l:type = '' - let l:text = l:match[3] + let l:text = l:match[4] endif let l:type = l:type ==# '' ? 'E' : toupper(l:type[0]) call add(l:output, { - \ 'lnum': l:match[1] + 0, - \ 'col': l:match[2] + 0, + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, \ 'text': l:text, \ 'type': l:type, \}) diff --git a/autoload/ale/path.vim b/autoload/ale/path.vim index 2c1d5133..2a38d740 100644 --- a/autoload/ale/path.vim +++ b/autoload/ale/path.vim @@ -62,6 +62,23 @@ function! ale#path#IsAbsolute(filename) abort return a:filename[:0] ==# '/' || a:filename[1:2] ==# ':\' endfunction +" Given a filename, return 1 if the file represents some temporary file +" created by Vim. +function! ale#path#IsTempName(filename) abort + let l:prefix_list = [ + \ $TMPDIR, + \ '/run/user', + \] + + for l:prefix in l:prefix_list + if a:filename[:len(l:prefix) - 1] ==# l:prefix + return 1 + endif + endfor + + return 0 +endfunction + " Given a buffer number and a relative or absolute path, return 1 if the " two paths represent the same file on disk. function! ale#path#IsBufferPath(buffer, complex_filename) abort @@ -83,8 +100,8 @@ function! ale#path#IsBufferPath(buffer, complex_filename) abort let l:test_filename = substitute(l:test_filename, '\v^(\.\.[/\\])+', '/', '') endif - " Use the basename for files in /tmp, as they are likely our files. - if l:test_filename[:len($TMPDIR) - 1] ==# $TMPDIR + " Use the basename for temporary files, as they are likely our files. + if ale#path#IsTempName(l:test_filename) let l:test_filename = fnamemodify(l:test_filename, ':t') endif |