aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md3
-rw-r--r--apheleia-formatters.el2
-rw-r--r--test/formatters/installers/gleam.bash5
-rw-r--r--test/formatters/samplecode/gleam/in.gleam20
-rw-r--r--test/formatters/samplecode/gleam/out.gleam13
5 files changed, 43 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1260fcc..38e6463 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,8 @@ The format is based on [Keep a Changelog].
instead of deprecated `--auto-correct` ([#316]).
* `snakefmt` official formatter for
[Snakemake](https://snakemake.readthedocs.io) ([#307]).
+* [`gleam`](https://github.com/gleam-lang/gleam) official formatter for
+ [`gleam`](https://github.com/gleam-lang/gleam) ([#325])
* `zig fmt` official formatter for
[zig](https://ziglang.org/) ([#327]).
@@ -51,6 +53,7 @@ The format is based on [Keep a Changelog].
[#316]: https://github.com/radian-software/apheleia/pull/316
[#317]: https://github.com/radian-software/apheleia/issues/317
[#319]: https://github.com/radian-software/apheleia/pull/319
+[#325]: https://github.com/radian-software/apheleia/pull/325
[#326]: https://github.com/radian-software/apheleia/pull/326
[#327]: https://github.com/radian-software/apheleia/pull/327
diff --git a/apheleia-formatters.el b/apheleia-formatters.el
index 30597ae..34ee3fc 100644
--- a/apheleia-formatters.el
+++ b/apheleia-formatters.el
@@ -63,6 +63,7 @@
(fish-indent . ("fish_indent"))
(fourmolu . ("fourmolu"))
(gawk . ("gawk" "-f" "-" "--pretty-print=-"))
+ (gleam . ("gleam" "format" "--stdin"))
(gofmt . ("gofmt"))
(gofumpt . ("gofumpt"))
(goimports . ("goimports"))
@@ -321,6 +322,7 @@ rather than using this system."
(elm-mode . elm-format)
(emacs-lisp-mode . lisp-indent)
(fish-mode . fish-indent)
+ (gleam-ts-mode . gleam)
(go-mode . gofmt)
(go-ts-mode . gofmt)
(graphql-mode . prettier-graphql)
diff --git a/test/formatters/installers/gleam.bash b/test/formatters/installers/gleam.bash
new file mode 100644
index 0000000..bef5316
--- /dev/null
+++ b/test/formatters/installers/gleam.bash
@@ -0,0 +1,5 @@
+ver="$(latest_release gleam-lang/gleam)"
+
+wget "https://github.com/gleam-lang/gleam/releases/download/${ver}/gleam-${ver}-x86_64-unknown-linux-musl.tar.gz" -O /tmp/gleam.tar.gz
+tar -xzf /tmp/gleam.tar.gz -C /usr/local/bin
+chmod +x /usr/local/bin/gleam
diff --git a/test/formatters/samplecode/gleam/in.gleam b/test/formatters/samplecode/gleam/in.gleam
new file mode 100644
index 0000000..f0f93e9
--- /dev/null
+++ b/test/formatters/samplecode/gleam/in.gleam
@@ -0,0 +1,20 @@
+fn encode_(
+ dna: List(Nucleotide),
+ acc: BitArray
+) {
+ case dna {
+ [] -> acc
+ [first, ..rest] ->
+ {
+ let nbit = encode_nucleotide(first)
+ encode_(rest,
+ <<acc:bits, nbit:size(2)>>)
+ }
+ }
+}
+
+pub fn encode(dna: List(Nucleotide) )
+ -> BitArray
+{
+ encode_(dna, <<>>)
+}
diff --git a/test/formatters/samplecode/gleam/out.gleam b/test/formatters/samplecode/gleam/out.gleam
new file mode 100644
index 0000000..0e54b50
--- /dev/null
+++ b/test/formatters/samplecode/gleam/out.gleam
@@ -0,0 +1,13 @@
+fn encode_(dna: List(Nucleotide), acc: BitArray) {
+ case dna {
+ [] -> acc
+ [first, ..rest] -> {
+ let nbit = encode_nucleotide(first)
+ encode_(rest, <<acc:bits, nbit:size(2)>>)
+ }
+ }
+}
+
+pub fn encode(dna: List(Nucleotide)) -> BitArray {
+ encode_(dna, <<>>)
+}