dotfiles/bin/format-rs-from-helix

13 lines
416 B
Bash
Executable File

#!/bin/bash
args="--emit stdout --edition 2021 --color never"
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