summaryrefslogtreecommitdiff
path: root/ale_linters/go/gobuild.vim
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-04-29 17:33:18 +0100
committerw0rp <devw0rp@gmail.com>2017-04-29 17:33:18 +0100
commit0b4acd645395d4196f2e346d65aeddf063927f4e (patch)
tree2701b1faefec6e1cc2dbfd5775d3bf94c6a5e022 /ale_linters/go/gobuild.vim
parentcbb01e32b950f4a5c14d56b41759945662b2db49 (diff)
downloadale-0b4acd645395d4196f2e346d65aeddf063927f4e.zip
Fix #518 Fix handling of spaces in filenames for various linters
Diffstat (limited to 'ale_linters/go/gobuild.vim')
-rw-r--r--ale_linters/go/gobuild.vim29
1 files changed, 13 insertions, 16 deletions
diff --git a/ale_linters/go/gobuild.vim b/ale_linters/go/gobuild.vim
index 419e67a0..62687534 100644
--- a/ale_linters/go/gobuild.vim
+++ b/ale_linters/go/gobuild.vim
@@ -25,35 +25,32 @@ function! ale_linters#go#gobuild#GetCommand(buffer, goenv_output) abort
\ . ' && go test -c -o /dev/null ./'
endfunction
-function! ale_linters#go#gobuild#Handler(buffer, lines) abort
- return ale_linters#go#gobuild#HandleGoBuildErrors(a:buffer, bufname(a:buffer), a:lines)
-endfunction
-
-function! ale_linters#go#gobuild#HandleGoBuildErrors(buffer, full_filename, lines) abort
- " Matches patterns line the following:
+function! ale_linters#go#gobuild#GetMatches(lines) abort
+ " Matches patterns like the following:
"
" file.go:27: missing argument for Printf("%s"): format reads arg 2, have only 1 args
" file.go:53:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
" file.go:5:2: expected declaration, found 'STRING' "log"
" go test returns relative paths so use tail of filename as part of pattern matcher
- let l:filename = fnamemodify(a:full_filename, ':t')
- let l:path_pattern = '[a-zA-Z]\?\\\?:\?[[:alnum:]/\.\-_]\+'
- let l:pattern = '^' . l:path_pattern . ':\(\d\+\):\?\(\d\+\)\?:\? \(.\+\)$'
- let l:output = []
+ let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:? (.+)$'
- for l:line in a:lines
- let l:match = matchlist(l:line, l:pattern)
+ return ale#util#GetMatches(a:lines, l:pattern)
+endfunction
+
+function! ale_linters#go#gobuild#Handler(buffer, lines) abort
+ let l:output = []
+ for l:match in ale_linters#go#gobuild#GetMatches(a:lines)
" Omit errors from imported go packages
- if len(l:match) == 0 || l:line !~ l:filename
+ if ale#path#IsBufferPath(a:buffer, l:match[0])
continue
endif
call add(l:output, {
- \ 'lnum': l:match[1] + 0,
- \ 'col': l:match[2] + 0,
- \ 'text': l:match[3],
+ \ 'lnum': l:match[2] + 0,
+ \ 'col': l:match[3] + 0,
+ \ 'text': l:match[4],
\ 'type': 'E',
\})
endfor