Skip to content

Conversation

@Sysix
Copy link
Member

@Sysix Sysix commented Nov 19, 2025

Refactored the language server, so the ServerCapability can modified by each tool.
Before, we just registered the textDocument/formatting capability, if the client supports it dynamically.

Now we tell the client at the beginning if the request is supported, skipping the dynamic registration. Improving integration with client that does only support static registration.

And only of course when we use the formatter tool ;) Skipping it for oxlint --lsp

@github-actions github-actions bot added A-editor Area - Editor and Language Server C-bug Category - Bug labels Nov 19, 2025
Copy link
Member Author

Sysix commented Nov 19, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Sysix Sysix force-pushed the 11-19-fix_oxlint_lsp_don_t_register_textdocument_formatting_capability branch from b4a6fdf to 45a6921 Compare November 19, 2025 18:50
@Sysix Sysix requested a review from Copilot November 19, 2025 19:11
Copilot finished reviewing on behalf of Sysix November 19, 2025 19:14
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 refactors the language server to allow tools (linter, formatter) to directly modify server capabilities during initialization, replacing the previous approach of dynamic capability registration. The main goal is to improve compatibility with LSP clients that only support static capability registration.

Key Changes:

  • Modified the ToolBuilder trait to expose a server_capabilities method that allows tools to declare their capabilities upfront
  • Removed dynamic registration of textDocument/formatting capability in favor of static declaration
  • Each tool now independently adds its capabilities (linter adds code actions/commands, formatter adds document formatting)

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/oxc_language_server/src/tool.rs Replaced provided_commands and provided_code_action_kinds methods with a unified server_capabilities method for modifying capabilities directly
crates/oxc_language_server/src/linter/server_linter.rs Implemented server_capabilities to add code action kinds and execute commands, with comprehensive test coverage for various capability scenarios
crates/oxc_language_server/src/formatter/server_formatter.rs Implemented server_capabilities to enable document formatting provider, with basic test coverage
crates/oxc_language_server/src/capabilities.rs Simplified by removing client capability checks for code actions and commands, converting server_capabilities to a standalone function
crates/oxc_language_server/src/backend.rs Updated initialization to call server_capabilities on each tool builder and removed dynamic formatting registration logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Sysix Sysix marked this pull request as ready for review November 19, 2025 19:17
@Sysix Sysix requested a review from camc314 as a code owner November 19, 2025 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-editor Area - Editor and Language Server C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants