Use gotype-live only in non module & non gopls scenarios
diff --git a/src/goLiveErrors.ts b/src/goLiveErrors.ts
index 3476572..fa02be9 100644
--- a/src/goLiveErrors.ts
+++ b/src/goLiveErrors.ts
@@ -6,6 +6,7 @@
import path = require('path');
import { promptForMissingTool } from './goInstallTools';
import { buildDiagnosticCollection } from './goMain';
+import { isModSupported } from './goModules';
// Interface for settings configuration for adding and removing tags
interface GoLiveErrorsConfig {
@@ -53,7 +54,12 @@
}
// processFile does the actual work once the timeout has fired
-function processFile(e: vscode.TextDocumentChangeEvent) {
+async function processFile(e: vscode.TextDocumentChangeEvent) {
+ const isMod = await isModSupported(e.document.uri);
+ if (isMod) {
+ return;
+ }
+
const gotypeLive = getBinPath('gotype-live');
if (!path.isAbsolute(gotypeLive)) {
return promptForMissingTool('gotype-live');
diff --git a/src/goMain.ts b/src/goMain.ts
index 9c52869..cb2f578 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -288,6 +288,10 @@
});
ctx.subscriptions.push(c.start());
+
+ if (languageServerTool !== 'gopls' || !languageServerExperimentalFeatures['diagnostics']) {
+ vscode.workspace.onDidChangeTextDocument(parseLiveFile, null, ctx.subscriptions);
+ }
} else {
registerCompletionProvider(ctx);
ctx.subscriptions.push(vscode.languages.registerHoverProvider(GO_MODE, new GoHoverProvider()));
@@ -300,6 +304,7 @@
ctx.subscriptions.push(vscode.languages.registerDocumentFormattingEditProvider(GO_MODE, new GoDocumentFormattingEditProvider()));
ctx.subscriptions.push(vscode.languages.registerTypeDefinitionProvider(GO_MODE, new GoTypeDefinitionProvider()));
ctx.subscriptions.push(vscode.languages.registerRenameProvider(GO_MODE, new GoRenameProvider()));
+ vscode.workspace.onDidChangeTextDocument(parseLiveFile, null, ctx.subscriptions);
}
if (vscode.window.activeTextEditor && vscode.window.activeTextEditor.document.languageId === 'go' && isGoPathSet()) {
@@ -328,7 +333,6 @@
vscode.workspace.onDidChangeTextDocument(removeTestStatus, null, ctx.subscriptions);
vscode.window.onDidChangeActiveTextEditor(showHideStatus, null, ctx.subscriptions);
vscode.window.onDidChangeActiveTextEditor(applyCodeCoverage, null, ctx.subscriptions);
- vscode.workspace.onDidChangeTextDocument(parseLiveFile, null, ctx.subscriptions);
vscode.workspace.onDidChangeTextDocument(notifyIfGeneratedFile, ctx, ctx.subscriptions);
startBuildOnSaveWatcher(ctx.subscriptions);