feat: add toggleLSPLogs command

add `toggleLSPLogs` command
update docs to reflect new command
This commit is contained in:
Joel Daniel Rico 2024-06-17 02:48:37 -07:00
parent 6b8b8ff4c5
commit 2ebcf55ece
5 changed files with 25 additions and 2 deletions

View file

@ -1485,3 +1485,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();
}
};
}

View file

@ -177,6 +177,7 @@ function createCommands(): Record<string, CommandFactory> {
serverVersion: { enabled: commands.serverVersion },
viewMemoryLayout: { enabled: commands.viewMemoryLayout },
toggleCheckOnSave: { enabled: commands.toggleCheckOnSave },
toggleLSPLogs: { enabled: commands.toggleLSPLogs },
// Internal commands which are invoked by the server.
applyActionGroup: { enabled: commands.applyActionGroup },
applySnippetWorkspaceEdit: { enabled: commands.applySnippetWorkspaceEditCommand },