Skip to content

Commit 5dab5e7

Browse files
committed
Introduce toggle inlay hints vscode command
Users now can assign a shortcut for this command via the general vscode keybindings ui or `keybinding.json file` Closes: #4599
1 parent fbb8b88 commit 5dab5e7

File tree

6 files changed

+25
-1
lines changed

6 files changed

+25
-1
lines changed

docs/user/features.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ Shows internal statistic about memory usage of rust-analyzer.
9393

9494
Show current rust-analyzer version.
9595

96+
#### Toggle inlay hints
97+
98+
Toggle inlay hints view for the current workspace.
99+
It is recommended to assign a shortcut for this command to quickly turn off
100+
inlay hints when they prevent you from reading/writing the code.
101+
96102
#### Run Garbage Collection
97103

98104
Manually triggers GC.

editors/code/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@
166166
"command": "rust-analyzer.serverVersion",
167167
"title": "Show RA Version",
168168
"category": "Rust Analyzer"
169+
},
170+
{
171+
"command": "rust-analyzer.toggleInlayHints",
172+
"title": "Toggle inlay hints",
173+
"category": "Rust Analyzer"
169174
}
170175
],
171176
"keybindings": [

editors/code/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export * from './expand_macro';
1616
export * from './runnables';
1717
export * from './ssr';
1818
export * from './server_version';
19+
export * from './toggle_inlay_hints';
1920

2021
export function collectGarbage(ctx: Ctx): Cmd {
2122
return async () => ctx.client.sendRequest(ra.collectGarbage, null);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as vscode from 'vscode';
2+
import { Ctx, Cmd } from '../ctx';
3+
4+
export function toggleInlayHints(ctx: Ctx): Cmd {
5+
return async () => {
6+
await vscode
7+
.workspace
8+
.getConfiguration(`${ctx.config.rootSection}.inlayHints`)
9+
.update('enable', !ctx.config.inlayHints.enable, vscode.ConfigurationTarget.Workspace);
10+
};
11+
}

editors/code/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const NIGHTLY_TAG = "nightly";
88
export class Config {
99
readonly extensionId = "matklad.rust-analyzer";
1010

11-
private readonly rootSection = "rust-analyzer";
11+
readonly rootSection = "rust-analyzer";
1212
private readonly requiresReloadOpts = [
1313
"serverPath",
1414
"cargo",

editors/code/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export async function activate(context: vscode.ExtensionContext) {
8686

8787
ctx.registerCommand('ssr', commands.ssr);
8888
ctx.registerCommand('serverVersion', commands.serverVersion);
89+
ctx.registerCommand('toggleInlayHints', commands.toggleInlayHints);
8990

9091
// Internal commands which are invoked by the server.
9192
ctx.registerCommand('runSingle', commands.runSingle);

0 commit comments

Comments
 (0)