Skip to content

Commit

Permalink
make formatting commands able to have arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Kl4rry committed Jul 20, 2024
1 parent 86623b7 commit 4e1e3c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,7 +25,7 @@ padding = 1

[[language]]
name = "rust"
format = "rustfmt"
format = "rustfmt --edition 2021"

[[language]]
name = "cpp"
Expand Down
10 changes: 9 additions & 1 deletion crates/ferrite-core/src/buffer/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ use subprocess::{Exec, PopenError, Redirection};
use super::{Buffer, Cursor};

fn format(formatter: &str, rope: Rope) -> Result<String, PopenError> {
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::<Vec<_>>())
.stdin(Redirection::Pipe)
.stdout(Redirection::Pipe)
.stderr(Redirection::Pipe)
Expand Down

0 comments on commit 4e1e3c6

Please sign in to comment.