Zed recipe
Wire Mago into Zed so PHP files are formatted on save.
Prerequisites
- Mago is installed. See the installation guide if you have not done that yet.
- The
magoexecutable is on yourPATH. The recommended installers handle this; verify withwhich mago.
Configuration
Open Zed's settings.json (Cmd + , on macOS, Ctrl + , on Linux and Windows, then "Open JSON Settings"). Add the PHP block to the languages section, merging with whatever you already have:
{
"languages": {
"PHP": {
"format_on_save": "on",
"formatter": {
"external": {
"command": "mago",
"arguments": ["format", "--stdin-input", "--stdin-filepath", "{buffer_path}"]
}
}
}
}
}
Passing --stdin-filepath {buffer_path} lets Mago apply [source].excludes and [formatter].excludes from your mago.toml to the current buffer, and it produces clearer error messages.
Usage
Save a .php file and Zed will format it via Mago. You can also trigger formatting manually from the Command Palette (Cmd + Shift + P or Ctrl + Shift + P) by running "Format Buffer".