Skip to content

Commit

Permalink
Add support for SQL using pgformatter (#247)
Browse files Browse the repository at this point in the history
Add support for [`pgFormatter`](https://github.com/darold/pgFormatter)
for `sql-mode`.

<!--

To expedite the pull request process, please see the contributor guide
for my projects:

  <https://github.com/raxod502/contributor-guide>

-->
  • Loading branch information
abougouffa authored Nov 23, 2023
1 parent fb8842b commit 515ee18
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions test/formatters/installers/pgformatter.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apt-get install -y pgformatter
1 change: 1 addition & 0 deletions test/formatters/samplecode/pgformatter/in.sql
Original file line number Diff line number Diff line change
@@ -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));
9 changes: 9 additions & 0 deletions test/formatters/samplecode/pgformatter/out.sql
Original file line number Diff line number Diff line change
@@ -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)
);

0 comments on commit 515ee18

Please sign in to comment.