diff options
| author | nohz.afk <149959021+nohzafk@users.noreply.github.com> | 2024-10-18 01:50:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-17 16:50:27 -0700 |
| commit | b9cd808a91d0a1372dd86b150eaa6605de6c0ec0 (patch) | |
| tree | 47481b1cd59f5e27435069c5e393f316707fcf14 | |
| parent | 4e00c9ce49ed7a854f34677ffccb24ddbcf7e469 (diff) | |
support gleam language (#325)
support gleam language
---------
Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | apheleia-formatters.el | 2 | ||||
| -rw-r--r-- | test/formatters/installers/gleam.bash | 5 | ||||
| -rw-r--r-- | test/formatters/samplecode/gleam/in.gleam | 20 | ||||
| -rw-r--r-- | test/formatters/samplecode/gleam/out.gleam | 13 |
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, <<>>) +} |
