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

Commit

Permalink
Revert "Support fork of goimports for modules #2098"
Browse files Browse the repository at this point in the history
This reverts commit d6b0f63.
  • Loading branch information
ramya-rao-a committed Nov 28, 2018
1 parent b04fe03 commit 56ef277
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
22 changes: 9 additions & 13 deletions src/goFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import cp = require('child_process');
import path = require('path');
import { promptForMissingTool, promptForUpdatingTool } from './goInstallTools';
import { sendTelemetryEvent, getBinPath, getToolsEnvVars, killTree } from './util';
import { isModSupported } from './goModules';

export class GoDocumentFormattingEditProvider implements vscode.DocumentFormattingEditProvider {

Expand All @@ -35,18 +34,15 @@ export class GoDocumentFormattingEditProvider implements vscode.DocumentFormatti
formatFlags.push('-style=indent=' + options.tabSize);
}

const formatToolPromise = formatTool !== 'goimports' ? Promise.resolve(formatTool) : isModSupported(document.uri).then(isMod => isMod ? 'goimports-gomod' : 'goimports');
return formatToolPromise.then(updatedFormatTool => {
return this.runFormatter(updatedFormatTool, formatFlags, document, token).then(edits => edits, err => {
if (typeof err === 'string' && err.startsWith('flag provided but not defined: -srcdir')) {
promptForUpdatingTool(updatedFormatTool);
return Promise.resolve([]);
}
if (err) {
console.log(err);
return Promise.reject('Check the console in dev tools to find errors when formatting.');
}
});
return this.runFormatter(formatTool, formatFlags, document, token).then(edits => edits, err => {
if (typeof err === 'string' && err.startsWith('flag provided but not defined: -srcdir')) {
promptForUpdatingTool(formatTool);
return Promise.resolve([]);
}
if (err) {
console.log(err);
return Promise.reject('Check the console in dev tools to find errors when formatting.');
}
});
}

Expand Down
10 changes: 0 additions & 10 deletions src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const _allTools: { [key: string]: string } = {
'godef-gomod': 'github.com/ianthehat/godef',
'gogetdoc': 'github.com/zmb3/gogetdoc',
'goimports': 'golang.org/x/tools/cmd/goimports',
'goimports-gomod': 'github.com/heschik/goimports/cmd/goimports',
'goreturns': 'github.com/sqs/goreturns',
'goformat': 'winterdrache.de/goformat/goformat',
'golint': 'golang.org/x/lint/golint',
Expand Down Expand Up @@ -66,7 +65,6 @@ const importantTools = [
'gogetdoc',
'goreturns',
'goimports',
'goimports-gomod',
'golint',
'gometalinter',
'megacheck',
Expand Down Expand Up @@ -104,10 +102,6 @@ function getTools(goVersion: SemVersion): string[] {
// Install the formattool that was chosen by the user
if (goConfig['formatTool'] === 'goimports') {
tools.push('goimports');
// godef-gomod needed in go 1.11 & higher
if (!goVersion || (goVersion.major === 1 && goVersion.minor >= 11)) {
tools.push('goimports-gomod');
}
} else if (goConfig['formatTool'] === 'goformat') {
tools.push('goformat');
} else if (goConfig['formatTool'] === 'goreturns') {
Expand Down Expand Up @@ -180,7 +174,6 @@ export function installAllTools(updateExistingToolsOnly: boolean = false) {
'godef-gomod': '\t(Go to definition, works with Modules)',
'gogetdoc': '\t(Go to definition & text shown on hover)',
'goimports': '\t(Formatter)',
'goimports-gomod': '\t(Formatter, works with Modules)',
'goreturns': '\t(Formatter)',
'goformat': '\t(Formatter)',
'golint': '\t\t(Linter)',
Expand Down Expand Up @@ -247,10 +240,7 @@ export function promptForMissingTool(tool: string) {
msg = `To provide auto-completions when using Go modules, we are testing a fork(${getToolImportPath(tool, goVersion)}) of "gocode" and an updated version of "gopkgs". Please press the Install button to install them.`;
} else if (tool === 'godef-gomod') {
msg = `To provide the Go to definition feature when using Go modules, we are testing a fork(${getToolImportPath(tool, goVersion)}) of "godef". Please press the Install button to install it.`;
} else if (tool === 'goimports-gomod') {
msg = `To provide the formatting feature when using Go modules, we are testing a fork(${getToolImportPath(tool, goVersion)}) of "goimports". Please press the Install button to install it.`;
}

vscode.window.showInformationMessage(msg, ...items).then(selected => {
if (selected === 'Install') {
if (tool === 'gocode-gomod') {
Expand Down

0 comments on commit 56ef277

Please sign in to comment.