src/goLanguageServer: deprecate documentLink configuration

gopls has had an importShortcut setting for a while, which is meant to
replace the documentLink setting in
go.languageServerExperimentalFeatures. Delete the setting entirely and
notify its users of the replacement.

Change-Id: I5b1828b1409400b84ffc2732f38cb905f343855a
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/280597
Trust: Rebecca Stambler <rstambler@golang.org>
Trust: Suzy Mueller <suzmue@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
diff --git a/docs/settings.md b/docs/settings.md
index 5d6b577..81addc6 100644
--- a/docs/settings.md
+++ b/docs/settings.md
@@ -366,16 +366,12 @@
 
 Default:{<br/>
 &nbsp;&nbsp;`"diagnostics": true`,<br/>
-&nbsp;&nbsp;`"documentLink": true`,<br/>
     }
 
 
 #### `diagnostics`
 If true, the language server will provide build, vet errors and the extension will ignore the `buildOnSave`, `vetOnSave` settings.
 
-#### `documentLink`
-If true, the language server will provide clickable Godoc links for import statements.
-
 ### `go.languageServerFlags`
 
 Flags like -rpc.trace and -logfile to be used while running the language server.
diff --git a/package.json b/package.json
index c9f4d3c..4f7a0d7 100644
--- a/package.json
+++ b/package.json
@@ -1605,17 +1605,11 @@
               "type": "boolean",
               "default": true,
               "description": "If true, the language server will provide build, vet errors and the extension will ignore the `buildOnSave`, `vetOnSave` settings."
-            },
-            "documentLink": {
-              "type": "boolean",
-              "default": true,
-              "description": "If true, the language server will provide clickable Godoc links for import statements."
             }
           },
           "additionalProperties": false,
           "default": {
-            "diagnostics": true,
-            "documentLink": true
+            "diagnostics": true
           },
           "description": "Use this setting to enable/disable experimental features from the language server."
         },
diff --git a/src/goLanguageServer.ts b/src/goLanguageServer.ts
index 9d4db9d..dffe4b5 100644
--- a/src/goLanguageServer.ts
+++ b/src/goLanguageServer.ts
@@ -76,7 +76,6 @@
 	env: any;
 	features: {
 		diagnostics: boolean;
-		documentLink: boolean;
 	};
 	checkForUpdates: string;
 }
@@ -394,16 +393,6 @@
 					}
 					return next(uri, diagnostics);
 				},
-				provideDocumentLinks: (
-					document: vscode.TextDocument,
-					token: vscode.CancellationToken,
-					next: ProvideDocumentLinksSignature
-				) => {
-					if (!cfg.features.documentLink) {
-						return null;
-					}
-					return next(document, token);
-				},
 				provideCompletionItem: async (
 					document: vscode.TextDocument,
 					position: vscode.Position,
@@ -709,7 +698,6 @@
 }
 
 export function buildLanguageServerConfig(goConfig: vscode.WorkspaceConfiguration): LanguageServerConfig {
-
 	const cfg: LanguageServerConfig = {
 		serverName: '',
 		path: '',
@@ -721,7 +709,6 @@
 			// TODO: We should have configs that match these names.
 			// Ultimately, we should have a centralized language server config rather than separate fields.
 			diagnostics: goConfig['languageServerExperimentalFeatures']['diagnostics'],
-			documentLink: goConfig['languageServerExperimentalFeatures']['documentLink']
 		},
 		env: toolExecutionEnvironment(),
 		checkForUpdates: getCheckForToolsUpdatesConfig(goConfig),
diff --git a/src/goMain.ts b/src/goMain.ts
index 278be4d..197363f 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -105,6 +105,13 @@
 		setCurrentGoRoot(resolvePath(configGOROOT));
 	}
 
+	// Present a warning about the deprecation of the go.documentLink setting.
+	if (getGoConfig()['languageServerExperimentalFeatures']['documentLink'] === false) {
+		vscode.window.showErrorMessage(`The 'go.languageServerExperimentalFeature.documentLink' setting is now deprecated.
+Please use 'gopls.importShortcut' instead.
+See https://github.com/golang/tools/blob/master/gopls/doc/settings.md#importshortcut-enum for more details.`);
+	}
+
 	updateGoVarsFromConfig().then(async () => {
 		suggestUpdates(ctx);
 		offerToInstallLatestGoVersion();
@@ -594,7 +601,7 @@
 			if (document.languageId !== 'go') {
 				return;
 			}
-			const session =  vscode.debug.activeDebugSession;
+			const session = vscode.debug.activeDebugSession;
 			if (session && (session.type === 'go' || session.type === 'godlvdap')) {
 				const neverAgain = { title: `Don't Show Again` };
 				const ignoreActiveDebugWarningKey = 'ignoreActiveDebugWarningKey';
diff --git a/test/gopls/update.test.ts b/test/gopls/update.test.ts
index dcfe27f..afb4a34 100644
--- a/test/gopls/update.test.ts
+++ b/test/gopls/update.test.ts
@@ -19,10 +19,10 @@
 	const defaultConfigInspector = getGoConfig().inspect(CHECK_FOR_UPDATES);
 
 	test('default is as expected', () => {
-		const {key, defaultValue, globalValue, workspaceValue} = defaultConfigInspector;
+		const { key, defaultValue, globalValue, workspaceValue } = defaultConfigInspector;
 		assert.deepStrictEqual(
 			{ key, defaultValue, globalValue, workspaceValue },
-			{ key: `go.${CHECK_FOR_UPDATES}`, defaultValue : 'proxy', globalValue: undefined, workspaceValue: undefined},
+			{ key: `go.${CHECK_FOR_UPDATES}`, defaultValue: 'proxy', globalValue: undefined, workspaceValue: undefined },
 			CHECK_FOR_UPDATES);
 		assert.strictEqual(getGoConfig().get(LEGACY_CHECK_FOR_UPDATES), true, LEGACY_CHECK_FOR_UPDATES);
 	});
@@ -31,14 +31,14 @@
 	// vscode.getConfiguration is read-only, and doesn't allow property modification
 	// so working with sinon directly doesn't seem possible.
 	class TestWorkspaceConfiguration implements vscode.WorkspaceConfiguration {
-		constructor(private _wrapped: vscode.WorkspaceConfiguration) {}
+		constructor(private _wrapped: vscode.WorkspaceConfiguration) { }
 		public get<T>(params: string) { return this._wrapped.get<T>(params); }
 		public has(params: string) { return this._wrapped.has(params); }
 		public inspect<T>(params: string) { return this._wrapped.inspect<T>(params); }
 		public update<T>(
 			section: string, value: any,
 			configurationTarget?: vscode.ConfigurationTarget | boolean, overrideInLanguage?: boolean) {
-				return this._wrapped.update(section, value, configurationTarget, overrideInLanguage);
+			return this._wrapped.update(section, value, configurationTarget, overrideInLanguage);
 		}
 		[key: string]: any;
 	}
@@ -62,7 +62,7 @@
 			.withArgs(LEGACY_CHECK_FOR_UPDATES).returns(false)
 			.withArgs(CHECK_FOR_UPDATES).returns('proxy');
 		sinon.stub(gocfg, 'inspect').withArgs(CHECK_FOR_UPDATES).returns(
-			Object.assign({}, defaultConfigInspector, {	globalValue: 'proxy' }));
+			Object.assign({}, defaultConfigInspector, { globalValue: 'proxy' }));
 
 		assert.strictEqual(getCheckForToolUpdatesConfig(gocfg), 'proxy');
 	});
@@ -72,7 +72,7 @@
 			.withArgs(LEGACY_CHECK_FOR_UPDATES).returns(false)
 			.withArgs(CHECK_FOR_UPDATES).returns('off');
 		sinon.stub(gocfg, 'inspect').withArgs(CHECK_FOR_UPDATES).returns(
-			Object.assign({}, defaultConfigInspector, {	workspaceValue: 'off' }));
+			Object.assign({}, defaultConfigInspector, { workspaceValue: 'off' }));
 		assert.strictEqual(getCheckForToolUpdatesConfig(gocfg), 'off');
 	});
 });
@@ -176,7 +176,6 @@
 				env: {},
 				features: {
 					diagnostics: true,
-					documentLink: true,
 				},
 				flags: [],
 				modtime: new Date(),