@@ -146,56 +146,97 @@ endfunction
146
146
" Golint calls 'golint' on the current directory. Any warnings are populated in
147
147
" the location list
148
148
function ! go#lint#Golint (bang , ... ) abort
149
+ call go#cmd#autowrite ()
150
+
151
+ let l: type = ' golint'
152
+ let l: status = {
153
+ \ ' desc' : ' current status' ,
154
+ \ ' type' : l: type ,
155
+ \ ' state' : " started" ,
156
+ \ }
157
+ if go#config#EchoCommandInfo ()
158
+ call go#util#EchoProgress (printf (' [%s] analyzing...' , l: type ))
159
+ endif
160
+ call go#statusline#Update (expand (' %:p:h' ), l: status )
161
+
149
162
if a: 0 == 0
150
163
let [l: out , l: err ] = go#util#Exec ([go#config#GolintBin (), expand (' %:p:h' )])
151
164
else
152
165
let [l: out , l: err ] = go#util#Exec ([go#config#GolintBin ()] + a: 000 )
153
166
endif
154
167
155
- if empty (l: out )
156
- call go#util#EchoSuccess (' [lint] PASS' )
157
- return
158
- endif
168
+ let l: status .state = ' success'
169
+ let l: state = ' PASS'
170
+ if ! empty (l: out )
171
+ let l: status .state = ' failed'
172
+ let l: state = ' FAIL'
159
173
160
- let l: winid = win_getid (winnr ())
161
- let l: listtype = go#list#Type (" GoLint" )
162
- call go#list#Parse (l: listtype , l: out , " GoLint" )
163
- let l: errors = go#list#Get (l: listtype )
164
- call go#list#Window (l: listtype , len (l: errors ))
174
+ let l: winid = win_getid (winnr ())
175
+ let l: listtype = go#list#Type (" GoLint" )
176
+ call go#list#Parse (l: listtype , l: out , " GoLint" )
177
+ let l: errors = go#list#Get (l: listtype )
178
+ call go#list#Window (l: listtype , len (l: errors ))
165
179
166
- if a: bang
167
- call win_gotoid (l: winid )
180
+ if a: bang
181
+ call win_gotoid (l: winid )
182
+ else
183
+ call go#list#JumpToFirst (l: listtype )
184
+ endif
185
+ if go#config#EchoCommandInfo ()
186
+ call go#util#EchoError (printf (' [%s] %s' , l: type , l: state ))
187
+ endif
168
188
else
169
- call go#list#JumpToFirst (l: listtype )
189
+ if go#config#EchoCommandInfo ()
190
+ call go#util#EchoSuccess (printf (' [%s] %s' , l: type , l: state ))
191
+ endif
170
192
endif
193
+ call go#statusline#Update (expand (' %:p:h' ), l: status )
171
194
endfunction
172
195
173
196
" Vet calls 'go vet' on the current directory. Any warnings are populated in
174
197
" the location list
175
198
function ! go#lint#Vet (bang , ... ) abort
176
199
call go#cmd#autowrite ()
177
200
178
- if go#config#EchoCommandInfo ()
179
- call go#util#EchoProgress (' calling vet...' )
180
- endif
181
-
182
201
let l: cmd = [' go' , ' vet' ]
183
202
184
203
let buildtags = go#config#BuildTags ()
185
204
if buildtags isnot ' '
186
- let cmd += [' -tags' , buildtags]
205
+ let l: cmd += [' -tags' , buildtags]
206
+ endif
207
+
208
+ if a: 0 == 0
209
+ let l: import_path = go#package#ImportPath ()
210
+ if l: import_path == -1
211
+ call go#util#EchoError (' could not determine package' )
212
+ return
213
+ endif
214
+ let l: cmd = add (l: cmd , l: import_path )
215
+ else
216
+ let l: cmd = extend (l: cmd , a: 000 )
187
217
endif
188
218
189
- if a: 0 != 0
190
- call extend (cmd, a: 000 )
219
+ let l: type = ' go vet'
220
+ if go#config#EchoCommandInfo ()
221
+ call go#util#EchoProgress (printf (' [%s] analyzing...' , l: type ))
191
222
endif
223
+ let l: status = {
224
+ \ ' desc' : ' current status' ,
225
+ \ ' type' : l: type ,
226
+ \ ' state' : " started" ,
227
+ \ }
228
+ call go#statusline#Update (expand (' %:p:h' ), l: status )
192
229
193
- let cmd += [ go#package#ImportPath ()]
230
+ let [ l: out , l: err ] = go#util#ExecInDir ( l: cmd )
194
231
195
- let [l: out , l: err ] = go#util#Exec (l: cmd )
232
+ let l: status .state = ' success'
233
+ let l: state = ' PASS'
196
234
197
235
let l: listtype = go#list#Type (" GoVet" )
198
236
if l: err != 0
237
+ let l: status .state = ' failed'
238
+ let l: state = ' FAIL'
239
+
199
240
let l: winid = win_getid (winnr ())
200
241
let l: errorformat = " %-Gexit status %\\ d%\\ +," . &errorformat
201
242
call go#list#ParseFormat (l: listtype , l: errorformat , out, " GoVet" )
@@ -212,33 +253,65 @@ function! go#lint#Vet(bang, ...) abort
212
253
else
213
254
call win_gotoid (l: winid )
214
255
endif
256
+
257
+ if go#config#EchoCommandInfo ()
258
+ call go#util#EchoError (printf (' [%s] %s' , l: type , l: state ))
259
+ endif
215
260
else
216
261
call go#list#Clean (l: listtype )
217
- call go#util#EchoSuccess (' [vet] PASS' )
262
+ if go#config#EchoCommandInfo ()
263
+ call go#util#EchoSuccess (printf (' [%s] %s' , l: type , l: state ))
264
+ endif
218
265
endif
266
+ call go#statusline#Update (expand (' %:p:h' ), l: status )
219
267
endfunction
220
268
221
269
" ErrCheck calls 'errcheck' for the given packages. Any warnings are populated in
222
270
" the location list
223
271
function ! go#lint#Errcheck (bang , ... ) abort
272
+ call go#cmd#autowrite ()
273
+
274
+ let l: cmd = [go#config#ErrcheckBin (), ' -abspath' ]
275
+
276
+ let buildtags = go#config#BuildTags ()
277
+ if buildtags isnot ' '
278
+ let l: cmd += [' -tags' , buildtags]
279
+ endif
280
+
224
281
if a: 0 == 0
225
282
let l: import_path = go#package#ImportPath ()
226
283
if l: import_path == -1
227
- call go#util#EchoError (' package is not inside GOPATH src ' )
284
+ call go#util#EchoError (' could not determine package ' )
228
285
return
229
286
endif
230
- let l: args = [ l: import_path]
287
+ let l: cmd = add ( l: cmd , l: import_path)
231
288
else
232
- let l: args = a: 000
289
+ let l: cmd = extend ( l: cmd , a: 000)
233
290
endif
234
291
235
- call go#util#EchoProgress (' [errcheck] analysing ...' )
292
+ let l: type = ' errcheck'
293
+ if go#config#EchoCommandInfo ()
294
+ call go#util#EchoProgress (printf (' [%s] analyzing...' , l: type ))
295
+ endif
296
+ let l: status = {
297
+ \ ' desc' : ' current status' ,
298
+ \ ' type' : l: type ,
299
+ \ ' state' : " started" ,
300
+ \ }
236
301
redraw
237
302
238
- let [l: out , l: err ] = go#util#ExecInDir ([go#config#ErrcheckBin (), ' -abspath' ] + l: args )
303
+ call go#statusline#Update (expand (' %:p:h' ), l: status )
304
+
305
+ let [l: out , l: err ] = go#util#ExecInDir (l: cmd )
306
+
307
+ let l: status .state = ' success'
308
+ let l: state = ' PASS'
239
309
240
310
let l: listtype = go#list#Type (" GoErrCheck" )
241
311
if l: err != 0
312
+ let l: status .state = ' failed'
313
+ let l: state = ' FAIL'
314
+
242
315
let l: winid = win_getid (winnr ())
243
316
244
317
if l: err == 1
@@ -262,10 +335,16 @@ function! go#lint#Errcheck(bang, ...) abort
262
335
call win_gotoid (l: winid )
263
336
endif
264
337
endif
338
+ if go#config#EchoCommandInfo ()
339
+ call go#util#EchoError (printf (' [%s] %s' , l: type , l: state ))
340
+ endif
265
341
else
266
342
call go#list#Clean (l: listtype )
267
- call go#util#EchoSuccess (' [errcheck] PASS' )
343
+ if go#config#EchoCommandInfo ()
344
+ call go#util#EchoSuccess (printf (' [%s] %s' , l: type , l: state ))
345
+ endif
268
346
endif
347
+ call go#statusline#Update (expand (' %:p:h' ), l: status )
269
348
endfunction
270
349
271
350
function ! go#lint#ToggleMetaLinterAutoSave () abort
0 commit comments