Skip to content

Commit

Permalink
extension/src: skip tool existence check if replaced by gopls
Browse files Browse the repository at this point in the history
When gopls is running, format tools it replaces are ineffective.

This change prevents VS Code Go from prompting for their
installation when gopls is active.

For #3677

Change-Id: Ic1fabf0687b6c9b3687dbc59e2099859b90d2250
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/648415
kokoro-CI: kokoro <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Madeline Kalil <[email protected]>
  • Loading branch information
h9jiang committed Feb 11, 2025
1 parent 8dc2b5a commit 2882143
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion extension/src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import { toggleVulncheckCommandFactory } from './goVulncheck';
import { GoTaskProvider } from './goTaskProvider';
import { setTelemetryEnvVars, telemetryReporter } from './goTelemetry';
import { experiments } from './experimental';
import { allToolsInformation } from './goToolsInformation';

const goCtx: GoExtensionContext = {};

Expand Down Expand Up @@ -300,7 +301,16 @@ function addOnDidChangeConfigListeners(ctx: vscode.ExtensionContext) {
}

if (e.affectsConfiguration('go.formatTool')) {
checkToolExists(getFormatTool(updatedGoConfig));
const tool = getFormatTool(updatedGoConfig);
// When language server gopls is active (by default), existence
// checks are skipped only for tools that gopls replaces. Other
// tools are still checked.
if (
updatedGoConfig['useLanguageServer'] === false ||
!new Set(['gofmt', 'goimports', 'goformat']).has(tool)
) {
checkToolExists(tool);
}
}
if (e.affectsConfiguration('go.lintTool')) {
checkToolExists(updatedGoConfig['lintTool']);
Expand Down

0 comments on commit 2882143

Please sign in to comment.