aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_lsp_server/src/config.rs3
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs1
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs1
-rw-r--r--crates/ra_lsp_server/src/world.rs1
-rw-r--r--editors/code/package.json18
-rw-r--r--editors/code/src/client.ts1
-rw-r--r--editors/code/src/config.ts3
7 files changed, 25 insertions, 3 deletions
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 {
44 /// Fine grained feature flags to disable specific features. 44 /// Fine grained feature flags to disable specific features.
45 pub feature_flags: FxHashMap<String, bool>, 45 pub feature_flags: FxHashMap<String, bool>,
46 46
47 pub rustfmt_args: Vec<String>,
48
47 /// Cargo feature configurations. 49 /// Cargo feature configurations.
48 pub cargo_features: CargoFeatures, 50 pub cargo_features: CargoFeatures,
49} 51}
@@ -63,6 +65,7 @@ impl Default for ServerConfig {
63 with_sysroot: true, 65 with_sysroot: true,
64 feature_flags: FxHashMap::default(), 66 feature_flags: FxHashMap::default(),
65 cargo_features: Default::default(), 67 cargo_features: Default::default(),
68 rustfmt_args: Vec::new(),
66 } 69 }
67 } 70 }
68} 71}
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(
178 command: config.cargo_watch_command, 178 command: config.cargo_watch_command,
179 all_targets: config.cargo_watch_all_targets, 179 all_targets: config.cargo_watch_all_targets,
180 }, 180 },
181 rustfmt_args: config.rustfmt_args,
181 } 182 }
182 }; 183 };
183 184
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 5879a1f7a..3893430c0 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(
590 let end_position = TextUnit::of_str(&file).conv_with(&file_line_index); 590 let end_position = TextUnit::of_str(&file).conv_with(&file_line_index);
591 591
592 let mut rustfmt = process::Command::new("rustfmt"); 592 let mut rustfmt = process::Command::new("rustfmt");
593 rustfmt.args(&world.options.rustfmt_args);
593 if let Some(&crate_id) = crate_ids.first() { 594 if let Some(&crate_id) = crate_ids.first() {
594 // Assume all crates are in the same edition 595 // Assume all crates are in the same edition
595 let edition = world.analysis().crate_edition(crate_id)?; 596 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 {
34 pub supports_location_link: bool, 34 pub supports_location_link: bool,
35 pub line_folding_only: bool, 35 pub line_folding_only: bool,
36 pub max_inlay_hint_length: Option<usize>, 36 pub max_inlay_hint_length: Option<usize>,
37 pub rustfmt_args: Vec<String>,
37 pub cargo_watch: CheckOptions, 38 pub cargo_watch: CheckOptions,
38} 39}
39 40
diff --git a/editors/code/package.json b/editors/code/package.json
index ed1cae2ab..46acbfe76 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -188,6 +188,14 @@
188 "default": [], 188 "default": [],
189 "description": "Paths to exclude from analysis" 189 "description": "Paths to exclude from analysis"
190 }, 190 },
191 "rust-analyzer.rustfmtArgs": {
192 "type": "array",
193 "items": {
194 "type": "string"
195 },
196 "default": [],
197 "description": "Additional arguments to rustfmt"
198 },
191 "rust-analyzer.useClientWatching": { 199 "rust-analyzer.useClientWatching": {
192 "type": "boolean", 200 "type": "boolean",
193 "default": true, 201 "default": true,
@@ -233,7 +241,10 @@
233 "description": "Trace requests to the ra_lsp_server" 241 "description": "Trace requests to the ra_lsp_server"
234 }, 242 },
235 "rust-analyzer.lruCapacity": { 243 "rust-analyzer.lruCapacity": {
236 "type": [ "null", "integer" ], 244 "type": [
245 "null",
246 "integer"
247 ],
237 "default": null, 248 "default": null,
238 "minimum": 0, 249 "minimum": 0,
239 "exclusiveMinimum": true, 250 "exclusiveMinimum": true,
@@ -245,7 +256,10 @@
245 "description": "Display additional type and parameter information in the editor" 256 "description": "Display additional type and parameter information in the editor"
246 }, 257 },
247 "rust-analyzer.maxInlayHintLength": { 258 "rust-analyzer.maxInlayHintLength": {
248 "type": [ "null", "integer" ], 259 "type": [
260 "null",
261 "integer"
262 ],
249 "default": 20, 263 "default": 20,
250 "minimum": 0, 264 "minimum": 0,
251 "exclusiveMinimum": true, 265 "exclusiveMinimum": true,
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index efef820ab..11894973c 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -42,6 +42,7 @@ export async function createClient(config: Config): Promise<null | lc.LanguageCl
42 featureFlags: config.featureFlags, 42 featureFlags: config.featureFlags,
43 withSysroot: config.withSysroot, 43 withSysroot: config.withSysroot,
44 cargoFeatures: config.cargoFeatures, 44 cargoFeatures: config.cargoFeatures,
45 rustfmtArgs: config.rustfmtArgs,
45 }, 46 },
46 traceOutputChannel, 47 traceOutputChannel,
47 }; 48 };
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 53e2a414b..c3fa788c7 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -148,7 +148,8 @@ export class Config {
148 get excludeGlobs() { return this.cfg.get("excludeGlobs") as string[]; } 148 get excludeGlobs() { return this.cfg.get("excludeGlobs") as string[]; }
149 get useClientWatching() { return this.cfg.get("useClientWatching") as boolean; } 149 get useClientWatching() { return this.cfg.get("useClientWatching") as boolean; }
150 get featureFlags() { return this.cfg.get("featureFlags") as Record<string, boolean>; } 150 get featureFlags() { return this.cfg.get("featureFlags") as Record<string, boolean>; }
151 151 get rustfmtArgs() { return this.cfg.get("rustfmtArgs") as string[]; }
152
152 get cargoWatchOptions(): CargoWatchOptions { 153 get cargoWatchOptions(): CargoWatchOptions {
153 return { 154 return {
154 enable: this.cfg.get("cargo-watch.enable") as boolean, 155 enable: this.cfg.get("cargo-watch.enable") as boolean,