Add support of runnables arguments in Rust Analyzer

This commit is contained in:
Igor Aleksanov
2020-09-05 12:52:27 +03:00
parent c01cd6e3ed
commit 2c125f3c63
4 changed files with 30 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ pub struct Config {
pub cargo: CargoConfig,
pub rustfmt: RustfmtConfig,
pub flycheck: Option<FlycheckConfig>,
pub runnables: RunnablesConfig,
pub inlay_hints: InlayHintsConfig,
pub completion: CompletionConfig,
@@ -124,6 +125,15 @@ pub enum RustfmtConfig {
CustomCommand { command: String, args: Vec<String> },
}
/// Configuration for runnable items, such as `main` function or tests.
#[derive(Debug, Clone, Default)]
pub struct RunnablesConfig {
/// Stuff to be inserted before `cargo`, e.g. `RUST_LOG=info`.
pub cargo_prefix: Vec<String>,
/// Additional arguments for the `cargo`, e.g. `--release`.
pub cargo_extra_args: Vec<String>,
}
#[derive(Debug, Clone, Default)]
pub struct ClientCapsConfig {
pub location_link: bool,
@@ -164,6 +174,7 @@ impl Config {
extra_args: Vec::new(),
features: Vec::new(),
}),
runnables: RunnablesConfig::default(),
inlay_hints: InlayHintsConfig {
type_hints: true,
@@ -220,6 +231,10 @@ impl Config {
load_out_dirs_from_check: data.cargo_loadOutDirsFromCheck,
target: data.cargo_target.clone(),
};
self.runnables = RunnablesConfig {
cargo_prefix: data.runnables_cargoPrefix,
cargo_extra_args: data.runnables_cargoExtraArgs,
};
self.proc_macro_srv = if data.procMacro_enable {
std::env::current_exe().ok().map(|path| (path, vec!["proc-macro".into()]))
@@ -474,6 +489,9 @@ config_data! {
notifications_cargoTomlNotFound: bool = true,
procMacro_enable: bool = false,
runnables_cargoPrefix: Vec<String> = Vec::new(),
runnables_cargoExtraArgs: Vec<String> = Vec::new(),
rustfmt_extraArgs: Vec<String> = Vec::new(),
rustfmt_overrideCommand: Option<Vec<String>> = None,