Auto merge of #17438 - jjoeldaniel:toggle_lsp_logs, r=Veykril

feat: add `toggleLSPLogs` command

Implement client-side command to toggle LSP logs in VSCode.

The command replaces the need to add/remove the `"rust-analyzer.trace.server": "verbose"` setting each time one wants to display logs. I've also updated the docs/ instances that reference the now outdated manual method.

The command labeled `rust-analyzer: Toggle LSP Logs` enables the setting project-wide and opens the relevant trace output channel.

Closes #8233
This commit is contained in:
bors 2024-06-19 08:39:42 +00:00
commit 87ee18da54
5 changed files with 25 additions and 2 deletions

View file

@ -1489,3 +1489,16 @@ export function toggleCheckOnSave(ctx: Ctx): Cmd {
ctx.refreshServerStatus();
};
}
export function toggleLSPLogs(ctx: Ctx): Cmd {
return async () => {
const config = vscode.workspace.getConfiguration("rust-analyzer");
const targetValue =
config.get<string | undefined>("trace.server") === "verbose" ? undefined : "verbose";
await config.update("trace.server", targetValue, vscode.ConfigurationTarget.Workspace);
if (targetValue && ctx.client && ctx.client.traceOutputChannel) {
ctx.client.traceOutputChannel.show();
}
};
}