dotfiles/bin/format-rs-from-helix

13 lines
416 B
Plaintext
Raw Normal View History

2023-10-04 21:50:44 -04:00
#!/bin/bash
args="--emit stdout --edition 2021 --color never"
2023-10-04 21:50:44 -04:00
for cfg in rustfmt.toml .rustfmt.toml rustfmt.nightly.toml .rustfmt.nightly.toml rustfmt-nightly.toml .rustfmt-nightly.toml
do
[ "$cfg" == "rustfmt.nightly.toml" ] && args="+nightly $args"
[ -f $cfg ] && exec rustfmt $args --config-path $cfg
done
# or if no files, fallback to my preferred format
exec rustfmt $args --config imports_granularity=crate