Skip to content

Commit 7c8d5a9

Browse files
committed
adjust default errorformat
Adjust the default error format to handle compilation errors when running `go vet`.
1 parent 925d29a commit 7c8d5a9

File tree

3 files changed

+43
-8
lines changed

3 files changed

+43
-8
lines changed

autoload/go/lint_test.vim

+29
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,35 @@ func! Test_Vet() abort
122122
endtry
123123
endfunc
124124

125+
func! Test_Vet_compilererror() abort
126+
let l:tmp = gotest#load_fixture('lint/src/vet/compilererror/compilererror.go')
127+
128+
try
129+
130+
let expected = [
131+
\ {'lnum': 6, 'bufnr': bufnr('%'), 'col': 22, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': "missing ',' before newline in argument list (and 1 more errors)"}
132+
\ ]
133+
134+
let winnr = winnr()
135+
136+
" clear the location lists
137+
call setqflist([], 'r')
138+
139+
call go#lint#Vet(1)
140+
141+
let actual = getqflist()
142+
let start = reltime()
143+
while len(actual) == 0 && reltimefloat(reltime(start)) < 10
144+
sleep 100m
145+
let actual = getqflist()
146+
endwhile
147+
148+
call gotest#assert_quickfix(actual, expected)
149+
finally
150+
call delete(l:tmp, 'rf')
151+
endtry
152+
endfunc
153+
125154
func! Test_Lint_GOPATH() abort
126155
let RestoreGOPATH = go#util#SetEnv('GOPATH', fnameescape(fnamemodify(getcwd(), ':p')) . 'test-fixtures/lint')
127156

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
fmt.Println("vim-go"
7+
}

compiler/go.vim

+7-8
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ endif
3131
" use a different output, for those we define them directly and modify the
3232
" errorformat ourselves. More information at:
3333
" http://vimdoc.sourceforge.net/htmldoc/quickfix.html#errorformat
34-
CompilerSet errorformat =%-G#\ %.%# " Ignore lines beginning with '#' ('# command-line-arguments' line sometimes appears?)
35-
CompilerSet errorformat+=%-G%.%#panic:\ %m " Ignore lines containing 'panic: message'
36-
CompilerSet errorformat+=%Ecan\'t\ load\ package:\ %m " Start of multiline error string is 'can\'t load package'
37-
CompilerSet errorformat+=%A%f:%l:%c:\ %m " Start of multiline unspecified string is 'filename:linenumber:columnnumber:'
38-
CompilerSet errorformat+=%A%f:%l:\ %m " Start of multiline unspecified string is 'filename:linenumber:'
39-
CompilerSet errorformat+=%C%*\\s%m " Continuation of multiline error message is indented
40-
CompilerSet errorformat+=%-G%.%# " All lines not matching any of the above patterns are ignored
41-
34+
CompilerSet errorformat =%-G#\ %.%# " Ignore lines beginning with '#' ('# command-line-arguments' line sometimes appears?)
35+
CompilerSet errorformat+=%-G%.%#panic:\ %m " Ignore lines containing 'panic: message'
36+
CompilerSet errorformat+=%Ecan\'t\ load\ package:\ %m " Start of multiline error string is 'can\'t load package'
37+
CompilerSet errorformat+=%A%\\%%(%[%^:]%\\+:\ %\\)%\\?%f:%l:%c:\ %m " Start of multiline unspecified string is 'filename:linenumber:columnnumber:'
38+
CompilerSet errorformat+=%A%\\%%(%[%^:]%\\+:\ %\\)%\\?%f:%l:\ %m " Start of multiline unspecified string is 'filename:linenumber:'
39+
CompilerSet errorformat+=%C%*\\s%m " Continuation of multiline error message is indented
40+
CompilerSet errorformat+=%-G%.%# " All lines not matching any of the above patterns are ignored
4241
let &cpo = s:save_cpo
4342
unlet s:save_cpo
4443

0 commit comments

Comments
 (0)