mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-27 20:35:09 +00:00
Add arguments to rustfmt
This commit is contained in:
parent
32fc890de8
commit
a2b0bdcc24
7 changed files with 25 additions and 3 deletions
|
@ -44,6 +44,8 @@ pub struct ServerConfig {
|
||||||
/// Fine grained feature flags to disable specific features.
|
/// Fine grained feature flags to disable specific features.
|
||||||
pub feature_flags: FxHashMap<String, bool>,
|
pub feature_flags: FxHashMap<String, bool>,
|
||||||
|
|
||||||
|
pub rustfmt_args: Vec<String>,
|
||||||
|
|
||||||
/// Cargo feature configurations.
|
/// Cargo feature configurations.
|
||||||
pub cargo_features: CargoFeatures,
|
pub cargo_features: CargoFeatures,
|
||||||
}
|
}
|
||||||
|
@ -63,6 +65,7 @@ impl Default for ServerConfig {
|
||||||
with_sysroot: true,
|
with_sysroot: true,
|
||||||
feature_flags: FxHashMap::default(),
|
feature_flags: FxHashMap::default(),
|
||||||
cargo_features: Default::default(),
|
cargo_features: Default::default(),
|
||||||
|
rustfmt_args: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,6 +178,7 @@ pub fn main_loop(
|
||||||
command: config.cargo_watch_command,
|
command: config.cargo_watch_command,
|
||||||
all_targets: config.cargo_watch_all_targets,
|
all_targets: config.cargo_watch_all_targets,
|
||||||
},
|
},
|
||||||
|
rustfmt_args: config.rustfmt_args,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -590,6 +590,7 @@ pub fn handle_formatting(
|
||||||
let end_position = TextUnit::of_str(&file).conv_with(&file_line_index);
|
let end_position = TextUnit::of_str(&file).conv_with(&file_line_index);
|
||||||
|
|
||||||
let mut rustfmt = process::Command::new("rustfmt");
|
let mut rustfmt = process::Command::new("rustfmt");
|
||||||
|
rustfmt.args(&world.options.rustfmt_args);
|
||||||
if let Some(&crate_id) = crate_ids.first() {
|
if let Some(&crate_id) = crate_ids.first() {
|
||||||
// Assume all crates are in the same edition
|
// Assume all crates are in the same edition
|
||||||
let edition = world.analysis().crate_edition(crate_id)?;
|
let edition = world.analysis().crate_edition(crate_id)?;
|
||||||
|
|
|
@ -34,6 +34,7 @@ pub struct Options {
|
||||||
pub supports_location_link: bool,
|
pub supports_location_link: bool,
|
||||||
pub line_folding_only: bool,
|
pub line_folding_only: bool,
|
||||||
pub max_inlay_hint_length: Option<usize>,
|
pub max_inlay_hint_length: Option<usize>,
|
||||||
|
pub rustfmt_args: Vec<String>,
|
||||||
pub cargo_watch: CheckOptions,
|
pub cargo_watch: CheckOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,14 @@
|
||||||
"default": [],
|
"default": [],
|
||||||
"description": "Paths to exclude from analysis"
|
"description": "Paths to exclude from analysis"
|
||||||
},
|
},
|
||||||
|
"rust-analyzer.rustfmtArgs": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"default": [],
|
||||||
|
"description": "Additional arguments to rustfmt"
|
||||||
|
},
|
||||||
"rust-analyzer.useClientWatching": {
|
"rust-analyzer.useClientWatching": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true,
|
"default": true,
|
||||||
|
@ -233,7 +241,10 @@
|
||||||
"description": "Trace requests to the ra_lsp_server"
|
"description": "Trace requests to the ra_lsp_server"
|
||||||
},
|
},
|
||||||
"rust-analyzer.lruCapacity": {
|
"rust-analyzer.lruCapacity": {
|
||||||
"type": [ "null", "integer" ],
|
"type": [
|
||||||
|
"null",
|
||||||
|
"integer"
|
||||||
|
],
|
||||||
"default": null,
|
"default": null,
|
||||||
"minimum": 0,
|
"minimum": 0,
|
||||||
"exclusiveMinimum": true,
|
"exclusiveMinimum": true,
|
||||||
|
@ -245,7 +256,10 @@
|
||||||
"description": "Display additional type and parameter information in the editor"
|
"description": "Display additional type and parameter information in the editor"
|
||||||
},
|
},
|
||||||
"rust-analyzer.maxInlayHintLength": {
|
"rust-analyzer.maxInlayHintLength": {
|
||||||
"type": [ "null", "integer" ],
|
"type": [
|
||||||
|
"null",
|
||||||
|
"integer"
|
||||||
|
],
|
||||||
"default": 20,
|
"default": 20,
|
||||||
"minimum": 0,
|
"minimum": 0,
|
||||||
"exclusiveMinimum": true,
|
"exclusiveMinimum": true,
|
||||||
|
|
|
@ -42,6 +42,7 @@ export async function createClient(config: Config): Promise<null | lc.LanguageCl
|
||||||
featureFlags: config.featureFlags,
|
featureFlags: config.featureFlags,
|
||||||
withSysroot: config.withSysroot,
|
withSysroot: config.withSysroot,
|
||||||
cargoFeatures: config.cargoFeatures,
|
cargoFeatures: config.cargoFeatures,
|
||||||
|
rustfmtArgs: config.rustfmtArgs,
|
||||||
},
|
},
|
||||||
traceOutputChannel,
|
traceOutputChannel,
|
||||||
};
|
};
|
||||||
|
|
|
@ -149,6 +149,7 @@ export class Config {
|
||||||
get excludeGlobs() { return this.cfg.get("excludeGlobs") as string[]; }
|
get excludeGlobs() { return this.cfg.get("excludeGlobs") as string[]; }
|
||||||
get useClientWatching() { return this.cfg.get("useClientWatching") as boolean; }
|
get useClientWatching() { return this.cfg.get("useClientWatching") as boolean; }
|
||||||
get featureFlags() { return this.cfg.get("featureFlags") as Record<string, boolean>; }
|
get featureFlags() { return this.cfg.get("featureFlags") as Record<string, boolean>; }
|
||||||
|
get rustfmtArgs() { return this.cfg.get("rustfmtArgs") as string[]; }
|
||||||
|
|
||||||
get cargoWatchOptions(): CargoWatchOptions {
|
get cargoWatchOptions(): CargoWatchOptions {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue