about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--docs/user/features.md6
-rw-r--r--editors/code/package.json5
-rw-r--r--editors/code/src/commands/index.ts1
-rw-r--r--editors/code/src/commands/toggle_inlay_hints.ts11
-rw-r--r--editors/code/src/config.ts2
-rw-r--r--editors/code/src/main.ts1
6 files changed, 25 insertions, 1 deletions
diff --git a/docs/user/features.md b/docs/user/features.md
index 340bce83556..12ecdec136a 100644
--- a/docs/user/features.md
+++ b/docs/user/features.md
@@ -93,6 +93,12 @@ Shows internal statistic about memory usage of rust-analyzer.
 
 Show current rust-analyzer version.
 
+#### Toggle inlay hints
+
+Toggle inlay hints view for the current workspace.
+It is recommended to assign a shortcut for this command to quickly turn off
+inlay hints when they prevent you from reading/writing the code.
+
 #### Run Garbage Collection
 
 Manually triggers GC.
diff --git a/editors/code/package.json b/editors/code/package.json
index 21039ced885..2f14eaebd25 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -166,6 +166,11 @@
                 "command": "rust-analyzer.serverVersion",
                 "title": "Show RA Version",
                 "category": "Rust Analyzer"
+            },
+            {
+                "command": "rust-analyzer.toggleInlayHints",
+                "title": "Toggle inlay hints",
+                "category": "Rust Analyzer"
             }
         ],
         "keybindings": [
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts
index abb53a24815..c2a232d5fd8 100644
--- a/editors/code/src/commands/index.ts
+++ b/editors/code/src/commands/index.ts
@@ -16,6 +16,7 @@ export * from './expand_macro';
 export * from './runnables';
 export * from './ssr';
 export * from './server_version';
+export * from './toggle_inlay_hints';
 
 export function collectGarbage(ctx: Ctx): Cmd {
     return async () => ctx.client.sendRequest(ra.collectGarbage, null);
diff --git a/editors/code/src/commands/toggle_inlay_hints.ts b/editors/code/src/commands/toggle_inlay_hints.ts
new file mode 100644
index 00000000000..7606af8d0cb
--- /dev/null
+++ b/editors/code/src/commands/toggle_inlay_hints.ts
@@ -0,0 +1,11 @@
+import * as vscode from 'vscode';
+import { Ctx, Cmd } from '../ctx';
+
+export function toggleInlayHints(ctx: Ctx): Cmd {
+    return async () => {
+        await vscode
+            .workspace
+            .getConfiguration(`${ctx.config.rootSection}.inlayHints`)
+            .update('enable', !ctx.config.inlayHints.enable, vscode.ConfigurationTarget.Workspace);
+    };
+}
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index ee294fbe312..e8abf8284eb 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -8,7 +8,7 @@ export const NIGHTLY_TAG = "nightly";
 export class Config {
     readonly extensionId = "matklad.rust-analyzer";
 
-    private readonly rootSection = "rust-analyzer";
+    readonly rootSection = "rust-analyzer";
     private readonly requiresReloadOpts = [
         "serverPath",
         "cargo",
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 3405634f339..0e5a206410e 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -86,6 +86,7 @@ export async function activate(context: vscode.ExtensionContext) {
 
     ctx.registerCommand('ssr', commands.ssr);
     ctx.registerCommand('serverVersion', commands.serverVersion);
+    ctx.registerCommand('toggleInlayHints', commands.toggleInlayHints);
 
     // Internal commands which are invoked by the server.
     ctx.registerCommand('runSingle', commands.runSingle);