diff --git a/config/default.toml b/config/default.toml index f2e7baf..f447980 100644 --- a/config/default.toml +++ b/config/default.toml @@ -7,7 +7,7 @@ watch_workspace = true show_indent_rulers = true always_prompt_on_exit = false case_insensitive_search = true -render_whitespace = "none" +render_whitespace = "trailing" [picker] show_hidden = false @@ -25,7 +25,7 @@ padding = 1 [[language]] name = "rust" -format = "rustfmt" +format = "rustfmt --edition 2021" [[language]] name = "cpp" diff --git a/crates/ferrite-core/src/buffer/format.rs b/crates/ferrite-core/src/buffer/format.rs index 3369d8c..571d3d0 100644 --- a/crates/ferrite-core/src/buffer/format.rs +++ b/crates/ferrite-core/src/buffer/format.rs @@ -7,7 +7,15 @@ use subprocess::{Exec, PopenError, Redirection}; use super::{Buffer, Cursor}; fn format(formatter: &str, rope: Rope) -> Result { - let mut child = Exec::cmd(formatter) + let mut parts = formatter.split_whitespace(); + let Some(first) = parts.next() else { + return Err( + std::io::Error::new(std::io::ErrorKind::InvalidInput, "invalid formatter").into(), + ); + }; + + let mut child = Exec::cmd(first) + .args(&parts.collect::>()) .stdin(Redirection::Pipe) .stdout(Redirection::Pipe) .stderr(Redirection::Pipe)