Edit. Found:
-
vscode-purty extension
- Can simply enable “Editor: Format On Save” in vscode settings, and ignore the below
watchexec
instructions
- Can simply enable “Editor: Format On Save” in vscode settings, and ignore the below
- purty issue to consolidate vscode extensions
Original Post:
Does anyone use Purty to automatically format files upon save? What is your workflow?
Here’s one hackish option using watchexec:
- Create a
format.sh
script:
echo formatting $WATCHEXEC_WRITTEN_PATH
purty --write $WATCHEXEC_WRITTEN_PATH
- Run this command:
watchexec -w src -e purs -- ./format.sh
There may be some benign purty failures as the script is sometimes triggered again without setting the file path variable after purty overwrites.
A better long-term option is IDE integration as mentioned here:
Not sure if this will be more difficult than mimicking what was done with elm-format in elm-language-server. I assume the place to make this change is in purescript-language-server and the specific IDE extensions (e.g. vscode and atom).
Pinging maintainers @joneshf and @nwolverson for suggestions on how to proceed.