Skip to content

Introduce toggle inlay hints vscode command #4601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/user/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
1 change: 1 addition & 0 deletions editors/code/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions editors/code/src/commands/toggle_inlay_hints.ts
Original file line number Diff line number Diff line change
@@ -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);
};
}
2 changes: 1 addition & 1 deletion editors/code/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions editors/code/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down