🧩 Zed Editor Recipe
Integrate Mago directly into the Zed editor for seamless, high-performance code formatting on save.
Prerequisites
- Mago Installed: Ensure you have installed Mago. If not, please follow the Installation Guide.
PATH
configured: Themago
executable must be in your system's$PATH
. The recommended installation methods handle this automatically. You can verify this by runningwhich mago
in your terminal, which should return a path to the executable.
Configuration
Open Settings: Launch Zed and open your
settings.json
file. You can do this by pressingCmd + ,
(on macOS) orCtrl + ,
(on Linux/Windows) and then clicking "Open JSON Settings".Add PHP Configuration: Add the following JSON block to your
settings.json
. If you already have a"languages"
section, simply add the"PHP"
object within it.json{ // ... other settings you may have "languages": { "PHP": { // Recommended: Format your code automatically whenever you save a file. "format_on_save": "on", // Configure Mago as the external formatter. "formatter": { "external": { "command": "mago", "arguments": ["format", "--stdin-input"] } } } // ... other language settings } }
Usage
That's it! With this configuration, Zed will now automatically format your .php
files with Mago every time you save.
You can also trigger formatting manually at any time by:
- Opening the command palette with
Cmd + Shift + P
orCtrl + Shift + P
. - Typing "Format Buffer" and pressing Enter.