Skip to content

Commit

Permalink
support gleam language (#325)
Browse files Browse the repository at this point in the history
support gleam language

---------

Co-authored-by: Radon Rosborough <[email protected]>
  • Loading branch information
nohzafk and raxod502 authored Oct 17, 2024
1 parent 4e00c9c commit b9cd808
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]).

Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions test/formatters/installers/gleam.bash
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions test/formatters/samplecode/gleam/in.gleam
Original file line number Diff line number Diff line change
@@ -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, <<>>)
}
13 changes: 13 additions & 0 deletions test/formatters/samplecode/gleam/out.gleam
Original file line number Diff line number Diff line change
@@ -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, <<>>)
}

0 comments on commit b9cd808

Please sign in to comment.