From 9dae94a78dd5b660dd97f884b91067c55b4a418e Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 7 Mar 2020 23:59:33 +0200 Subject: vscode: contribute "alwaysDownloadServer" option to config --- editors/code/package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/editors/code/package.json b/editors/code/package.json index 225739328..7bcd45e15 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -219,6 +219,11 @@ } } }, + "rust-analyzer.alwaysDownloadServer": { + "type": "boolean", + "default": false, + "description": "Whether to ask before downloading the language server binary" + }, "rust-analyzer.serverPath": { "type": [ "null", -- cgit v1.2.3 From c29a502e2549aba7e47a6f40581e5ccf74b5f481 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 8 Mar 2020 00:01:48 +0200 Subject: vscode: care about alwaysDownloadServer option before asking Also renamed BinarySource to ArtifactSource in anticipation of nightlies installation that requires downloading not a binary itself but .vsix package, thus generalized to `artifact` term --- editors/code/src/config.ts | 11 ++++++----- editors/code/src/installation/interfaces.ts | 15 ++++++++++----- editors/code/src/installation/server.ts | 28 +++++++++++++++------------- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index bf915102c..c4acb632d 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -1,6 +1,6 @@ import * as os from "os"; import * as vscode from 'vscode'; -import { BinarySource } from "./installation/interfaces"; +import { ArtifactSource } from "./installation/interfaces"; import { log } from "./util"; const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; @@ -114,12 +114,12 @@ export class Config { } } - get serverSource(): null | BinarySource { + get serverSource(): null | ArtifactSource { const serverPath = RA_LSP_DEBUG ?? this.cfg.get("serverPath"); if (serverPath) { return { - type: BinarySource.Type.ExplicitPath, + type: ArtifactSource.Type.ExplicitPath, path: Config.replaceTildeWithHomeDir(serverPath) }; } @@ -129,11 +129,12 @@ export class Config { if (!prebuiltBinaryName) return null; return { - type: BinarySource.Type.GithubRelease, + type: ArtifactSource.Type.GithubRelease, dir: this.ctx.globalStoragePath, file: prebuiltBinaryName, storage: this.ctx.globalState, - version: Config.extensionVersion, + tag: Config.extensionVersion, + askBeforeDownload: !(this.cfg.get("alwaysDownloadServer") as boolean), repo: { name: "rust-analyzer", owner: "rust-analyzer", diff --git a/editors/code/src/installation/interfaces.ts b/editors/code/src/installation/interfaces.ts index e40839e4b..50b635921 100644 --- a/editors/code/src/installation/interfaces.ts +++ b/editors/code/src/installation/interfaces.ts @@ -14,14 +14,14 @@ export interface ArtifactReleaseInfo { } /** - * Represents the source of a binary artifact which is either specified by the user + * Represents the source of a an artifact which is either specified by the user * explicitly, or bundled by this extension from GitHub releases. */ -export type BinarySource = BinarySource.ExplicitPath | BinarySource.GithubRelease; +export type ArtifactSource = ArtifactSource.ExplicitPath | ArtifactSource.GithubRelease; -export namespace BinarySource { +export namespace ArtifactSource { /** - * Type tag for `BinarySource` discriminated union. + * Type tag for `ArtifactSource` discriminated union. */ export const enum Type { ExplicitPath, GithubRelease } @@ -56,13 +56,18 @@ export namespace BinarySource { /** * Tag of github release that denotes a version required by this extension. */ - version: string; + tag: string; /** * Object that provides `get()/update()` operations to store metadata * about the actual binary, e.g. its actual version. */ storage: vscode.Memento; + + /** + * Ask for the user permission before downloading the artifact. + */ + askBeforeDownload: boolean; } } diff --git a/editors/code/src/installation/server.ts b/editors/code/src/installation/server.ts index 6a6cf4f8c..ef1c45ff6 100644 --- a/editors/code/src/installation/server.ts +++ b/editors/code/src/installation/server.ts @@ -3,12 +3,12 @@ import * as path from "path"; import { promises as dns } from "dns"; import { spawnSync } from "child_process"; -import { BinarySource } from "./interfaces"; +import { ArtifactSource } from "./interfaces"; import { fetchArtifactReleaseInfo } from "./fetch_artifact_release_info"; import { downloadArtifact } from "./download_artifact"; import { log, assert } from "../util"; -export async function ensureServerBinary(source: null | BinarySource): Promise { +export async function ensureServerBinary(source: null | ArtifactSource): Promise { if (!source) { vscode.window.showErrorMessage( "Unfortunately we don't ship binaries for your platform yet. " + @@ -22,7 +22,7 @@ export async function ensureServerBinary(source: null | BinarySource): Promise { +async function downloadServer(source: ArtifactSource.GithubRelease): Promise { try { - const releaseInfo = await fetchArtifactReleaseInfo(source.repo, source.file, source.version); + const releaseInfo = await fetchArtifactReleaseInfo(source.repo, source.file, source.tag); await downloadArtifact(releaseInfo, source.file, source.dir, "language server"); await setServerVersion(source.storage, releaseInfo.releaseName); -- cgit v1.2.3 From 49b4e88458561986009f3cb9dee8879a0649049e Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 8 Mar 2020 18:51:21 +0200 Subject: vscode: add docs on alwaysDownloadServer --- docs/user/readme.adoc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc index f1386a8f9..fb3312614 100644 --- a/docs/user/readme.adoc +++ b/docs/user/readme.adoc @@ -30,7 +30,7 @@ $ rustup component add rust-src === VS Code -This the best supported editor at the moment. +This is the best supported editor at the moment. rust-analyzer plugin for VS Code is maintained https://github.com/rust-analyzer/rust-analyzer/tree/master/editors/code[in tree]. @@ -40,6 +40,13 @@ By default, the plugin will prompt you to download the matching version of the s image::https://user-images.githubusercontent.com/9021944/75067008-17502500-54ba-11ea-835a-f92aac50e866.png[] +> Note: to disable this notification put the following to `settings.json` +> ```json +{ + "rust-analyzer.alwaysDownloadServer": true +} +``` + The server binary is stored in `~/.config/Code/User/globalStorage/matklad.rust-analyzer`. Note that we only support the latest version of VS Code. -- cgit v1.2.3 From 6bd1ff16e5e517c89a154b9b26847d20656e1184 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 8 Mar 2020 18:58:02 +0200 Subject: vscode: rename alwaysDownloadServer -> askBeforeDownload The new name seems much simpler and it doesn't limit this config value only to downloading the server binary. Thus we wouldn't need to create another config properties to handle other downloads whatsoever. Anyway, I believe (heuristically) that most of the users would want to set "askBeforeDownload": false once and never bother clicking on the notification again (because otherwise there is no big point in installing rust-analyzer if it cannot install the server) --- docs/user/readme.adoc | 2 +- editors/code/package.json | 6 +++--- editors/code/src/config.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc index fb3312614..4ce05a26c 100644 --- a/docs/user/readme.adoc +++ b/docs/user/readme.adoc @@ -43,7 +43,7 @@ image::https://user-images.githubusercontent.com/9021944/75067008-17502500-54ba- > Note: to disable this notification put the following to `settings.json` > ```json { - "rust-analyzer.alwaysDownloadServer": true + "rust-analyzer.askBeforeDownload": false } ``` diff --git a/editors/code/package.json b/editors/code/package.json index 7bcd45e15..430a61c64 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -219,10 +219,10 @@ } } }, - "rust-analyzer.alwaysDownloadServer": { + "rust-analyzer.askBeforeDownload": { "type": "boolean", - "default": false, - "description": "Whether to ask before downloading the language server binary" + "default": true, + "description": "Whether to ask for permission before downloading any files from the Internet" }, "rust-analyzer.serverPath": { "type": [ diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index c4acb632d..cb9af86c0 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -134,7 +134,7 @@ export class Config { file: prebuiltBinaryName, storage: this.ctx.globalState, tag: Config.extensionVersion, - askBeforeDownload: !(this.cfg.get("alwaysDownloadServer") as boolean), + askBeforeDownload: !(this.cfg.get("askBeforeDownload") as boolean), repo: { name: "rust-analyzer", owner: "rust-analyzer", -- cgit v1.2.3 From 2847636d3038fd6274d278170d75fe3c0c5ecaf0 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 8 Mar 2020 19:01:31 +0200 Subject: docs: change formatting --- docs/user/readme.adoc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc index 4ce05a26c..d2feac0d7 100644 --- a/docs/user/readme.adoc +++ b/docs/user/readme.adoc @@ -2,6 +2,13 @@ :toc: preamble :sectanchors: :page-layout: post +// https://gist.github.com/dcode/0cfbf2699a1fe9b46ff04c41721dda74#admonitions +:tip-caption: :bulb: +:note-caption: :information_source: +:important-caption: :heavy_exclamation_mark: +:caution-caption: :fire: +:warning-caption: :warning: + // Master copy of this document lives in the https://github.com/rust-analyzer/rust-analyzer repository @@ -40,12 +47,15 @@ By default, the plugin will prompt you to download the matching version of the s image::https://user-images.githubusercontent.com/9021944/75067008-17502500-54ba-11ea-835a-f92aac50e866.png[] -> Note: to disable this notification put the following to `settings.json` -> ```json -{ - "rust-analyzer.askBeforeDownload": false -} -``` +[NOTE] +==== +To disable this notification put the following to `settings.json` + +[source,json] +---- +{ "rust-analyzer.askBeforeDownload": false } +---- +==== The server binary is stored in `~/.config/Code/User/globalStorage/matklad.rust-analyzer`. -- cgit v1.2.3 From de99fa71992b0d86e245b14a946b8c4914c1be6c Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 8 Mar 2020 21:47:35 +0200 Subject: vscode: fix inversion of askBeforeDownload --- editors/code/src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index cb9af86c0..948c12c2d 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -134,7 +134,7 @@ export class Config { file: prebuiltBinaryName, storage: this.ctx.globalState, tag: Config.extensionVersion, - askBeforeDownload: !(this.cfg.get("askBeforeDownload") as boolean), + askBeforeDownload: this.cfg.get("askBeforeDownload") as boolean, repo: { name: "rust-analyzer", owner: "rust-analyzer", -- cgit v1.2.3 From ce65cc949f9e183c7c166212b4f3d7d4abd102b0 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Mon, 9 Mar 2020 10:59:36 +0200 Subject: vscode: groupd updates-related config under `updates` section as per @matklad --- docs/user/readme.adoc | 2 +- editors/code/package.json | 2 +- editors/code/src/config.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc index d2feac0d7..e5843ed70 100644 --- a/docs/user/readme.adoc +++ b/docs/user/readme.adoc @@ -53,7 +53,7 @@ To disable this notification put the following to `settings.json` [source,json] ---- -{ "rust-analyzer.askBeforeDownload": false } +{ "rust-analyzer.updates.askBeforeDownload": false } ---- ==== diff --git a/editors/code/package.json b/editors/code/package.json index 430a61c64..6827c822b 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -219,7 +219,7 @@ } } }, - "rust-analyzer.askBeforeDownload": { + "rust-analyzer.updates.askBeforeDownload": { "type": "boolean", "default": true, "description": "Whether to ask for permission before downloading any files from the Internet" diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 948c12c2d..b72206d3c 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -134,7 +134,7 @@ export class Config { file: prebuiltBinaryName, storage: this.ctx.globalState, tag: Config.extensionVersion, - askBeforeDownload: this.cfg.get("askBeforeDownload") as boolean, + askBeforeDownload: this.cfg.get("updates.askBeforeDownload") as boolean, repo: { name: "rust-analyzer", owner: "rust-analyzer", -- cgit v1.2.3