Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/stamblerre/vscode-go into…
Browse files Browse the repository at this point in the history
… go-langserver
  • Loading branch information
stamblerre committed Mar 6, 2020
2 parents 137073b + 341a4ff commit 9aa7363
Show file tree
Hide file tree
Showing 14 changed files with 138 additions and 1,573 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ language: go
dist: bionic

go:
- 1.11.x
- 1.12.x
- 1.13.x
- 1.14.x
- tip

git:
Expand Down
1,516 changes: 5 additions & 1,511 deletions CHANGELOG.md

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "vscode-go"
description:
"Fork of github.com/Microsoft/vscode-go (the VSCode plugin for Go). "
"This fork is kept in sync with the upstream while includes "
"new features go-tools@google.com team is developing and experimenting. "
""

third_party {
url {
type: GIT
value: "https://github.com/Microsoft/vscode-go"
}
version: "master"
last_upgrade_date { year: 2020 month: 1 day: 8 }
license_type: NOTICE
}
53 changes: 37 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
# Go for Visual Studio Code

[![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)

This extension adds rich language support for the [Go language](https://golang.org/) to VS Code.

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.
# Go Nightly for VS Code

> ### **ATTENTION**
>**Go Nightly for VS Code** is the insider version of
[VS Code Go extension](https://github.com/microsoft/vscode-go)
for early feedback and testing. This extension works best with
[VS Code Insiders](https://code.visualstudio.com/insiders).
Go Nightly contains previews of new features and bug fixes that are still
under review or testing, so can be unstable. If you are looking for the stable version,
please use [the stable version](https://marketplace.visualstudio.com/items?itemName=ms-vscode.go) instead.
>
> **NOTE:**
If you have both stable (aka "Go") and nightly version (aka "Go Nightly") installed,
you MUST DISABLE one of them. Docs on how to disable an extension can be found
[here](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension).

> ### Difference between VS Code Go and VS Code Go Nightly
> - Go Nightly is maintained and released by Go Tools team at Google.
> - Go Nightly is released more frequently than the stable version.
> - Go Nightly includes features and bug fixes that are still under testing or not finalized yet.
> - Go Nightly may use the latest pre-release versions of tools (e.g. `gopls`) instead of release versions.
> - For now, Go and Go Nightly maintain separate repositories. Both repositories
> welcome all contributors. For contribution to Go Nightly repo, see the Go
> project's [contribution guide](https://golang.org/doc/contribute.html).
> Go team members who has signed the Microsoft CLA will send a syncing PR upstream to
> https://github.com/microsoft/vscode-go every two weeks.
> - [Here](https://github.com/microsoft/vscode-go/compare/master...golang:master) is the full list of local modifications.
## Table of Contents

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

### IntelliSense

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

### Code Navigation

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

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

**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.

**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.
**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.

### Customizing the Go extension features

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

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

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

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.

- Set `go.useLanguageServer` to `true` to enable the use of language server
- Set `go.useLanguageServer` to `true` to enable the use of language server.
- When using `gopls`, see the [recommended settings](https://github.com/golang/tools/blob/master/gopls/doc/vscode.md).
- 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.
```json
"go.languageServerExperimentalFeatures": {
Expand Down
5 changes: 5 additions & 0 deletions build/cloudbuild.container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/vscode-test-env', '-f', 'build/Dockerfile', '.']
images:
- 'gcr.io/$PROJECT_ID/vscode-test-env'
9 changes: 9 additions & 0 deletions build/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
steps:
- name: 'gcr.io/$PROJECT_ID/vscode-test-env'
entrypoint: "./build/all.bash"
args: ['ci']
env:
- 'BUILD=$BUILD_ID'
- 'PROJECT=$PROJECT_ID'
- 'REV=$REVISION_ID'
timeout: 600s
41 changes: 17 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 18 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"name": "Go",
"version": "0.13.0",
"publisher": "ms-vscode",
"description": "Rich Go language support for Visual Studio Code",
"name": "go-nightly",
"displayName": "Go Nightly",
"version": "2020.3.144",
"publisher": "golang",
"description": "Rich Go language support for Visual Studio Code (Nightly)",
"author": {
"name": "Microsoft Corporation - Development Labs"
"name": "Go Team at Google"
},
"preview": true,
"license": "MIT",
"icon": "images/go-logo-blue.png",
"categories": [
Expand All @@ -22,7 +24,10 @@
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-go.git"
"url": "https://github.com/golang/vscode-go"
},
"bugs": {
"url": "https://github.com/golang/vscode-go/issues"
},
"keywords": [
"multi-root ready"
Expand All @@ -47,7 +52,7 @@
"vscode-debugadapter": "^1.36.0",
"vscode-debugprotocol": "^1.36.0",
"vscode-extension-telemetry": "^0.1.2",
"vscode-languageclient": "~5.2.1",
"vscode-languageclient": "6.1.0",
"web-request": "^1.0.7"
},
"devDependencies": {
Expand All @@ -66,7 +71,7 @@
"prettier": "^1.16.4"
},
"engines": {
"vscode": "^1.30.0"
"vscode": "^1.41.0"
},
"activationEvents": [
"workspaceContains:**/*.go",
Expand Down Expand Up @@ -326,7 +331,11 @@
"description": "Restart the running instance of the language server"
}
],
"breakpoints": [{ "language": "go" }],
"breakpoints": [
{
"language": "go"
}
],
"debuggers": [
{
"type": "go",
Expand Down
8 changes: 7 additions & 1 deletion src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ const declinedInstalls: Tool[] = [];

export async function installAllTools(updateExistingToolsOnly: boolean = false) {
const goVersion = await getGoVersion();
const allTools = getConfiguredTools(goVersion);
let allTools = getConfiguredTools(goVersion);

// exclude tools replaced by alternateTools.
const alternateTools: { [key: string]: string } = getGoConfig().get('alternateTools');
allTools = allTools.filter((tool) => {
return !alternateTools[tool.name];
});

// Update existing tools by finding all tools the user has already installed.
if (updateExistingToolsOnly) {
Expand Down
15 changes: 9 additions & 6 deletions src/goLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { GoCompletionItemProvider } from './goSuggest';
import { GoWorkspaceSymbolProvider } from './goSymbol';
import { getTool, Tool } from './goTools';
import { GoTypeDefinitionProvider } from './goTypeDefinition';
import { getBinPath, getCurrentGoPath, getGoConfig, getToolsEnvVars } from './util';
import { getBinPath, getCurrentGoPath, getGoConfig, getToolsEnvVars, isForNightly } from './util';

interface LanguageServerConfig {
enabled: boolean;
Expand Down Expand Up @@ -366,8 +366,8 @@ function registerUsualProviders(ctx: vscode.ExtensionContext) {
vscode.workspace.onDidChangeTextDocument(parseLiveFile, null, ctx.subscriptions);
}

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

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

// 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
if (!latestVersion) {
Expand Down Expand Up @@ -467,7 +467,7 @@ async function goplsVersionTimestamp(tool: Tool, version: semver.SemVer): Promis
return time;
}

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

if (includePrerelease) {
return versions[0]; // The first one in the prerelease.
}
// The first version in the sorted list without a prerelease tag.
return versions.find((version) => !version.prerelease || !version.prerelease.length);
}
Expand Down
7 changes: 5 additions & 2 deletions src/goSymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export class GoWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvider
token: vscode.CancellationToken
): Thenable<vscode.SymbolInformation[]> {
const convertToCodeSymbols = (decls: GoSymbolDeclaration[], symbols: vscode.SymbolInformation[]): void => {
decls.forEach((decl) => {
if (!decls) {
return;
}
for (const decl of decls) {
let kind: vscode.SymbolKind;
if (decl.kind !== '') {
kind = this.goKindToCodeKind[decl.kind];
Expand All @@ -49,7 +52,7 @@ export class GoWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvider
''
);
symbols.push(symbolInfo);
});
}
};
const root = getWorkspaceFolderPath(
vscode.window.activeTextEditor && vscode.window.activeTextEditor.document.uri
Expand Down
2 changes: 1 addition & 1 deletion src/goTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const allToolsInformation: { [key: string]: Tool } = {
},
'gopkgs': {
name: 'gopkgs',
importPath: 'github.com/uudashr/gopkgs/cmd/gopkgs',
importPath: 'github.com/uudashr/gopkgs/v2/cmd/gopkgs',
isImportant: true,
description: 'Auto-completion of unimported packages & Add Import feature'
},
Expand Down
7 changes: 5 additions & 2 deletions src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import vscode = require('vscode');
import TelemetryReporter from 'vscode-extension-telemetry';

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

export function sendTelemetryEventForModulesUsage() {
/* __GDPR__
Expand Down Expand Up @@ -183,6 +183,9 @@ function sendTelemetryEvent(
properties?: { [key: string]: string },
measures?: { [key: string]: number }
): void {
if (!aiKey) {
return; // cannot enable telemetry
}
telemtryReporter = telemtryReporter
? telemtryReporter
: new TelemetryReporter(extensionId, extensionVersion, aiKey);
Expand Down
3 changes: 3 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1052,3 +1052,6 @@ export function isPositionInComment(document: vscode.TextDocument, position: vsc
}
return false;
}

// isForNightly is true if the source code is built for a preview version of the extension.
export const isForNightly: boolean = extensionId.endsWith('.go-nightly');

0 comments on commit 9aa7363

Please sign in to comment.