Skip to content

Commit

Permalink
Add support for treefmt
Browse files Browse the repository at this point in the history
  • Loading branch information
terlar committed Jan 8, 2024
1 parent 923cd12 commit 0a2ec1b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The format is based on [Keep a Changelog].
clojurescript, edn files. ([#271])
* Stylua is used now in `lua-ts-mode` as well as just `lua-mode`, by
default ([#275]).
* [`treefmt`](https://numtide.github.io/treefmt) for project configured formatters ([#280]).

### Bugs fixed
* Apheleia sometimes failed to determine indent level from Emacs
Expand Down
1 change: 1 addition & 0 deletions apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
(stylua . ("stylua" "-"))
(rustfmt . ("rustfmt" "--quiet" "--emit" "stdout"))
(terraform . ("terraform" "fmt" "-"))
(treefmt . ("treefmt" "--stdin" filepath))
(xmllint . ("xmllint" "--format" "-"))
(yapf . ("yapf"))
(yq-csv . ("yq" "--prettyPrint" "--no-colors"
Expand Down
11 changes: 11 additions & 0 deletions test/formatters/installers/treefmt.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ver="$(latest_release numtide/treefmt)"

wget "https://github.com/numtide/treefmt/releases/download/${ver}/treefmt-x86_64-unknown-linux-gnu.tar.gz" -O - | tar -C /usr/local/bin -xz
chmod +x /usr/local/bin/treefmt

apt-get install -y rustfmt
cat <<EOT >> /tmp/treefmt.toml
[formatter.rust]
command = "rustfmt"
includes = ["*.rs"]
EOT
12 changes: 12 additions & 0 deletions test/formatters/samplecode/treefmt/in.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fn foo() {
println!("a");
}



fn bar() {
println!("b");


println!("c");
}
9 changes: 9 additions & 0 deletions test/formatters/samplecode/treefmt/out.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fn foo() {
println!("a");
}

fn bar() {
println!("b");

println!("c");
}

0 comments on commit 0a2ec1b

Please sign in to comment.