src/goLanguageServer.ts: enable language server by default in nightly
Fixes golang/vscode-go#680
Change-Id: I93c47e48509175d302a3fe49e43642fd4bd7e749
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/257959
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/build/all.bash b/build/all.bash
index 0264154..c622653 100755
--- a/build/all.bash
+++ b/build/all.bash
@@ -76,9 +76,7 @@
.displayName="Go Nightly" |
.publisher="golang" |
.description="Rich Go language support for Visual Studio Code (Nightly)" |
-.author.name="Go Team at Google" |
-.repository.url="https://github.com/golang/vscode-go" |
-.bugs.url="https://github.com/golang/vscode-go/issues"
+.contributes.configuration.properties."go.useLanguageServer".default=true
') > /tmp/package.json && mv /tmp/package.json package.json
# Replace CHANGELOG.md with CHANGELOG.md + Release commit info.
diff --git a/src/goLanguageServer.ts b/src/goLanguageServer.ts
index b577ae4..80c0797 100644
--- a/src/goLanguageServer.ts
+++ b/src/goLanguageServer.ts
@@ -1212,3 +1212,25 @@
}
return '';
}
+
+export async function promptForLanguageServerDefaultChange(cfg: vscode.WorkspaceConfiguration) {
+ const promptedForLSDefaultChangeKey = `promptedForLSDefaultChange`;
+ if (getFromGlobalState(promptedForLSDefaultChangeKey, false)) {
+ return;
+ }
+
+ const useLanguageServer = cfg.inspect<boolean>('useLanguageServer');
+ if (useLanguageServer.globalValue !== undefined || useLanguageServer.workspaceValue !== undefined) {
+ return; // user already explicitly set the field.
+ }
+
+ const selected = await vscode.window.showInformationMessage(
+ `"go.useLanguageServer" is enabled by default. If you need to disable it, please configure in the settings.`,
+ 'Open Settings', 'OK');
+ switch (selected) {
+ case 'Open Settings':
+ vscode.commands.executeCommand('workbench.action.openSettings', 'go.useLanguageServer');
+ default:
+ }
+ updateGlobalState(promptedForLSDefaultChangeKey, true);
+}
diff --git a/src/goLogging.ts b/src/goLogging.ts
index d032f1f..52bcdeb 100644
--- a/src/goLogging.ts
+++ b/src/goLogging.ts
@@ -61,7 +61,7 @@
// tslint:disable-next-line:no-any
export function logVerbose(...args: any[]) {
- log(LogLevel.Info, ...args);
+ log(LogLevel.Verbose, ...args);
}
// tslint:disable-next-line:no-any
diff --git a/src/goMain.ts b/src/goMain.ts
index 9104b37..1e707b2 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -8,6 +8,7 @@
import * as path from 'path';
import vscode = require('vscode');
+import { extensionId } from './const';
import { browsePackages } from './goBrowsePackage';
import { buildCode } from './goBuild';
import { check, notifyIfGeneratedFile, removeTestStatus } from './goCheck';
@@ -29,7 +30,10 @@
installAllTools, installTools, offerToInstallTools, promptForMissingTool,
updateGoVarsFromConfig
} from './goInstallTools';
-import { sendToggleCommand, startLanguageServerWithFallback, watchLanguageServerConfiguration } from './goLanguageServer';
+import {
+ promptForLanguageServerDefaultChange, sendToggleCommand,
+ startLanguageServerWithFallback, watchLanguageServerConfiguration
+} from './goLanguageServer';
import { lintCode } from './goLint';
import { logVerbose, setLogConfig } from './goLogging';
import { GO_MODE } from './goMode';
@@ -73,13 +77,17 @@
export let restartLanguageServer = () => { return; };
export function activate(ctx: vscode.ExtensionContext) {
- const logConfig = getGoConfig()['logging'];
- setLogConfig(logConfig);
+ const cfg = getGoConfig();
+ setLogConfig(cfg['logging']);
setGlobalState(ctx.globalState);
setWorkspaceState(ctx.workspaceState);
setEnvironmentVariableCollection(ctx.environmentVariableCollection);
+ if (extensionId === 'golang.go-nightly') {
+ promptForLanguageServerDefaultChange(cfg);
+ }
+
const configGOROOT = getGoConfig()['goroot'];
if (!!configGOROOT) {
logVerbose(`go.goroot = '${configGOROOT}'`);