hxpint
is a simple Bash script that allows you to use Laravel Pint 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 Laravel Pint 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.
hxpint
solves this problem.
If you don't have Laravel Pint installed yet, install it through the Composer:
composer require laravel/pint --dev
Now 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/hxpint.git
cd hxpint
chmod +x ./hxpint.sh
mv hxpint.sh $HOME/.local/bin
Important
The path to the folder where you put the hxpint
script should be in your .bashrc
or .zshrc
!
Now add hxpint
to your Helix languages.toml
configuration file.
hx $HOME/.config/helix/languages.toml
[[language]]
name = "php"
formatter = { command = "hxpint.sh", args = ["--stdin"] }
auto-format = true
And that's it! Open any PHP file in your Laravel project and see if hxpint
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.