helix: Add my preferred formatting for rust

This commit is contained in:
Travis Burtrum 2023-10-04 01:26:15 -04:00
parent f3442c8d00
commit 99bf72b351
3 changed files with 28 additions and 1 deletions

2
bashrc
View File

@ -155,7 +155,7 @@ if [ -f .rustfmt.nightly.toml]; then
exit $? exit $?
fi fi
# ok then just run my preferred format # ok then just run my preferred format
cargo fmt -- --config imports_granularity=crate cargo +nightly fmt -- --config imports_granularity=crate
} }
function spurdo() { function spurdo() {

22
bin/format-rs-from-helix Normal file
View File

@ -0,0 +1,22 @@
!/bin/bash
args="--emit stdout --edition 2021 --color never"
if [ -f rustfmt.toml]; then
rustfmt $args --config-path rustfmt.toml
exit $?
fi
if [ -f .rustfmt.toml]; then
rustfmt $args --config-path .rustfmt.toml
exit $?
fi
if [ -f rustfmt.nightly.toml]; then
rustfmt +nightly $args --config-path rustfmt.nightly.toml
exit $?
fi
if [ -f .rustfmt.nightly.toml]; then
rustfmt +nightly $args --config-path .rustfm.nightly.toml
exit $?
fi
# ok then just run my preferred format
rustfmt +nightly $args --config imports_granularity=crate

5
helix/languages.toml Normal file
View File

@ -0,0 +1,5 @@
[[language]]
name = "rust"
auto-format = true
formatter = { command = "~/.config/bin/format-rs-from-helix" }