feat(fmt): add --lsp language server mode - #323
Conversation
Deploying rstack-cli with
|
| Latest commit: |
b2b670c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e66c5d91.rstack-cli.pages.dev |
| Branch Preview URL: | https://feat-fmt-lsp.rstack-cli.pages.dev |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 69fcea7b13
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Could we use full document sync instead?
Formatting only needs the latest complete text, so each didChange could simply replace the cached document.
This avoids incremental range/position edge cases, simplifies state management, and allows us to remove the vscode-languageserver-textdocument dependency.
|
@chenjiahan agreed — formatting doesn't happen on every keystroke, so incremental sync buys us nothing here. switched to full sync and dropped vscode-languageserver-textdocument from the runtime bundle (kept as a devDependency for tests). |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e74ba2b58
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5adb718c54
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
This PR adds
rs fmt --lsp, which serves document formatting over the Language Server Protocol on stdio, so editors can format open buffers through a standard LSP client instead of spawningrs fmt --stdin-filepathper request.documentFormattingProvideronly, loads the project config once per server lifetime from the client-reported workspace root, and returns a minimalTextEditcomputed by a prefix/suffix trim that never splits surrogate pairs or\r\nsequences.vscode-languageserverandvscode-languageserver-textdocumentare devDependencies bundled into a lazily loadedfmtLspchunk (~211 kB), growing the published package from ~301 kB to ~512 kB; publisheddependenciesare unchanged.--configoption is now resolved to an absolute path at CLI parse time for all commands, so the server (whose workspace root can differ from its cwd) shares the same relative-path semantics as the rest of the CLI.