From a2b0bdcc24a64061364aaa017bf6caef1810da7c Mon Sep 17 00:00:00 2001 From: Ilya Titkov Date: Mon, 17 Feb 2020 11:44:58 +0300 Subject: Add arguments to rustfmt --- crates/ra_lsp_server/src/config.rs | 3 +++ crates/ra_lsp_server/src/main_loop.rs | 1 + crates/ra_lsp_server/src/main_loop/handlers.rs | 1 + crates/ra_lsp_server/src/world.rs | 1 + 4 files changed, 6 insertions(+) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/config.rs b/crates/ra_lsp_server/src/config.rs index 2d7948d74..3314269ec 100644 --- a/crates/ra_lsp_server/src/config.rs +++ b/crates/ra_lsp_server/src/config.rs @@ -44,6 +44,8 @@ pub struct ServerConfig { /// Fine grained feature flags to disable specific features. pub feature_flags: FxHashMap, + pub rustfmt_args: Vec, + /// 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(), } } } diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index ceff82fda..1e70cea13 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -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, } }; diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 2e598fdcd..1da2d1814 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -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)?; diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 1ee02b47c..d993c5fc4 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -34,6 +34,7 @@ pub struct Options { pub supports_location_link: bool, pub line_folding_only: bool, pub max_inlay_hint_length: Option, + pub rustfmt_args: Vec, pub cargo_watch: CheckOptions, } -- cgit v1.2.3