aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--apheleia-formatters.el4
-rw-r--r--test/formatters/installers/pgformatter.bash1
-rw-r--r--test/formatters/samplecode/pgformatter/in.sql1
-rw-r--r--test/formatters/samplecode/pgformatter/out.sql9
5 files changed, 17 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2e763fb..4c36575 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -84,6 +84,7 @@ The format is based on [Keep a Changelog].
* [`ormolu`](https://github.com/tweag/ormolu) for haskell.
* [`perltidy`](https://perltidy.sourceforge.net/) for
[perl](https://www.perl.org/) ([#175]).
+* [`pgformatter`](https://github.com/darold/pgFormatter) for [SQL](https://en.wikipedia.org/wiki/SQL) ([#247])
* [purs-tidy](https://github.com/natefaubion/purescript-tidy) for PureScript ([#182]).
* [`rubocop`](https://github.com/rubocop/rubocop) for [ruby](https://www.ruby-lang.org/en/) ([#176]).
* [`ruby-standard`](https://github.com/standardrb/standard) for
@@ -122,6 +123,7 @@ The format is based on [Keep a Changelog].
[#236]: https://github.com/radian-software/apheleia/pull/236
[#242]: https://github.com/radian-software/apheleia/pull/242
[#253]: https://github.com/radian-software/apheleia/pull/253
+[#247]: https://github.com/radian-software/apheleia/pull/247
## 3.2 (released 2023-02-25)
### Features
diff --git a/apheleia-formatters.el b/apheleia-formatters.el
index bb8bb1e..bb20b8b 100644
--- a/apheleia-formatters.el
+++ b/apheleia-formatters.el
@@ -81,6 +81,9 @@
"--enable-outside-detected-project"))
(ormolu . ("ormolu"))
(perltidy . ("perltidy" "--quiet" "--standard-error-output"))
+ (pgformatter . ("pg_format"
+ (apheleia-formatters-indent "--tabs" "--spaces" 'tab-width)
+ (apheleia-formatters-fill-column "--wrap-limit")))
(phpcs . ("apheleia-phpcs"))
(prettier
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
@@ -306,6 +309,7 @@ rather than using this system."
(rust-mode . rustfmt)
(rust-ts-mode . rustfmt)
(scss-mode . prettier-scss)
+ (sql-mode . pgformatter)
(svelte-mode . prettier-svelte)
(terraform-mode . terraform)
(TeX-latex-mode . latexindent)
diff --git a/test/formatters/installers/pgformatter.bash b/test/formatters/installers/pgformatter.bash
new file mode 100644
index 0000000..60375b8
--- /dev/null
+++ b/test/formatters/installers/pgformatter.bash
@@ -0,0 +1 @@
+apt-get install -y pgformatter
diff --git a/test/formatters/samplecode/pgformatter/in.sql b/test/formatters/samplecode/pgformatter/in.sql
new file mode 100644
index 0000000..74b50eb
--- /dev/null
+++ b/test/formatters/samplecode/pgformatter/in.sql
@@ -0,0 +1 @@
+create table person (primary key id int, firstname varchar(500), lastname varchar(500), email varchar(500), password_sha256 varchar(200), password_seed varchar(200));
diff --git a/test/formatters/samplecode/pgformatter/out.sql b/test/formatters/samplecode/pgformatter/out.sql
new file mode 100644
index 0000000..3853714
--- /dev/null
+++ b/test/formatters/samplecode/pgformatter/out.sql
@@ -0,0 +1,9 @@
+CREATE TABLE person (
+ PRIMARY KEY id int,
+ firstname varchar(500),
+ lastname varchar(500),
+ email varchar(500),
+ password_sha256 varchar(200),
+ password_seed varchar(200)
+);
+