From 99bf72b351c8b7cf68f6a633f55844426793ca24 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Wed, 4 Oct 2023 01:26:15 -0400 Subject: [PATCH] helix: Add my preferred formatting for rust --- bashrc | 2 +- bin/format-rs-from-helix | 22 ++++++++++++++++++++++ helix/languages.toml | 5 +++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 bin/format-rs-from-helix create mode 100644 helix/languages.toml diff --git a/bashrc b/bashrc index 916adfd..5750f0c 100755 --- a/bashrc +++ b/bashrc @@ -155,7 +155,7 @@ if [ -f .rustfmt.nightly.toml]; then exit $? fi # ok then just run my preferred format -cargo fmt -- --config imports_granularity=crate +cargo +nightly fmt -- --config imports_granularity=crate } function spurdo() { diff --git a/bin/format-rs-from-helix b/bin/format-rs-from-helix new file mode 100644 index 0000000..5251878 --- /dev/null +++ b/bin/format-rs-from-helix @@ -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 diff --git a/helix/languages.toml b/helix/languages.toml new file mode 100644 index 0000000..c047134 --- /dev/null +++ b/helix/languages.toml @@ -0,0 +1,5 @@ +[[language]] +name = "rust" +auto-format = true +formatter = { command = "~/.config/bin/format-rs-from-helix" } +