about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-05-18 06:48:21 +0000
committerbors <bors@rust-lang.org>2023-05-18 06:48:21 +0000
commit673008aaa2c47028affc3dbcc1d88afdb8e1d77b (patch)
tree0e760f16df3145b9fdf2ed6dfcee0698f2efb3c8
parentc7b03491cdb40a3b900c7db3c4193d5cc704a7d7 (diff)
parent0028e73927fc4e3402c7243511936de0f2bc17bc (diff)
downloadrust-673008aaa2c47028affc3dbcc1d88afdb8e1d77b.tar.gz
rust-673008aaa2c47028affc3dbcc1d88afdb8e1d77b.zip
Auto merge of #14822 - Veykril:augmentsSyntaxTokens-vscode, r=Veykril
fix: Force disable augmentsSyntaxTokens capability on VSCode

The default textmate grammar for rust in VSCode is pretty brittle, quite often coloring things very differently than we'd like to so we force full semantic highlighting by disabling that config.
-rw-r--r--editors/code/src/client.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index b27d9f54943..f721fcce766 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -366,6 +366,7 @@ export async function createClient(
 
     // To turn on all proposed features use: client.registerProposedFeatures();
     client.registerFeature(new ExperimentalFeatures());
+    client.registerFeature(new OverrideFeatures());
 
     return client;
 }
@@ -401,6 +402,25 @@ class ExperimentalFeatures implements lc.StaticFeature {
     dispose(): void {}
 }
 
+class OverrideFeatures implements lc.StaticFeature {
+    getState(): lc.FeatureState {
+        return { kind: "static" };
+    }
+    fillClientCapabilities(capabilities: lc.ClientCapabilities): void {
+        // Force disable `augmentsSyntaxTokens`, VSCode's textmate grammar is somewhat incomplete
+        // making the experience generally worse
+        const caps = capabilities.textDocument?.semanticTokens;
+        if (caps) {
+            caps.augmentsSyntaxTokens = false;
+        }
+    }
+    initialize(
+        _capabilities: lc.ServerCapabilities,
+        _documentSelector: lc.DocumentSelector | undefined
+    ): void {}
+    dispose(): void {}
+}
+
 function isCodeActionWithoutEditsAndCommands(value: any): boolean {
     const candidate: lc.CodeAction = value;
     return (