Skip to content

Conversation

Sysix
Copy link
Member

@Sysix Sysix commented Sep 11, 2025

First try on formatter integration.
The server will only tell the client, that is supports formatting when fmt.experimental is true.

It will respect the flag in initialize, did_change_configuration (changing configuration), or did_change_workspace_folders.
It will not tell the client, it does not support formatting when the configuration is changed to false.
This can be optimized but has no high priority, because the client needs to send the request and the ServerFormatter needs to be set. The last requirement is then false.

Make WorkspaceWorker.option optional, so we the servers knows when the configuration in initialize or initialized (with request_workspace_configuration). Before the server knew it, by looking at the WorkspaceWorker.server_linter instance.

@github-actions github-actions bot added A-editor Area - Editor and Language Server C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Sep 11, 2025
Copy link
Member Author

Sysix commented Sep 11, 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.

Copy link

codspeed-hq bot commented Sep 11, 2025

CodSpeed Instrumentation Performance Report

Merging #13700 will not alter performance

Comparing 09-11-refactor_language_server_introduce_dummy_serverformatter_ (a21ff54) with main (6fcb0d0)

Summary

✅ 37 untouched

@Sysix Sysix force-pushed the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch 2 times, most recently from 80c4f06 to 42a1b9b Compare September 11, 2025 20:51
@Sysix Sysix force-pushed the 09-09-chore_language_server_split_options_for_linting_and_formatting branch from ce97ea7 to fc596f4 Compare September 12, 2025 11:23
@Sysix Sysix force-pushed the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch 2 times, most recently from f4c7ef3 to 8ca332f Compare September 12, 2025 11:34
@Sysix Sysix force-pushed the 09-09-chore_language_server_split_options_for_linting_and_formatting branch from fc596f4 to 3798dad Compare September 12, 2025 11:34
@Sysix Sysix changed the base branch from 09-09-chore_language_server_split_options_for_linting_and_formatting to graphite-base/13700 September 12, 2025 17:16
@Sysix Sysix force-pushed the graphite-base/13700 branch from 3798dad to 3b08bf6 Compare September 12, 2025 17:16
@Sysix Sysix force-pushed the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch from df1a8d1 to a2bf52e Compare September 12, 2025 17:16
@Sysix Sysix changed the base branch from graphite-base/13700 to 09-12-refactor_langauge_server_introdude_lspfilesystem_ September 12, 2025 17:16
@Sysix Sysix changed the title refactor(language_server): introduce dummy ServerFormatter feat(language_server): introduce ServerFormatter Sep 12, 2025
@github-actions github-actions bot added the C-enhancement Category - New feature or request label Sep 12, 2025
@Sysix Sysix force-pushed the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch from a2bf52e to 76c2729 Compare September 14, 2025 00:27
@Sysix Sysix force-pushed the 09-12-refactor_langauge_server_introdude_lspfilesystem_ branch from 3b08bf6 to 179e34f Compare September 14, 2025 00:27
@Sysix Sysix force-pushed the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch from 76c2729 to 940f6f4 Compare September 15, 2025 18:54
@Sysix Sysix force-pushed the 09-12-refactor_langauge_server_introdude_lspfilesystem_ branch 2 times, most recently from f391c08 to b988882 Compare September 15, 2025 19:25
@Sysix Sysix force-pushed the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch from 940f6f4 to f05a0f8 Compare September 15, 2025 19:25
@graphite-app graphite-app bot force-pushed the 09-12-refactor_langauge_server_introdude_lspfilesystem_ branch 2 times, most recently from 64fafe3 to bdbd19b Compare September 16, 2025 01:23
@graphite-app graphite-app bot force-pushed the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch from f05a0f8 to a6f11d8 Compare September 16, 2025 01:23
@Sysix Sysix force-pushed the 09-12-refactor_langauge_server_introdude_lspfilesystem_ branch from bdbd19b to 5bf9ca8 Compare September 16, 2025 19:00
@Sysix Sysix force-pushed the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch 2 times, most recently from ddf7c62 to 5ad6d97 Compare September 16, 2025 20:07
@Sysix Sysix removed the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Sep 19, 2025
@Sysix Sysix force-pushed the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch 2 times, most recently from cb54a80 to c1e00fd Compare September 19, 2025 11:41
@Sysix Sysix force-pushed the 09-12-refactor_langauge_server_introdude_lspfilesystem_ branch from dabd34c to 4649c44 Compare September 19, 2025 11:41
@graphite-app graphite-app bot changed the base branch from 09-12-refactor_langauge_server_introdude_lspfilesystem_ to graphite-base/13700 September 19, 2025 11:47
@graphite-app graphite-app bot force-pushed the graphite-base/13700 branch from 4649c44 to dc700f5 Compare September 19, 2025 11:52
@graphite-app graphite-app bot force-pushed the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch from c1e00fd to 694413b Compare September 19, 2025 11:52
@graphite-app graphite-app bot changed the base branch from graphite-base/13700 to main September 19, 2025 11:52
@graphite-app graphite-app bot force-pushed the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch from 694413b to 325422e Compare September 19, 2025 11:53
@Sysix Sysix force-pushed the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch 4 times, most recently from 7854fef to e9ea470 Compare September 19, 2025 17:29
@Sysix Sysix marked this pull request as ready for review September 20, 2025 11:48
@Sysix Sysix requested a review from camc314 as a code owner September 20, 2025 11:48
@Copilot Copilot AI review requested due to automatic review settings September 20, 2025 11:48
Copy link
Contributor

@Copilot 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 introduces experimental formatter support to the OXC language server, adding the ServerFormatter struct and configuring it to be enabled via the fmt.experimental configuration option. The formatter integration uses dynamic LSP capability registration to conditionally advertise formatting support to clients.

  • Adds ServerFormatter with run_single method for formatting files
  • Introduces fmt.experimental configuration option for enabling the formatter
  • Implements dynamic capability registration for textDocument/formatting when formatter is enabled

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
worker.rs Adds formatter state management and configuration handling to WorkspaceWorker
main.rs Implements LSP formatting endpoint and dynamic capability registration
formatter/server_formatter.rs Core formatter implementation with file processing logic
formatter/options.rs Configuration parsing for formatter experimental flag
capabilities.rs Enables dynamic formatting capability support
options.rs Adds test for new fmt.experimental configuration option

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@camc314 camc314 self-assigned this Sep 20, 2025
@Sysix Sysix force-pushed the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch from e9ea470 to 58926e6 Compare September 20, 2025 11:53
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Sep 20, 2025
Copy link
Contributor

camc314 commented Sep 20, 2025

Merge activity

First try on formatter integration.
The server will only tell the client, that is supports `formatting` when `fmt.experimental` is `true`.

It will respect the flag in `initialize`, `did_change_configuration` (changing configuration), or `did_change_workspace_folders`.
It will not tell the client, it does not support formatting when the configuration is changed to `false`.
This can be optimized but has no high priority, because the client needs to send the request and the `ServerFormatter` needs to be set. The last requirement is then false.

Make `WorkspaceWorker.option` optional, so we the servers knows when the configuration in `initialize` or `initialized` (with `request_workspace_configuration`). Before the server knew it, by looking at the `WorkspaceWorker.server_linter` instance.
@graphite-app graphite-app bot force-pushed the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch from 58926e6 to a21ff54 Compare September 20, 2025 18:05
@graphite-app graphite-app bot merged commit a21ff54 into main Sep 20, 2025
28 checks passed
@graphite-app graphite-app bot deleted the 09-11-refactor_language_server_introduce_dummy_serverformatter_ branch September 20, 2025 18:10
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Sep 20, 2025
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-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants