mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 07:04:22 +00:00
feat: add toggleLSPLogs
command
add `toggleLSPLogs` command update docs to reflect new command
This commit is contained in:
parent
6b8b8ff4c5
commit
2ebcf55ece
5 changed files with 25 additions and 2 deletions
|
@ -145,7 +145,7 @@ To log all communication between the server and the client, there are two choice
|
|||
```
|
||||
env RA_LOG=lsp_server=debug code .
|
||||
```
|
||||
* You can log on the client side, by enabling `"rust-analyzer.trace.server": "verbose"` workspace setting.
|
||||
* You can log on the client side, by the `rust-analyzer: Toggle LSP Logs` command or enabling `"rust-analyzer.trace.server": "verbose"` workspace setting.
|
||||
These logs are shown in a separate tab in the output and could be used with LSP inspector.
|
||||
Kudos to [@DJMcNab](https://github.com/DJMcNab) for setting this awesome infra up!
|
||||
|
||||
|
|
|
@ -591,7 +591,7 @@ The next thing to check would be panic messages in rust-analyzer's log.
|
|||
Log messages are printed to stderr, in VS Code you can see them in the `Output > Rust Analyzer Language Server` tab of the panel.
|
||||
To see more logs, set the `RA_LOG=info` environment variable, this can be done either by setting the environment variable manually or by using `rust-analyzer.server.extraEnv`, note that both of these approaches require the server to be restarted.
|
||||
|
||||
To fully capture LSP messages between the editor and the server, set `"rust-analyzer.trace.server": "verbose"` config and check
|
||||
To fully capture LSP messages between the editor and the server, run the `rust-analyzer: Toggle LSP Logs` command and check
|
||||
`Output > Rust Analyzer Language Server Trace`.
|
||||
|
||||
The root cause for many "`nothing works`" problems is that rust-analyzer fails to understand the project structure.
|
||||
|
|
|
@ -300,6 +300,11 @@
|
|||
"command": "rust-analyzer.toggleCheckOnSave",
|
||||
"title": "Toggle Check on Save",
|
||||
"category": "rust-analyzer"
|
||||
},
|
||||
{
|
||||
"command": "rust-analyzer.toggleLSPLogs",
|
||||
"title": "Toggle LSP Logs",
|
||||
"category": "rust-analyzer"
|
||||
}
|
||||
],
|
||||
"keybindings": [
|
||||
|
@ -3123,6 +3128,10 @@
|
|||
{
|
||||
"command": "rust-analyzer.viewMemoryLayout",
|
||||
"when": "inRustProject"
|
||||
},
|
||||
{
|
||||
"command": "rust-analyzer.toggleLSPLogs",
|
||||
"when": "inRustProject"
|
||||
}
|
||||
],
|
||||
"editor/context": [
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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 },
|
||||
|
|
Loading…
Reference in a new issue