carthage-software/mago
Mago is an extremely fast PHP linter, formatter, and static analyzer written in Rust. It helps teams catch issues early, enforce consistent style, and improve code quality across projects, with multiple install options like script, Homebrew, Composer, and Cargo.
+++ title = "Helix 实用方案" description = "把 Mago 接入 Helix 编辑器,作为 PHP 的格式化器。" nav_order = 30 nav_section = "实用方案" +++
把 Mago 用作 Helix 编辑器 中 PHP 文件的格式化器。
mago 可执行文件在你的 PATH 上。推荐的安装方式会自动处理这一点;你可以用 which mago 验证。在 Helix 的 languages.toml 中加几行:
~/.config/helix/languages.toml。%AppData%\helix\languages.toml。如果文件不存在就创建它,然后追加:
[[language]]
name = "php"
formatter = { command = "mago", args = ["format", "--stdin-input"] }
auto-format = true
这会覆盖 Helix 默认的 PHP 格式化器,并在保存时自动格式化。
启用 auto-format = true 后,每次保存(:write 或 :w)Mago 都会运行。你也可以在命令模式下手动用 :format(或 :fmt)触发格式化。
要验证配置,打开一个 .php 文件,把代码搞乱,然后保存。代码应该立刻归位。
How can I help you explore Laravel packages today?