From 72de8553832ed4943e3b462fde5a6063a08a710b Mon Sep 17 00:00:00 2001 From: fi3ework Date: Wed, 19 Aug 2026 13:39:14 +0800 Subject: [PATCH] feat(vscode): declare rstack.fmt.trace.server for the rs fmt language client The old stdin-based fmt stack logged `Formatting completed in Xms`; that line went away with the move to `rs fmt --lsp`, and the language client had no declared trace setting to fall back on. Align with the other LSP-based formatter extensions instead of re-adding a custom timing log: - Rename the client id to `rstack.fmt` so vscode-languageclient reads (and hot-reloads) `rstack.fmt.trace.server` on its own. - Point `traceOutputChannel` at the stack's output channel so trace lines (`Received response 'textDocument/formatting' in Xms`) land next to the other fmt logs instead of a separate per-folder channel. - Declare the setting in package.json and document it in the README. --- packages/vscode/README.md | 1 + packages/vscode/package.json | 12 ++++++++++++ packages/vscode/src/stacks/fmt/index.ts | 9 ++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/vscode/README.md b/packages/vscode/README.md index e77ab9b..aa63951 100644 --- a/packages/vscode/README.md +++ b/packages/vscode/README.md @@ -98,6 +98,7 @@ All settings live under the unified `rstack.*` namespace. There are no `rslint.* | `rstack.rstest.terminalShellPath` | — | Shell used by **Run in Terminal**. | | `rstack.rstest.terminalShellArgs` | `[]` | Shell args for **Run in Terminal**. | | `rstack.fmt.enable` | `true` | Enable/disable the formatter integration. | +| `rstack.fmt.trace.server` | `off` | LSP trace level (`off` / `messages` / `verbose`); `messages` logs each formatting request's duration. | To use `rs fmt` as the formatter for supported documents, opt in through your VS Code settings: `"editor.defaultFormatter": "rstack.rstack"`. The extension never changes `editor.defaultFormatter` itself. diff --git a/packages/vscode/package.json b/packages/vscode/package.json index 66b5a5c..44ce790 100644 --- a/packages/vscode/package.json +++ b/packages/vscode/package.json @@ -319,6 +319,18 @@ "default": true, "scope": "window", "markdownDescription": "Enable the `rs fmt` document formatter for detected workspace folders. Requires `#rstack.enable#`. This is a window-level kill switch; which folders are formatted is decided by detection." + }, + "rstack.fmt.trace.server": { + "order": 1, + "type": "string", + "enum": [ + "off", + "messages", + "verbose" + ], + "default": "off", + "scope": "window", + "description": "Traces the communication between VS Code and the rs fmt language server (`messages` also shows how long each formatting request took)" } } } diff --git a/packages/vscode/src/stacks/fmt/index.ts b/packages/vscode/src/stacks/fmt/index.ts index 333607d..bd20bc5 100644 --- a/packages/vscode/src/stacks/fmt/index.ts +++ b/packages/vscode/src/stacks/fmt/index.ts @@ -338,8 +338,12 @@ class FmtFolderRuntime { ); this.#owner = owner; const serverOptions: ServerOptions = async () => owner.start(); + // The id doubles as the configuration section vscode-languageclient reads + // `trace.server` from (and hot-reloads on change), so it must equal the + // declared `rstack.fmt.trace.server` prefix — the same pairing Biome + // (`biome.lsp`) and Oxc (`oxc`) rely on. const client = new FmtLanguageClient( - 'rstack-fmt', + 'rstack.fmt', `rs fmt Language Server (${this.folder.name})`, serverOptions, this.createClientOptions(), @@ -481,6 +485,9 @@ class FmtFolderRuntime { // rslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion documentSelector as unknown as LanguageClientOptions['documentSelector'], outputChannel: this.context.output, + // Trace lines land in the stack's own channel next to its other logs + // instead of a separate "... Trace" channel per folder. + traceOutputChannel: this.context.output, errorHandler, }; }