1- if ! exists (" g:go_jump_to_error" )
2- let g: go_jump_to_error = 1
3- endif
4-
51if ! exists (" g:go_dispatch_enabled" )
62 let g: go_dispatch_enabled = 0
73endif
@@ -36,16 +32,15 @@ function! go#cmd#Build(bang, ...)
3632 silent ! exe ' make!'
3733 endif
3834 redraw !
39- if ! a: bang
40- cwindow
41- let errors = getqflist ()
42- if ! empty (errors)
43- if g: go_jump_to_error
44- cc 1 " jump to first error if there is any
45- endif
46- else
47- redraws ! | echon " vim-go: " | echohl Function | echon " [build] SUCCESS" | echohl None
35+
36+ cwindow
37+ let errors = getqflist ()
38+ if ! empty (errors)
39+ if ! a: bang
40+ cc 1 " jump to first error if there is any
4841 endif
42+ else
43+ redraws ! | echon " vim-go: " | echohl Function | echon " [build] SUCCESS" | echohl None
4944 endif
5045
5146 let &makeprg = default_makeprg
@@ -86,14 +81,11 @@ function! go#cmd#Run(bang, ...)
8681 else
8782 exe ' make!'
8883 endif
89- if ! a: bang
90- cwindow
91- let errors = getqflist ()
92- if ! empty (errors)
93- if g: go_jump_to_error
94- cc 1 " jump to first error if there is any
95- endif
96- endif
84+
85+ cwindow
86+ let errors = getqflist ()
87+ if ! empty (errors) && ! a: bang
88+ cc 1 " jump to first error if there is any
9789 endif
9890
9991 let $GOPATH = old_gopath
@@ -103,7 +95,7 @@ endfunction
10395" Install installs the package by simple calling 'go install'. If any argument
10496" is given(which are passed directly to 'go insta'') it tries to install those
10597" packages. Errors are populated in the quickfix window.
106- function ! go#cmd#Install (... )
98+ function ! go#cmd#Install (bang , ... )
10799 let pkgs = join (a: 000 , ' " "' )
108100 let command = ' go install "' . pkgs . ' "'
109101 call go#cmd#autowrite ()
@@ -112,10 +104,8 @@ function! go#cmd#Install(...)
112104 call go#tool#ShowErrors (out)
113105 cwindow
114106 let errors = getqflist ()
115- if ! empty (errors)
116- if g: go_jump_to_error
117- cc 1 " jump to first error if there is any
118- endif
107+ if ! empty (errors) && ! a: bang
108+ cc 1 " jump to first error if there is any
119109 endif
120110 return
121111 endif
@@ -126,7 +116,7 @@ endfunction
126116" Test runs `go test` in the current directory. If compile is true, it'll
127117" compile the tests instead of running them (useful to catch errors in the
128118" test files). Any other argument is appendend to the final `go test` command
129- function ! go#cmd#Test (compile, ... )
119+ function ! go#cmd#Test (bang , compile, ... )
130120 let command = " go test "
131121
132122 " don't run the test, only compile it. Useful to capture and fix errors or
@@ -156,10 +146,8 @@ function! go#cmd#Test(compile, ...)
156146 call go#tool#ShowErrors (out)
157147 cwindow
158148 let errors = getqflist ()
159- if ! empty (errors)
160- if g: go_jump_to_error
161- cc 1 " jump to first error if there is any
162- endif
149+ if ! empty (errors) && ! a: bang
150+ cc 1 " jump to first error if there is any
163151 endif
164152 echon " vim-go: " | echohl ErrorMsg | echon " [test] FAIL" | echohl None
165153 else
@@ -176,7 +164,7 @@ endfunction
176164
177165" Testfunc runs a single test that surrounds the current cursor position.
178166" Arguments are passed to the `go test` command.
179- function ! go#cmd#TestFunc (... )
167+ function ! go#cmd#TestFunc (bang , ... )
180168 " search flags legend (used only)
181169 " 'b' search backward instead of forward
182170 " 'c' accept a match at the cursor position
@@ -204,12 +192,12 @@ function! go#cmd#TestFunc(...)
204192 let flag = " " . flag
205193 endif
206194
207- call go#cmd#Test (0 , a1, flag)
195+ call go#cmd#Test (a: bang , 0 , a1, flag)
208196endfunction
209197
210198" Coverage creates a new cover profile with 'go test -coverprofile' and opens
211199" a new HTML coverage page from that profile.
212- function ! go#cmd#Coverage (... )
200+ function ! go#cmd#Coverage (bang , ... )
213201 let l: tmpname= tempname ()
214202
215203 let command = " go test -coverprofile=" .l: tmpname
@@ -226,20 +214,16 @@ function! go#cmd#Coverage(...)
226214 call go#tool#ExecuteInDir (openHTML)
227215 endif
228216 cwindow
229-
230217 let errors = getqflist ()
231- if ! empty (errors)
232- if g: go_jump_to_error
233- cc 1 " jump to first error if there is any
234- endif
218+ if ! empty (errors) && ! a: bang
219+ cc 1 " jump to first error if there is any
235220 endif
236-
237221 call delete (l: tmpname )
238222endfunction
239223
240224" Vet calls "go vet' on the current directory. Any warnings are populated in
241225" the quickfix window
242- function ! go#cmd#Vet ()
226+ function ! go#cmd#Vet (bang )
243227 call go#cmd#autowrite ()
244228 echon " vim-go: " | echohl Identifier | echon " calling vet..." | echohl None
245229 let out = go#tool#ExecuteInDir (' go vet' )
@@ -248,11 +232,10 @@ function! go#cmd#Vet()
248232 else
249233 call setqflist ([])
250234 endif
251- cwindow
252235
253236 let errors = getqflist ()
254- if ! empty (errors)
255- if g: go_jump_to_error
237+ if ! empty (errors)
238+ if ! a: bang
256239 cc 1 " jump to first error if there is any
257240 endif
258241 else
0 commit comments