diff options
Diffstat (limited to 'editors/code/src')
-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 |
4 files changed, 20 insertions, 15 deletions
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 | ||