diff options
Diffstat (limited to 'editors')
-rw-r--r-- | editors/code/package-lock.json | 11 | ||||
-rw-r--r-- | editors/code/package.json | 8 | ||||
-rw-r--r-- | editors/code/src/client.ts | 8 | ||||
-rw-r--r-- | editors/code/src/config.ts | 2 | ||||
-rw-r--r-- | editors/code/src/installation/download_artifact.ts | 21 | ||||
-rw-r--r-- | editors/code/src/main.ts | 4 |
6 files changed, 26 insertions, 28 deletions
diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json index 0288a468e..6901363fc 100644 --- a/editors/code/package-lock.json +++ b/editors/code/package-lock.json | |||
@@ -112,12 +112,6 @@ | |||
112 | "@types/node": "*" | 112 | "@types/node": "*" |
113 | } | 113 | } |
114 | }, | 114 | }, |
115 | "@types/throttle-debounce": { | ||
116 | "version": "2.1.0", | ||
117 | "resolved": "https://registry.npmjs.org/@types/throttle-debounce/-/throttle-debounce-2.1.0.tgz", | ||
118 | "integrity": "sha512-5eQEtSCoESnh2FsiLTxE121IiE60hnMqcb435fShf4bpLRjEu1Eoekht23y6zXS9Ts3l+Szu3TARnTsA0GkOkQ==", | ||
119 | "dev": true | ||
120 | }, | ||
121 | "@types/vscode": { | 115 | "@types/vscode": { |
122 | "version": "1.42.0", | 116 | "version": "1.42.0", |
123 | "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.42.0.tgz", | 117 | "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.42.0.tgz", |
@@ -1517,11 +1511,6 @@ | |||
1517 | "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", | 1511 | "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", |
1518 | "dev": true | 1512 | "dev": true |
1519 | }, | 1513 | }, |
1520 | "throttle-debounce": { | ||
1521 | "version": "2.1.0", | ||
1522 | "resolved": "https://registry.npmjs.org/throttle-debounce/-/throttle-debounce-2.1.0.tgz", | ||
1523 | "integrity": "sha512-AOvyNahXQuU7NN+VVvOOX+uW6FPaWdAOdRP5HfwYxAfCzXTFKRMoIMk+n+po318+ktcChx+F1Dd91G3YHeMKyg==" | ||
1524 | }, | ||
1525 | "through": { | 1514 | "through": { |
1526 | "version": "2.3.8", | 1515 | "version": "2.3.8", |
1527 | "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", | 1516 | "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", |
diff --git a/editors/code/package.json b/editors/code/package.json index dff535fcd..2a89987e8 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -18,6 +18,7 @@ | |||
18 | "engines": { | 18 | "engines": { |
19 | "vscode": "^1.42.0" | 19 | "vscode": "^1.42.0" |
20 | }, | 20 | }, |
21 | "enableProposedApi": true, | ||
21 | "scripts": { | 22 | "scripts": { |
22 | "vscode:prepublish": "tsc && rollup -c", | 23 | "vscode:prepublish": "tsc && rollup -c", |
23 | "package": "vsce package -o rust-analyzer.vsix", | 24 | "package": "vsce package -o rust-analyzer.vsix", |
@@ -27,7 +28,6 @@ | |||
27 | "dependencies": { | 28 | "dependencies": { |
28 | "jsonc-parser": "^2.1.0", | 29 | "jsonc-parser": "^2.1.0", |
29 | "node-fetch": "^2.6.0", | 30 | "node-fetch": "^2.6.0", |
30 | "throttle-debounce": "^2.1.0", | ||
31 | "vscode-languageclient": "^6.1.1" | 31 | "vscode-languageclient": "^6.1.1" |
32 | }, | 32 | }, |
33 | "devDependencies": { | 33 | "devDependencies": { |
@@ -35,7 +35,6 @@ | |||
35 | "@rollup/plugin-node-resolve": "^7.1.1", | 35 | "@rollup/plugin-node-resolve": "^7.1.1", |
36 | "@types/node": "^12.12.27", | 36 | "@types/node": "^12.12.27", |
37 | "@types/node-fetch": "^2.5.4", | 37 | "@types/node-fetch": "^2.5.4", |
38 | "@types/throttle-debounce": "^2.1.0", | ||
39 | "@types/vscode": "^1.42.0", | 38 | "@types/vscode": "^1.42.0", |
40 | "@typescript-eslint/eslint-plugin": "^2.20.0", | 39 | "@typescript-eslint/eslint-plugin": "^2.20.0", |
41 | "@typescript-eslint/parser": "^2.20.0", | 40 | "@typescript-eslint/parser": "^2.20.0", |
@@ -169,6 +168,11 @@ | |||
169 | "type": "object", | 168 | "type": "object", |
170 | "title": "Rust Analyzer", | 169 | "title": "Rust Analyzer", |
171 | "properties": { | 170 | "properties": { |
171 | "rust-analyzer.highlighting.semanticTokens": { | ||
172 | "type": "boolean", | ||
173 | "default": false, | ||
174 | "description": "Use proposed semantic tokens API for syntax highlighting" | ||
175 | }, | ||
172 | "rust-analyzer.highlightingOn": { | 176 | "rust-analyzer.highlightingOn": { |
173 | "type": "boolean", | 177 | "type": "boolean", |
174 | "default": false, | 178 | "default": false, |
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index aaf2ef40e..44bd04c21 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts | |||
@@ -3,6 +3,7 @@ import * as vscode from 'vscode'; | |||
3 | 3 | ||
4 | import { Config } from './config'; | 4 | import { Config } from './config'; |
5 | import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; | 5 | import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; |
6 | import { SemanticTokensFeature } from 'vscode-languageclient/lib/semanticTokens.proposed'; | ||
6 | 7 | ||
7 | export async function createClient(config: Config, serverPath: string): Promise<lc.LanguageClient> { | 8 | export async function createClient(config: Config, serverPath: string): Promise<lc.LanguageClient> { |
8 | // '.' Is the fallback if no folder is open | 9 | // '.' Is the fallback if no folder is open |
@@ -26,7 +27,7 @@ export async function createClient(config: Config, serverPath: string): Promise< | |||
26 | const clientOptions: lc.LanguageClientOptions = { | 27 | const clientOptions: lc.LanguageClientOptions = { |
27 | documentSelector: [{ scheme: 'file', language: 'rust' }], | 28 | documentSelector: [{ scheme: 'file', language: 'rust' }], |
28 | initializationOptions: { | 29 | initializationOptions: { |
29 | publishDecorations: true, | 30 | publishDecorations: !config.highlightingSemanticTokens, |
30 | lruCapacity: config.lruCapacity, | 31 | lruCapacity: config.lruCapacity, |
31 | maxInlayHintLength: config.maxInlayHintLength, | 32 | maxInlayHintLength: config.maxInlayHintLength, |
32 | cargoWatchEnable: cargoWatchOpts.enable, | 33 | cargoWatchEnable: cargoWatchOpts.enable, |
@@ -83,5 +84,10 @@ export async function createClient(config: Config, serverPath: string): Promise< | |||
83 | // Here we want to just enable CallHierarchyFeature since it is available on stable. | 84 | // Here we want to just enable CallHierarchyFeature since it is available on stable. |
84 | // Note that while the CallHierarchyFeature is stable the LSP protocol is not. | 85 | // Note that while the CallHierarchyFeature is stable the LSP protocol is not. |
85 | res.registerFeature(new CallHierarchyFeature(res)); | 86 | res.registerFeature(new CallHierarchyFeature(res)); |
87 | |||
88 | if (config.highlightingSemanticTokens) { | ||
89 | res.registerFeature(new SemanticTokensFeature(res)); | ||
90 | } | ||
91 | |||
86 | return res; | 92 | return res; |
87 | } | 93 | } |
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 47e8cd45d..bf915102c 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
@@ -22,6 +22,7 @@ export class Config { | |||
22 | private static readonly requiresReloadOpts = [ | 22 | private static readonly requiresReloadOpts = [ |
23 | "cargoFeatures", | 23 | "cargoFeatures", |
24 | "cargo-watch", | 24 | "cargo-watch", |
25 | "highlighting.semanticTokens" | ||
25 | ] | 26 | ] |
26 | .map(opt => `${Config.rootSection}.${opt}`); | 27 | .map(opt => `${Config.rootSection}.${opt}`); |
27 | 28 | ||
@@ -143,6 +144,7 @@ export class Config { | |||
143 | // We don't do runtime config validation here for simplicity. More on stackoverflow: | 144 | // We don't do runtime config validation here for simplicity. More on stackoverflow: |
144 | // https://stackoverflow.com/questions/60135780/what-is-the-best-way-to-type-check-the-configuration-for-vscode-extension | 145 | // https://stackoverflow.com/questions/60135780/what-is-the-best-way-to-type-check-the-configuration-for-vscode-extension |
145 | 146 | ||
147 | get highlightingSemanticTokens() { return this.cfg.get("highlighting.semanticTokens") as boolean; } | ||
146 | get highlightingOn() { return this.cfg.get("highlightingOn") as boolean; } | 148 | get highlightingOn() { return this.cfg.get("highlightingOn") as boolean; } |
147 | get rainbowHighlightingOn() { return this.cfg.get("rainbowHighlightingOn") as boolean; } | 149 | get rainbowHighlightingOn() { return this.cfg.get("rainbowHighlightingOn") as boolean; } |
148 | get lruCapacity() { return this.cfg.get("lruCapacity") as null | number; } | 150 | get lruCapacity() { return this.cfg.get("lruCapacity") as null | number; } |
diff --git a/editors/code/src/installation/download_artifact.ts b/editors/code/src/installation/download_artifact.ts index 356723aba..8ed99bf0a 100644 --- a/editors/code/src/installation/download_artifact.ts +++ b/editors/code/src/installation/download_artifact.ts | |||
@@ -5,7 +5,6 @@ import { strict as assert } from "assert"; | |||
5 | 5 | ||
6 | import { ArtifactReleaseInfo } from "./interfaces"; | 6 | import { ArtifactReleaseInfo } from "./interfaces"; |
7 | import { downloadFile } from "./download_file"; | 7 | import { downloadFile } from "./download_file"; |
8 | import { throttle } from "throttle-debounce"; | ||
9 | 8 | ||
10 | /** | 9 | /** |
11 | * Downloads artifact from given `downloadUrl`. | 10 | * Downloads artifact from given `downloadUrl`. |
@@ -38,19 +37,15 @@ export async function downloadArtifact( | |||
38 | async (progress, _cancellationToken) => { | 37 | async (progress, _cancellationToken) => { |
39 | let lastPrecentage = 0; | 38 | let lastPrecentage = 0; |
40 | const filePermissions = 0o755; // (rwx, r_x, r_x) | 39 | const filePermissions = 0o755; // (rwx, r_x, r_x) |
41 | await downloadFile(downloadUrl, installationPath, filePermissions, throttle( | 40 | await downloadFile(downloadUrl, installationPath, filePermissions, (readBytes, totalBytes) => { |
42 | 200, | 41 | const newPercentage = (readBytes / totalBytes) * 100; |
43 | /* noTrailing: */ true, | 42 | progress.report({ |
44 | (readBytes, totalBytes) => { | 43 | message: newPercentage.toFixed(0) + "%", |
45 | const newPercentage = (readBytes / totalBytes) * 100; | 44 | increment: newPercentage - lastPrecentage |
46 | progress.report({ | 45 | }); |
47 | message: newPercentage.toFixed(0) + "%", | ||
48 | increment: newPercentage - lastPrecentage | ||
49 | }); | ||
50 | 46 | ||
51 | lastPrecentage = newPercentage; | 47 | lastPrecentage = newPercentage; |
52 | }) | 48 | }); |
53 | ); | ||
54 | } | 49 | } |
55 | ); | 50 | ); |
56 | } | 51 | } |
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 424ff1ac3..ecf53cf77 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -89,7 +89,9 @@ export async function activate(context: vscode.ExtensionContext) { | |||
89 | 89 | ||
90 | activateStatusDisplay(ctx); | 90 | activateStatusDisplay(ctx); |
91 | 91 | ||
92 | activateHighlighting(ctx); | 92 | if (!ctx.config.highlightingSemanticTokens) { |
93 | activateHighlighting(ctx); | ||
94 | } | ||
93 | activateInlayHints(ctx); | 95 | activateInlayHints(ctx); |
94 | } | 96 | } |
95 | 97 | ||