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

Remove support for github.com/sourcegraph/go-langserver #3127

Merged
merged 2 commits into from
Mar 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export function installTools(missing: Tool[], goVersion: GoVersion): Promise<voi
outputChannel.appendLine(''); // Blank line for spacing
const failures = res.filter((x) => x != null);
if (failures.length === 0) {
if (containsString(missing, 'go-langserver') || containsString(missing, 'gopls')) {
if (containsString(missing, 'gopls')) {
outputChannel.appendLine('Reload VS Code window to use the Go language server');
}
outputChannel.appendLine('All tools successfully installed. You are ready to Go :).');
Expand Down
54 changes: 23 additions & 31 deletions src/goLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ export function parseLanguageServerConfig(): LanguageServerConfig {
}

/**
* Get the absolute path to the language server to be used.
* If the required tool is not available, then user is prompted to install it.
* This supports the language servers from both Google and Sourcegraph with the
* former getting a precedence over the latter
*
* If the user has enabled the language server, return the absolute path to the
* correct binary. If the required tool is not available, prompt the user to
* install it. Only gopls is officially supported.
*/
export function getLanguageServerToolPath(): string {
// If language server is not enabled, return
Expand All @@ -363,40 +363,32 @@ export function getLanguageServerToolPath(): string {
);
return;
}

// Get the path to gopls or any alternative that the user might have set for gopls.
// Get the path to gopls (getBinPath checks for alternate tools).
const goplsBinaryPath = getBinPath('gopls');
if (path.isAbsolute(goplsBinaryPath)) {
return goplsBinaryPath;
}

// Get the path to go-langserver or any alternative that the user might have set for go-langserver.
const golangserverBinaryPath = getBinPath('go-langserver');
if (path.isAbsolute(golangserverBinaryPath)) {
return golangserverBinaryPath;
}

// If no language server path has been found, notify the user.
let languageServerOfChoice = 'gopls';
if (goConfig['alternateTools']) {
const goplsAlternate = goConfig['alternateTools']['gopls'];
const golangserverAlternate = goConfig['alternateTools']['go-langserver'];
if (typeof goplsAlternate === 'string') {
languageServerOfChoice = getToolFromToolPath(goplsAlternate);
} else if (typeof golangserverAlternate === 'string') {
languageServerOfChoice = getToolFromToolPath(golangserverAlternate);
const alternateTools = goConfig['alternateTools'];
if (alternateTools) {
// The user's alternate language server was not found.
const goplsAlternate = alternateTools['gopls'];
if (goplsAlternate) {
vscode.window.showErrorMessage(
`Cannot find the alternate tool ${goplsAlternate} configured for gopls.
Please install it and reload this VS Code window.`
);
return;
}
// Check if the user has the deprecated "go-langserver" setting.
// Suggest deleting it if the alternate tool is gopls.
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.`);
}
}
// Only gopls and go-langserver are supported.
if (languageServerOfChoice !== 'gopls' && languageServerOfChoice !== 'go-langserver') {
vscode.window.showErrorMessage(
`Cannot find the language server ${languageServerOfChoice}. Please install it and reload this VS Code window`
);
return;
}
// Otherwise, prompt the user to install the language server.
promptForMissingTool(languageServerOfChoice);
vscode.window.showInformationMessage('Reload VS Code window after installing the Go language server.');
// Prompt the user to install gopls.
promptForMissingTool('gopls');
}

function allFoldersHaveSameGopath(): boolean {
Expand Down
8 changes: 1 addition & 7 deletions src/goTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function getConfiguredTools(goVersion: GoVersion): Tool[] {
// Add the linter that was chosen by the user.
maybeAddTool(goConfig['lintTool']);

// Add the language server for Go versions > 1.10 if user has choosen to do so
// Add the language server for Go versions > 1.10 if user has choosen to do so.
if (goConfig['useLanguageServer'] && goVersion.gt('1.10')) {
maybeAddTool('gopls');
}
Expand Down Expand Up @@ -260,12 +260,6 @@ const allToolsInformation: { [key: string]: Tool } = {
isImportant: true,
description: 'Linter'
},
'go-langserver': {
name: 'go-langserver',
importPath: 'github.com/sourcegraph/go-langserver',
isImportant: false,
description: 'Language Server from Sourcegraph'
},
'gopls': {
name: 'gopls',
importPath: 'golang.org/x/tools/gopls',
Expand Down