From 23c8b7d1ca3d855b38b8fe8bee760fa1234b6143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Ho=C5=82ubowicz?= <45176912+alternateved@users.noreply.github.com> Date: Wed, 29 Mar 2023 23:35:02 +0200 Subject: [PATCH] Add purs-tidy formatter (#182) Hello! I would like to add support for `purs-tidy` - PureScript formatter. Best wishes alternateved --- CHANGELOG.md | 6 ++++++ apheleia-formatters.el | 2 ++ test/formatters/installers/purs-tidy.bash | 1 + test/formatters/samplecode/purs-tidy/in.purs | 7 +++++++ test/formatters/samplecode/purs-tidy/out.purs | 10 ++++++++++ 5 files changed, 26 insertions(+) create mode 100644 test/formatters/installers/purs-tidy.bash create mode 100644 test/formatters/samplecode/purs-tidy/in.purs create mode 100644 test/formatters/samplecode/purs-tidy/out.purs diff --git a/CHANGELOG.md b/CHANGELOG.md index bf494fe..91efefb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,17 @@ The format is based on [Keep a Changelog]. ## Unreleased ### Enhancements * Prettier is now enabled in `svelte-mode`. + ### Bugs fixed * `ktlint` would emit log messages into its stdout when formatting, and these would get spliced into the source file. This has been fixed by suppressing all logs from `ktlint`. +### Formatters +* [purs-tidy](https://github.com/natefaubion/purescript-tidy) for PureScript ([#182]). + +[#182]: https://github.com/radian-software/apheleia/pull/182 + ## 3.2 (released 2023-02-25) ### Features * You can use `apheleia-inhibit` as a file-local variable to disable diff --git a/apheleia-formatters.el b/apheleia-formatters.el index 01b79f2..1e65ec9 100644 --- a/apheleia-formatters.el +++ b/apheleia-formatters.el @@ -153,6 +153,7 @@ Otherwise return the extension only." . (npx "prettier" "--stdin-filepath" filepath "--parser=typescript")) (prettier-yaml . (npx "prettier" "--stdin-filepath" filepath "--parser=yaml")) + (purs-tidy . (npx "purs-tidy" "format")) (shfmt . ("shfmt" "-i" "4")) (stylua . ("stylua" "-")) (rustfmt . ("rustfmt" "--quiet" "--emit" "stdout")) @@ -265,6 +266,7 @@ rather than using this system." (lua-mode . stylua) (lisp-mode . lisp-indent) (nix-mode . nixfmt) + (purescript-mode . purs-tidy) (python-mode . black) (python-ts-mode . black) (ruby-mode . prettier-ruby) diff --git a/test/formatters/installers/purs-tidy.bash b/test/formatters/installers/purs-tidy.bash new file mode 100644 index 0000000..b6e2bae --- /dev/null +++ b/test/formatters/installers/purs-tidy.bash @@ -0,0 +1 @@ +npm install -g purs-tidy diff --git a/test/formatters/samplecode/purs-tidy/in.purs b/test/formatters/samplecode/purs-tidy/in.purs new file mode 100644 index 0000000..e112292 --- /dev/null +++ b/test/formatters/samplecode/purs-tidy/in.purs @@ -0,0 +1,7 @@ +module Foo where +baz ::Array(String) + -> Int->Boolean->Int +baz _ n + = case _ of + true-> 20 +1 + false -> if n> 0 then 3-(-2)else 0 diff --git a/test/formatters/samplecode/purs-tidy/out.purs b/test/formatters/samplecode/purs-tidy/out.purs new file mode 100644 index 0000000..b149877 --- /dev/null +++ b/test/formatters/samplecode/purs-tidy/out.purs @@ -0,0 +1,10 @@ +module Foo where + +baz + :: Array (String) + -> Int + -> Boolean + -> Int +baz _ n = case _ of + true -> 20 + 1 + false -> if n > 0 then 3 - (-2) else 0