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:
-
Formatter approach (recommended) — Uses documentFormattingProvider via formatter: { "language_server": { "name": "phpcs" } }. This works reliably because Zed calls the formatting handler exactly once.
-
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.
Summary
When using
code_actions_on_formatwithsource.fixAll.phpcsandformat_on_save: "on", Zed's defaultformatter: "auto"causes the code action edits to be reverted if no formatter is available.Upstream Issue
code_actions_on_formatedits are reverted whenformatter: "auto"finds no formatter zed-industries/zed#51490Current Workaround
We provide two mechanisms for auto-fixing on save:
Formatter approach (recommended) — Uses
documentFormattingProviderviaformatter: { "language_server": { "name": "phpcs" } }. This works reliably because Zed calls the formatting handler exactly once.Code action approach — Uses
source.fixAll.phpcsviacode_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 usecode_actions_on_formatwithout needing the"formatter": []workaround. At that point, we can simplify the documentation.