-
-
Notifications
You must be signed in to change notification settings - Fork 763
feat: add Prettier-only formatting support #17442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for formatting Prettier-only file types (JSON, CSS, Markdown) through an external formatter bridge, enabling the OXC formatter to delegate formatting to Prettier for file types it doesn't natively support.
Key Changes:
- Introduced an
ExternalFormatterBridgetrait and implementation for delegating formatting to Prettier - Added activation events for CSS, JSON, JSONC, and Markdown languages in VS Code extension
- Implemented detection logic to identify Prettier-only files and route them to the external formatter
- Created comprehensive test fixtures for various Prettier-supported file types
Reviewed changes
Copilot reviewed 39 out of 40 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
crates/oxc_language_server/src/formatter/external_formatter_bridge.rs |
Defines the bridge trait for external formatters with a no-op implementation |
crates/oxc_format_support/src/lib.rs |
Implements file type detection and config loading for Prettier-only files |
crates/oxc_language_server/src/formatter/server_formatter.rs |
Integrates external formatter bridge into the formatter pipeline |
apps/oxfmt/src/lsp/mod.rs |
Implements NAPI bridge for external formatter with Tokio runtime handling |
editors/vscode/package.json |
Adds activation events for newly supported languages |
editors/vscode/client/tools/formatter.ts |
Extends supported file extensions list |
editors/vscode/tests/e2e_server_formatter.spec.ts |
Adds E2E tests for Prettier-only file formatting |
crates/oxc_format_support/Cargo.toml |
New crate for format support utilities |
| Multiple fixture files | Test data for various Prettier-supported file types |
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pub struct ServerFormatter { | ||
| options: FormatOptions, | ||
| gitignore_glob: Option<Gitignore>, | ||
| #[cfg_attr(not(feature = "lsp-prettier"), allow(dead_code))] |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The external_options field is marked as potentially dead code when the lsp-prettier feature is disabled, but it's unconditionally included in the struct. Consider making this field conditional with #[cfg(feature = \"lsp-prettier\")] to avoid including unused data in the struct.
| #[cfg_attr(not(feature = "lsp-prettier"), allow(dead_code))] | |
| #[cfg(feature = "lsp-prettier")] |
|
Is this an AI-generated PR? Please follow https://oxc.rs/docs/contribute/introduction.html#ai-usage-policy |
β¨ Introduce a delegation bridge for Prettier-only formatting.
π§ͺ Add tests for formatting specific to Prettier-only file types.
π Fix issues with nested Tokio runtime in LSP.
π Ensure formatter activates for JSON, CSS, and Markdown file types.
π Scope formatter selector to supported file types.
π Require Prettier-only formatting in tests.