@@ -13,6 +13,7 @@ import semver = require('semver');
13
13
import util = require( 'util' ) ;
14
14
import { getFormatTool , usingCustomFormatTool } from './goFormat' ;
15
15
import { goLiveErrorsEnabled } from './goLiveErrors' ;
16
+ import { allToolsInformation } from './goToolsInformation' ;
16
17
import { getBinPath , GoVersion } from './util' ;
17
18
18
19
export interface Tool {
@@ -214,259 +215,20 @@ export function goplsStaticcheckEnabled(
214
215
return ! features || features [ 'diagnostics' ] === true ;
215
216
}
216
217
217
- export const allToolsInformation : { [ key : string ] : Tool } = {
218
- 'gocode' : {
219
- name : 'gocode' ,
220
- importPath : 'github.com/mdempsky/gocode' ,
221
- modulePath : 'github.com/mdempsky/gocode' ,
222
- isImportant : true ,
223
- replacedByGopls : true ,
224
- description : 'Auto-completion, does not work with modules' ,
225
- close : async ( env : NodeJS . Dict < string > ) : Promise < string > => {
226
- const toolBinPath = getBinPath ( 'gocode' ) ;
227
- if ( ! path . isAbsolute ( toolBinPath ) ) {
228
- return '' ;
229
- }
230
- try {
231
- const execFile = util . promisify ( cp . execFile ) ;
232
- const { stderr } = await execFile ( toolBinPath , [ 'close' ] , { env, timeout : 10000 } ) ; // give 10sec.
233
- if ( stderr . indexOf ( "rpc: can't find service Server." ) > - 1 ) {
234
- return 'Installing gocode aborted as existing process cannot be closed. Please kill the running process for gocode and try again.' ;
235
- }
236
- } catch ( err ) {
237
- // This may fail if gocode isn't already running.
238
- console . log ( `gocode close failed: ${ err } ` ) ;
239
- }
240
- return '' ;
218
+ export const gocodeClose = async ( env : NodeJS . Dict < string > ) : Promise < string > => {
219
+ const toolBinPath = getBinPath ( 'gocode' ) ;
220
+ if ( ! path . isAbsolute ( toolBinPath ) ) {
221
+ return '' ;
222
+ }
223
+ try {
224
+ const execFile = util . promisify ( cp . execFile ) ;
225
+ const { stderr } = await execFile ( toolBinPath , [ 'close' ] , { env, timeout : 10000 } ) ; // give 10sec.
226
+ if ( stderr . indexOf ( "rpc: can't find service Server." ) > - 1 ) {
227
+ return 'Installing gocode aborted as existing process cannot be closed. Please kill the running process for gocode and try again.' ;
241
228
}
242
- } ,
243
- 'gocode-gomod' : {
244
- name : 'gocode-gomod' ,
245
- importPath : 'github.com/stamblerre/gocode' ,
246
- modulePath : 'github.com/stamblerre/gocode' ,
247
- isImportant : true ,
248
- replacedByGopls : true ,
249
- description : 'Auto-completion, works with modules' ,
250
- minimumGoVersion : semver . coerce ( '1.11' )
251
- } ,
252
- 'gopkgs' : {
253
- name : 'gopkgs' ,
254
- importPath : 'github.com/uudashr/gopkgs/v2/cmd/gopkgs' ,
255
- modulePath : 'github.com/uudashr/gopkgs/v2' ,
256
- replacedByGopls : false , // TODO(github.com/golang/vscode-go/issues/258): disable Add Import command.
257
- isImportant : true ,
258
- description : 'Auto-completion of unimported packages & Add Import feature'
259
- } ,
260
- 'go-outline' : {
261
- name : 'go-outline' ,
262
- importPath : 'github.com/ramya-rao-a/go-outline' ,
263
- modulePath : 'github.com/ramya-rao-a/go-outline' ,
264
- replacedByGopls : false , // TODO(github.com/golang/vscode-go/issues/1020): replace with Gopls.
265
- isImportant : true ,
266
- description : 'Go to symbol in file' // GoDocumentSymbolProvider, used by 'run test' codelens
267
- } ,
268
- 'go-symbols' : {
269
- name : 'go-symbols' ,
270
- importPath : 'github.com/acroca/go-symbols' ,
271
- modulePath : 'github.com/acroca/go-symbols' ,
272
- replacedByGopls : true ,
273
- isImportant : false ,
274
- description : 'Go to symbol in workspace'
275
- } ,
276
- 'guru' : {
277
- name : 'guru' ,
278
- importPath : 'golang.org/x/tools/cmd/guru' ,
279
- modulePath : 'golang.org/x/tools' ,
280
- replacedByGopls : true ,
281
- isImportant : false ,
282
- description : 'Find all references and Go to implementation of symbols'
283
- } ,
284
- 'gorename' : {
285
- name : 'gorename' ,
286
- importPath : 'golang.org/x/tools/cmd/gorename' ,
287
- modulePath : 'golang.org/x/tools' ,
288
- replacedByGopls : true ,
289
- isImportant : false ,
290
- description : 'Rename symbols'
291
- } ,
292
- 'gomodifytags' : {
293
- name : 'gomodifytags' ,
294
- importPath : 'github.com/fatih/gomodifytags' ,
295
- modulePath : 'github.com/fatih/gomodifytags' ,
296
- replacedByGopls : false ,
297
- isImportant : false ,
298
- description : 'Modify tags on structs'
299
- } ,
300
- 'goplay' : {
301
- name : 'goplay' ,
302
- importPath : 'github.com/haya14busa/goplay/cmd/goplay' ,
303
- modulePath : 'github.com/haya14busa/goplay' ,
304
- replacedByGopls : false ,
305
- isImportant : false ,
306
- description : 'The Go playground'
307
- } ,
308
- 'impl' : {
309
- name : 'impl' ,
310
- importPath : 'github.com/josharian/impl' ,
311
- modulePath : 'github.com/josharian/impl' ,
312
- replacedByGopls : false ,
313
- isImportant : false ,
314
- description : 'Stubs for interfaces'
315
- } ,
316
- 'gotype-live' : {
317
- name : 'gotype-live' ,
318
- importPath : 'github.com/tylerb/gotype-live' ,
319
- modulePath : 'github.com/tylerb/gotype-live' ,
320
- replacedByGopls : true , // TODO(github.com/golang/vscode-go/issues/1021): recommend users to turn off.
321
- isImportant : false ,
322
- description : 'Show errors as you type'
323
- } ,
324
- 'godef' : {
325
- name : 'godef' ,
326
- importPath : 'github.com/rogpeppe/godef' ,
327
- modulePath : 'github.com/rogpeppe/godef' ,
328
- replacedByGopls : true ,
329
- isImportant : true ,
330
- description : 'Go to definition'
331
- } ,
332
- 'gogetdoc' : {
333
- name : 'gogetdoc' ,
334
- importPath : 'github.com/zmb3/gogetdoc' ,
335
- modulePath : 'github.com/zmb3/gogetdoc' ,
336
- replacedByGopls : true ,
337
- isImportant : true ,
338
- description : 'Go to definition & text shown on hover'
339
- } ,
340
- 'gofumports' : {
341
- name : 'gofumports' ,
342
- importPath : 'mvdan.cc/gofumpt/gofumports' ,
343
- modulePath : 'mvdan.cc/gofumpt' ,
344
- replacedByGopls : true ,
345
- isImportant : false ,
346
- description : 'Formatter'
347
- } ,
348
- 'gofumpt' : {
349
- name : 'gofumpt' ,
350
- importPath : 'mvdan.cc/gofumpt' ,
351
- modulePath : 'mvdan.cc/gofumpt' ,
352
- replacedByGopls : true ,
353
- isImportant : false ,
354
- description : 'Formatter'
355
- } ,
356
- 'goimports' : {
357
- name : 'goimports' ,
358
- importPath : 'golang.org/x/tools/cmd/goimports' ,
359
- modulePath : 'golang.org/x/tools' ,
360
- replacedByGopls : true ,
361
- isImportant : true ,
362
- description : 'Formatter'
363
- } ,
364
- 'goreturns' : {
365
- name : 'goreturns' ,
366
- importPath : 'github.com/sqs/goreturns' ,
367
- modulePath : 'github.com/sqs/goreturns' ,
368
- replacedByGopls : true ,
369
- isImportant : true ,
370
- description : 'Formatter'
371
- } ,
372
- 'goformat' : {
373
- name : 'goformat' ,
374
- importPath : 'winterdrache.de/goformat/goformat' ,
375
- modulePath : 'winterdrache.de/goformat/goformat' ,
376
- replacedByGopls : true ,
377
- isImportant : false ,
378
- description : 'Formatter'
379
- } ,
380
- 'gotests' : {
381
- name : 'gotests' ,
382
- importPath : 'github.com/cweill/gotests/gotests' ,
383
- modulePath : 'github.com/cweill/gotests' ,
384
- replacedByGopls : false ,
385
- isImportant : false ,
386
- description : 'Generate unit tests' ,
387
- minimumGoVersion : semver . coerce ( '1.9' )
388
- } ,
389
- // TODO(github.com/golang/vscode-go/issues/189): consider disabling lint when gopls is turned on.
390
- 'golint' : {
391
- name : 'golint' ,
392
- importPath : 'golang.org/x/lint/golint' ,
393
- modulePath : 'golang.org/x/lint' ,
394
- replacedByGopls : false ,
395
- isImportant : false ,
396
- description : 'Linter' ,
397
- minimumGoVersion : semver . coerce ( '1.9' )
398
- } ,
399
- 'staticcheck' : {
400
- name : 'staticcheck' ,
401
- importPath : 'honnef.co/go/tools/cmd/staticcheck' ,
402
- modulePath : 'honnef.co/go/tools' ,
403
- replacedByGopls : false ,
404
- isImportant : true ,
405
- description : 'Linter'
406
- } ,
407
- 'golangci-lint' : {
408
- name : 'golangci-lint' ,
409
- importPath : 'github.com/golangci/golangci-lint/cmd/golangci-lint' ,
410
- modulePath : 'github.com/golangci/golangci-lint' ,
411
- replacedByGopls : false ,
412
- isImportant : true ,
413
- description : 'Linter'
414
- } ,
415
- 'revive' : {
416
- name : 'revive' ,
417
- importPath : 'github.com/mgechev/revive' ,
418
- modulePath : 'github.com/mgechev/revive' ,
419
- isImportant : true ,
420
- description : 'Linter'
421
- } ,
422
- 'gopls' : {
423
- name : 'gopls' ,
424
- importPath : 'golang.org/x/tools/gopls' ,
425
- modulePath : 'golang.org/x/tools/gopls' ,
426
- replacedByGopls : false , // lol
427
- isImportant : true ,
428
- description : 'Language Server from Google' ,
429
- usePrereleaseInPreviewMode : true ,
430
- minimumGoVersion : semver . coerce ( '1.12' ) ,
431
- latestVersion : semver . coerce ( '0.6.8' ) ,
432
- latestVersionTimestamp : moment ( '2021-03-17' , 'YYYY-MM-DD' ) ,
433
- latestPrereleaseVersion : semver . coerce ( '0.6.8' ) ,
434
- latestPrereleaseVersionTimestamp : moment ( '2021-03-17' , 'YYYY-MM-DD' )
435
- } ,
436
- 'dlv' : {
437
- name : 'dlv' ,
438
- importPath : 'github.com/go-delve/delve/cmd/dlv' ,
439
- modulePath : 'github.com/go-delve/delve' ,
440
- replacedByGopls : false ,
441
- isImportant : true ,
442
- description : 'Go debugger (Delve)'
443
- } ,
444
- 'dlv-dap' : {
445
- name : 'dlv-dap' ,
446
- importPath : 'github.com/go-delve/delve/cmd/dlv' ,
447
- modulePath : 'github.com/go-delve/delve' ,
448
- replacedByGopls : false ,
449
- isImportant : false ,
450
- description : 'Go debugger (Delve built for DAP experiment)' ,
451
- defaultVersion : 'master' , // Always build from the master.
452
- minimumGoVersion : semver . coerce ( '1.14' ) , // last 3 versions per delve policy
453
- latestVersion : semver . parse ( '1.6.1-0.20210504195617-c5d58f494a26' ) ,
454
- latestVersionTimestamp : moment ( '2021-05-04' , 'YYYY-MM-DD' )
455
- } ,
456
- 'fillstruct' : {
457
- name : 'fillstruct' ,
458
- importPath : 'github.com/davidrjenni/reftools/cmd/fillstruct' ,
459
- modulePath : 'github.com/davidrjenni/reftools' ,
460
- replacedByGopls : true ,
461
- isImportant : false ,
462
- description : 'Fill structs with defaults'
463
- } ,
464
- 'godoctor' : {
465
- name : 'godoctor' ,
466
- importPath : 'github.com/godoctor/godoctor' ,
467
- modulePath : 'github.com/godoctor/godoctor' ,
468
- replacedByGopls : true ,
469
- isImportant : false ,
470
- description : 'Extract to functions and variables'
229
+ } catch ( err ) {
230
+ // This may fail if gocode isn't already running.
231
+ console . log ( `gocode close failed: ${ err } ` ) ;
471
232
}
233
+ return '' ;
472
234
} ;
0 commit comments