hxduster is a simple Bash script that allows you to use Tighten's Duster as a formatter for PHP files in Helix Editor.
The problem without this script is that Helix puts the contents of the file into stdin and takes the formatted version from stdout, and Tighten's Duster formats the file and saves it. The only way to use it was via dprint and :reload-all command in Helix. But it's inconvenient because you should run :rla command after each save and should be aware of it all the time.
hxduster solves this problem.
If you don't have Tighten's Duster installed yet, install it through the Composer:
composer global require tightenco/dusterNow clone the repo and install the script. You can install it in any directory you want, I show you an example of the default $HOME/.local/bin folder in Linux here.
git clone git@github.com:dotninth/hxduster.git
cd hxduster
chmod +x ./hxduster.sh
mv hxduster.sh $HOME/.local/binImportant
The path to the folder where you put the hxduster script should be in your .bashrc or .zshrc!
Now add hxduster to your Helix languages.toml configuration file.
hx $HOME/.config/helix/languages.toml[[language]]
name = "php"
formatter = { command = "hxduster.sh", args = ["--stdin"] }
auto-format = trueAnd that's it! Open any PHP file in your Laravel project and see if hxduster works. You can break the formatting and run the :fmt command to make sure everything works as intended.
Have fun!
The MIT License (MIT). Please see License File for more information.