aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/code/package.json5
-rw-r--r--editors/code/src/client.ts7
-rw-r--r--editors/code/src/config.ts2
-rw-r--r--editors/code/src/main.ts4
4 files changed, 15 insertions, 3 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 8a8a74f7c..2a89987e8 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -168,6 +168,11 @@
168 "type": "object", 168 "type": "object",
169 "title": "Rust Analyzer", 169 "title": "Rust Analyzer",
170 "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 },
171 "rust-analyzer.highlightingOn": { 176 "rust-analyzer.highlightingOn": {
172 "type": "boolean", 177 "type": "boolean",
173 "default": false, 178 "default": false,
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index f9dbe34c2..44bd04c21 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -27,7 +27,7 @@ export async function createClient(config: Config, serverPath: string): Promise<
27 const clientOptions: lc.LanguageClientOptions = { 27 const clientOptions: lc.LanguageClientOptions = {
28 documentSelector: [{ scheme: 'file', language: 'rust' }], 28 documentSelector: [{ scheme: 'file', language: 'rust' }],
29 initializationOptions: { 29 initializationOptions: {
30 publishDecorations: true, 30 publishDecorations: !config.highlightingSemanticTokens,
31 lruCapacity: config.lruCapacity, 31 lruCapacity: config.lruCapacity,
32 maxInlayHintLength: config.maxInlayHintLength, 32 maxInlayHintLength: config.maxInlayHintLength,
33 cargoWatchEnable: cargoWatchOpts.enable, 33 cargoWatchEnable: cargoWatchOpts.enable,
@@ -84,7 +84,10 @@ export async function createClient(config: Config, serverPath: string): Promise<
84 // 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.
85 // 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.
86 res.registerFeature(new CallHierarchyFeature(res)); 86 res.registerFeature(new CallHierarchyFeature(res));
87 res.registerFeature(new SemanticTokensFeature(res)); 87
88 if (config.highlightingSemanticTokens) {
89 res.registerFeature(new SemanticTokensFeature(res));
90 }
88 91
89 return res; 92 return res;
90} 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/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