Add arguments to rustfmt

This commit is contained in:
Ilya Titkov 2020-02-17 11:44:58 +03:00
parent 32fc890de8
commit a2b0bdcc24
7 changed files with 25 additions and 3 deletions

View file

@ -44,6 +44,8 @@ pub struct ServerConfig {
/// Fine grained feature flags to disable specific features.
pub feature_flags: FxHashMap<String, bool>,
pub rustfmt_args: Vec<String>,
/// Cargo feature configurations.
pub cargo_features: CargoFeatures,
}
@ -63,6 +65,7 @@ impl Default for ServerConfig {
with_sysroot: true,
feature_flags: FxHashMap::default(),
cargo_features: Default::default(),
rustfmt_args: Vec::new(),
}
}
}

View file

@ -178,6 +178,7 @@ pub fn main_loop(
command: config.cargo_watch_command,
all_targets: config.cargo_watch_all_targets,
},
rustfmt_args: config.rustfmt_args,
}
};

View file

@ -590,6 +590,7 @@ pub fn handle_formatting(
let end_position = TextUnit::of_str(&file).conv_with(&file_line_index);
let mut rustfmt = process::Command::new("rustfmt");
rustfmt.args(&world.options.rustfmt_args);
if let Some(&crate_id) = crate_ids.first() {
// Assume all crates are in the same edition
let edition = world.analysis().crate_edition(crate_id)?;

View file

@ -34,6 +34,7 @@ pub struct Options {
pub supports_location_link: bool,
pub line_folding_only: bool,
pub max_inlay_hint_length: Option<usize>,
pub rustfmt_args: Vec<String>,
pub cargo_watch: CheckOptions,
}