Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
src/goLanguageServer: fix missing gopls detection logic
Browse files Browse the repository at this point in the history
Also, update getMissingTools to check the tool's existence
by simply checking whether the resolved tool path is absolute.
getBinPath already ran the existence check before returning
the absolute path for the tool.

Fixes #3194
  • Loading branch information
hyangah committed Apr 20, 2020
1 parent dfa9cbb commit c15d43f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ export async function promptForMissingTool(toolName: string) {
const installOptions = ['Install'];
let missing = await getMissingTools(goVersion);
if (!containsTool(missing, tool)) {
console.log(`not containsTool ${missing}, ${tool}, ${goVersion}`);
return;
}
missing = missing.filter((x) => x === tool || tool.isImportant);
Expand Down Expand Up @@ -544,9 +545,7 @@ function getMissingTools(goVersion: GoVersion): Promise<Tool[]> {
(tool) =>
new Promise<Tool>((resolve, reject) => {
const toolPath = getBinPath(tool.name);
fs.exists(toolPath, (exists) => {
resolve(exists ? null : tool);
});
resolve(path.isAbsolute(toolPath) ? null : tool);
})
)
).then((res) => {
Expand Down
5 changes: 4 additions & 1 deletion src/goLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ export function getLanguageServerToolPath(): string {
}
const alternateTools = goConfig['alternateTools'];
if (alternateTools) {
console.log('alternateTools ' + JSON.stringify(alternateTools, null, 2));
// The user's alternate language server was not found.
const goplsAlternate = alternateTools['gopls'];
if (goplsAlternate) {
Expand All @@ -298,9 +299,11 @@ Please install it and reload this VS Code window.`
if (alternateTools['go-langserver']) {
vscode.window.showErrorMessage(`Support for "go-langserver" has been deprecated.
The recommended language server is gopls. Delete the alternate tool setting for "go-langserver" to use gopls, or change "go-langserver" to "gopls" in your settings.json and reload the VS Code window.`);
return;
}
return;
}

console.log('promptForMissingTools(gopls)');
// Prompt the user to install gopls.
promptForMissingTool('gopls');
}
Expand Down

0 comments on commit c15d43f

Please # to comment.