Skip to content

Conversation

@J3m5
Copy link

@J3m5 J3m5 commented Dec 29, 2025

  • ✨ 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.

Copilot AI review requested due to automatic review settings December 29, 2025 00:12
@J3m5 J3m5 requested review from Sysix and camc314 as code owners December 29, 2025 00:12
@github-actions github-actions bot added A-cli Area - CLI A-editor Area - Editor and Language Server A-formatter Area - Formatter labels Dec 29, 2025
Copy link
Contributor

Copilot AI left a 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 ExternalFormatterBridge trait 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))]
Copy link

Copilot AI Dec 29, 2025

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.

Suggested change
#[cfg_attr(not(feature = "lsp-prettier"), allow(dead_code))]
#[cfg(feature = "lsp-prettier")]

Copilot uses AI. Check for mistakes.
@Dunqing
Copy link
Member

Dunqing commented Dec 29, 2025

Is this an AI-generated PR? Please follow https://oxc.rs/docs/contribute/introduction.html#ai-usage-policy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-editor Area - Editor and Language Server A-formatter Area - Formatter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants