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

Commit

Permalink
Use gotype-live only in non module & non gopls scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed May 24, 2019
1 parent 293bd31 commit d1bf95c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/goLiveErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import cp = require('child_process');
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 {
Expand Down Expand Up @@ -53,7 +54,12 @@ export function parseLiveFile(e: vscode.TextDocumentChangeEvent) {
}

// 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');
Expand Down
6 changes: 5 additions & 1 deletion src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ export function activate(ctx: vscode.ExtensionContext): void {
});

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()));
Expand All @@ -300,6 +304,7 @@ export function activate(ctx: vscode.ExtensionContext): void {
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()) {
Expand Down Expand Up @@ -328,7 +333,6 @@ export function activate(ctx: vscode.ExtensionContext): void {
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);

Expand Down

0 comments on commit d1bf95c

Please sign in to comment.