Skip to content

Commit 9aa7363

Browse files
committed
Merge branch 'master' of https://github.com/stamblerre/vscode-go into go-langserver
2 parents 137073b + 341a4ff commit 9aa7363

14 files changed

+138
-1573
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ language: go
33
dist: bionic
44

55
go:
6-
- 1.11.x
76
- 1.12.x
87
- 1.13.x
8+
- 1.14.x
99
- tip
1010

1111
git:

CHANGELOG.md

Lines changed: 5 additions & 1511 deletions
Large diffs are not rendered by default.

METADATA

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: "vscode-go"
2+
description:
3+
"Fork of github.com/Microsoft/vscode-go (the VSCode plugin for Go). "
4+
"This fork is kept in sync with the upstream while includes "
5+
"new features [email protected] team is developing and experimenting. "
6+
""
7+
8+
third_party {
9+
url {
10+
type: GIT
11+
value: "https://github.com/Microsoft/vscode-go"
12+
}
13+
version: "master"
14+
last_upgrade_date { year: 2020 month: 1 day: 8 }
15+
license_type: NOTICE
16+
}

README.md

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
1-
# Go for Visual Studio Code
2-
3-
[![Join the chat at https://gitter.im/Microsoft/vscode-go](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/vscode-go?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/Microsoft/vscode-go.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-go)
4-
5-
This extension adds rich language support for the [Go language](https://golang.org/) to VS Code.
6-
7-
Read the [Changelog](https://github.com/Microsoft/vscode-go/blob/master/CHANGELOG.md) to know what has changed over the last few versions of this extension.
1+
# Go Nightly for VS Code
2+
3+
> ### **ATTENTION**
4+
>**Go Nightly for VS Code** is the insider version of
5+
[VS Code Go extension](https://github.com/microsoft/vscode-go)
6+
for early feedback and testing. This extension works best with
7+
[VS Code Insiders](https://code.visualstudio.com/insiders).
8+
Go Nightly contains previews of new features and bug fixes that are still
9+
under review or testing, so can be unstable. If you are looking for the stable version,
10+
please use [the stable version](https://marketplace.visualstudio.com/items?itemName=ms-vscode.go) instead.
11+
>
12+
> **NOTE:**
13+
If you have both stable (aka "Go") and nightly version (aka "Go Nightly") installed,
14+
you MUST DISABLE one of them. Docs on how to disable an extension can be found
15+
[here](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension).
16+
17+
> ### Difference between VS Code Go and VS Code Go Nightly
18+
> - Go Nightly is maintained and released by Go Tools team at Google.
19+
> - Go Nightly is released more frequently than the stable version.
20+
> - Go Nightly includes features and bug fixes that are still under testing or not finalized yet.
21+
> - Go Nightly may use the latest pre-release versions of tools (e.g. `gopls`) instead of release versions.
22+
> - For now, Go and Go Nightly maintain separate repositories. Both repositories
23+
> welcome all contributors. For contribution to Go Nightly repo, see the Go
24+
> project's [contribution guide](https://golang.org/doc/contribute.html).
25+
> Go team members who has signed the Microsoft CLA will send a syncing PR upstream to
26+
> https://github.com/microsoft/vscode-go every two weeks.
27+
> - [Here](https://github.com/microsoft/vscode-go/compare/master...golang:master) is the full list of local modifications.
828
929
## Table of Contents
1030

@@ -36,16 +56,16 @@ Read the [Changelog](https://github.com/Microsoft/vscode-go/blob/master/CHANGELO
3656

3757
### IntelliSense
3858

39-
- Auto Completion of symbols as you type (using `gocode`)
40-
- Signature Help for functions as you type (using `gogetdoc` or `godef`+`go doc`)
41-
- Quick Info on the symbol as you hover over it (using `gogetdoc` or `godef`+`go doc`)
59+
- Auto Completion of symbols as you type (using language server or `gocode`)
60+
- Signature Help for functions as you type (using language server or `gogetdoc` or `godef`+`go doc`)
61+
- Quick Info on the symbol as you hover over it (using language server or `gogetdoc` or `godef`+`go doc`)
4262

4363
### Code Navigation
4464

45-
- Go to or Peek Definition of symbols (using `gogetdoc` or `godef`+`go doc`)
46-
- Find References of symbols and Implementations of interfaces (using `guru`)
65+
- Go to or Peek Definition of symbols (using language server or `gogetdoc` or `godef`+`go doc`)
66+
- Find References of symbols and Implementations of interfaces (using language server or `guru`)
4767
- Go to symbol in file or see the file outline (using `go-outline`)
48-
- Go to symbol in workspace (using `go-symbols`)
68+
- Go to symbol in workspace (using language server or `go-symbols`)
4969
- Toggle between a Go program and the corresponding test file.
5070

5171
### Code Editing
@@ -93,7 +113,7 @@ You will see `Analysis Tools Missing` in the bottom right, clicking this will of
93113

94114
**Note 2**: The `Format on save` feature has a timeout of 750ms after which the formatting is aborted. You can change this timeout using the setting `editor.formatOnSaveTimeout`. This feature gets disabled when you have enabled the `Auto Save` feature in Visual Studio Code.
95115

96-
**Note 3**: This extension uses `gocode` to provide completion lists as you type. If you have disabled the `go.buildOnSave` setting, then you may not get fresh results from not-yet-built dependencies. Therefore, ensure you have built your dependencies manually in such cases.
116+
**Note 3**: Unless `go.useLanguageServer` is set to `true`, this extension uses `gocode` to provide completion lists as you type. If you have disabled the `go.buildOnSave` setting, then you may not get fresh results from not-yet-built dependencies. Therefore, ensure you have built your dependencies manually in such cases.
97117

98118
### Customizing the Go extension features
99119

@@ -117,7 +137,7 @@ Previously, we added support to use `go-langserver`, the [language server from S
117137

118138
Ideally, you would see prompts to use/install/update the language server.
119139
Follow the prompts and the language server should get set up correctly.
120-
If you want to manually install/update the language server,
140+
If you want to manually install/update the language server,
121141
- Ensure you have set `go.useLanguageServer` to `true` in your settings
122142
- Use the `Go: Install/Update Tools` command, select `gopls` from the list and press Ok.
123143

@@ -126,7 +146,8 @@ If you want to manually install/update the language server,
126146

127147
Below are the settings you can use to control the use of the language server. You need to reload the VS Code window for any changes in these settings to take effect.
128148

129-
- Set `go.useLanguageServer` to `true` to enable the use of language server
149+
- Set `go.useLanguageServer` to `true` to enable the use of language server.
150+
- When using `gopls`, see the [recommended settings](https://github.com/golang/tools/blob/master/gopls/doc/vscode.md).
130151
- Some of the features from the language server can be disabled if needed using the setting `go.languageServerExperimentalFeatures`. Below are the features you can thus control. By default, all are set to `true` i.e are enabled.
131152
```json
132153
"go.languageServerExperimentalFeatures": {

build/cloudbuild.container.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
steps:
2+
- name: 'gcr.io/cloud-builders/docker'
3+
args: ['build', '-t', 'gcr.io/$PROJECT_ID/vscode-test-env', '-f', 'build/Dockerfile', '.']
4+
images:
5+
- 'gcr.io/$PROJECT_ID/vscode-test-env'

build/cloudbuild.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
steps:
2+
- name: 'gcr.io/$PROJECT_ID/vscode-test-env'
3+
entrypoint: "./build/all.bash"
4+
args: ['ci']
5+
env:
6+
- 'BUILD=$BUILD_ID'
7+
- 'PROJECT=$PROJECT_ID'
8+
- 'REV=$REVISION_ID'
9+
timeout: 600s

package-lock.json

Lines changed: 17 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
2-
"name": "Go",
3-
"version": "0.13.0",
4-
"publisher": "ms-vscode",
5-
"description": "Rich Go language support for Visual Studio Code",
2+
"name": "go-nightly",
3+
"displayName": "Go Nightly",
4+
"version": "2020.3.144",
5+
"publisher": "golang",
6+
"description": "Rich Go language support for Visual Studio Code (Nightly)",
67
"author": {
7-
"name": "Microsoft Corporation - Development Labs"
8+
"name": "Go Team at Google"
89
},
10+
"preview": true,
911
"license": "MIT",
1012
"icon": "images/go-logo-blue.png",
1113
"categories": [
@@ -22,7 +24,10 @@
2224
"private": true,
2325
"repository": {
2426
"type": "git",
25-
"url": "https://github.com/Microsoft/vscode-go.git"
27+
"url": "https://github.com/golang/vscode-go"
28+
},
29+
"bugs": {
30+
"url": "https://github.com/golang/vscode-go/issues"
2631
},
2732
"keywords": [
2833
"multi-root ready"
@@ -47,7 +52,7 @@
4752
"vscode-debugadapter": "^1.36.0",
4853
"vscode-debugprotocol": "^1.36.0",
4954
"vscode-extension-telemetry": "^0.1.2",
50-
"vscode-languageclient": "~5.2.1",
55+
"vscode-languageclient": "6.1.0",
5156
"web-request": "^1.0.7"
5257
},
5358
"devDependencies": {
@@ -66,7 +71,7 @@
6671
"prettier": "^1.16.4"
6772
},
6873
"engines": {
69-
"vscode": "^1.30.0"
74+
"vscode": "^1.41.0"
7075
},
7176
"activationEvents": [
7277
"workspaceContains:**/*.go",
@@ -326,7 +331,11 @@
326331
"description": "Restart the running instance of the language server"
327332
}
328333
],
329-
"breakpoints": [{ "language": "go" }],
334+
"breakpoints": [
335+
{
336+
"language": "go"
337+
}
338+
],
330339
"debuggers": [
331340
{
332341
"type": "go",

src/goInstallTools.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ const declinedInstalls: Tool[] = [];
4242

4343
export async function installAllTools(updateExistingToolsOnly: boolean = false) {
4444
const goVersion = await getGoVersion();
45-
const allTools = getConfiguredTools(goVersion);
45+
let allTools = getConfiguredTools(goVersion);
46+
47+
// exclude tools replaced by alternateTools.
48+
const alternateTools: { [key: string]: string } = getGoConfig().get('alternateTools');
49+
allTools = allTools.filter((tool) => {
50+
return !alternateTools[tool.name];
51+
});
4652

4753
// Update existing tools by finding all tools the user has already installed.
4854
if (updateExistingToolsOnly) {

src/goLanguageServer.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { GoCompletionItemProvider } from './goSuggest';
3636
import { GoWorkspaceSymbolProvider } from './goSymbol';
3737
import { getTool, Tool } from './goTools';
3838
import { GoTypeDefinitionProvider } from './goTypeDefinition';
39-
import { getBinPath, getCurrentGoPath, getGoConfig, getToolsEnvVars } from './util';
39+
import { getBinPath, getCurrentGoPath, getGoConfig, getToolsEnvVars, isForNightly } from './util';
4040

4141
interface LanguageServerConfig {
4242
enabled: boolean;
@@ -366,8 +366,8 @@ function registerUsualProviders(ctx: vscode.ExtensionContext) {
366366
vscode.workspace.onDidChangeTextDocument(parseLiveFile, null, ctx.subscriptions);
367367
}
368368

369-
const defaultLatestVersion = semver.coerce('0.1.7');
370-
const defaultLatestVersionTime = moment('2019-09-18', 'YYYY-MM-DD');
369+
const defaultLatestVersion = semver.coerce('0.3.1');
370+
const defaultLatestVersionTime = moment('2020-02-04', 'YYYY-MM-DD');
371371
async function shouldUpdateLanguageServer(
372372
tool: Tool,
373373
languageServerToolPath: string,
@@ -391,8 +391,8 @@ async function shouldUpdateLanguageServer(
391391
return false;
392392
}
393393

394-
// Get the latest gopls version.
395-
let latestVersion = makeProxyCall ? await latestGopls(tool) : defaultLatestVersion;
394+
// Get the latest gopls version. If it is for nightly, using the prereleased version is ok.
395+
let latestVersion = makeProxyCall ? await latestGopls(tool, isForNightly) : defaultLatestVersion;
396396

397397
// If we failed to get the gopls version, pick the one we know to be latest at the time of this extension's last update
398398
if (!latestVersion) {
@@ -467,7 +467,7 @@ async function goplsVersionTimestamp(tool: Tool, version: semver.SemVer): Promis
467467
return time;
468468
}
469469

470-
async function latestGopls(tool: Tool): Promise<semver.SemVer> {
470+
async function latestGopls(tool: Tool, includePrerelease: boolean): Promise<semver.SemVer> {
471471
// If the user has a version of gopls that we understand,
472472
// ask the proxy for the latest version, and if the user's version is older,
473473
// prompt them to update.
@@ -489,6 +489,9 @@ async function latestGopls(tool: Tool): Promise<semver.SemVer> {
489489
}
490490
versions.sort(semver.rcompare);
491491

492+
if (includePrerelease) {
493+
return versions[0]; // The first one in the prerelease.
494+
}
492495
// The first version in the sorted list without a prerelease tag.
493496
return versions.find((version) => !version.prerelease || !version.prerelease.length);
494497
}

src/goSymbol.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ export class GoWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvider
3535
token: vscode.CancellationToken
3636
): Thenable<vscode.SymbolInformation[]> {
3737
const convertToCodeSymbols = (decls: GoSymbolDeclaration[], symbols: vscode.SymbolInformation[]): void => {
38-
decls.forEach((decl) => {
38+
if (!decls) {
39+
return;
40+
}
41+
for (const decl of decls) {
3942
let kind: vscode.SymbolKind;
4043
if (decl.kind !== '') {
4144
kind = this.goKindToCodeKind[decl.kind];
@@ -49,7 +52,7 @@ export class GoWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvider
4952
''
5053
);
5154
symbols.push(symbolInfo);
52-
});
55+
}
5356
};
5457
const root = getWorkspaceFolderPath(
5558
vscode.window.activeTextEditor && vscode.window.activeTextEditor.document.uri

src/goTools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const allToolsInformation: { [key: string]: Tool } = {
149149
},
150150
'gopkgs': {
151151
name: 'gopkgs',
152-
importPath: 'github.com/uudashr/gopkgs/cmd/gopkgs',
152+
importPath: 'github.com/uudashr/gopkgs/v2/cmd/gopkgs',
153153
isImportant: true,
154154
description: 'Auto-completion of unimported packages & Add Import feature'
155155
},

src/telemetry.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import vscode = require('vscode');
77
import TelemetryReporter from 'vscode-extension-telemetry';
88

9-
export const extensionId: string = 'ms-vscode.Go';
9+
export const extensionId: string = 'golang.go-nightly';
1010
const extension = vscode.extensions.getExtension(extensionId);
1111
const extensionVersion: string = extension ? extension.packageJSON.version : '';
12-
const aiKey: string = 'AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217';
12+
const aiKey: string = ''; // Empty aiKey disables telemetry.
1313

1414
export function sendTelemetryEventForModulesUsage() {
1515
/* __GDPR__
@@ -183,6 +183,9 @@ function sendTelemetryEvent(
183183
properties?: { [key: string]: string },
184184
measures?: { [key: string]: number }
185185
): void {
186+
if (!aiKey) {
187+
return; // cannot enable telemetry
188+
}
186189
telemtryReporter = telemtryReporter
187190
? telemtryReporter
188191
: new TelemetryReporter(extensionId, extensionVersion, aiKey);

src/util.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,3 +1052,6 @@ export function isPositionInComment(document: vscode.TextDocument, position: vsc
10521052
}
10531053
return false;
10541054
}
1055+
1056+
// isForNightly is true if the source code is built for a preview version of the extension.
1057+
export const isForNightly: boolean = extensionId.endsWith('.go-nightly');

0 commit comments

Comments
 (0)