Skip to content

Workaround for Zed code_actions_on_format revert when no formatter configured #56

@mikebronner

Description

@mikebronner

Summary

When using code_actions_on_format with source.fixAll.phpcs and format_on_save: "on", Zed's default formatter: "auto" causes the code action edits to be reverted if no formatter is available.

Upstream Issue

Current Workaround

We provide two mechanisms for auto-fixing on save:

  1. Formatter approach (recommended) — Uses documentFormattingProvider via formatter: { "language_server": { "name": "phpcs" } }. This works reliably because Zed calls the formatting handler exactly once.

  2. Code action approach — Uses source.fixAll.phpcs via code_actions_on_format. Requires users to also set "formatter": [] to prevent the auto formatter from reverting the edits.

Both are documented in the README.

Future

Once zed-industries/zed#51490 is resolved (or zed-industries/zed#48991 is merged adding formatter: "none"), users will be able to use code_actions_on_format without needing the "formatter": [] workaround. At that point, we can simplify the documentation.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions