fixup! feat: add debug code lens

autodetect vscode-lldb
This commit is contained in:
Hannes De Valkeneer 2020-03-12 22:31:47 +01:00
parent e9d025b618
commit 39c92b3872
7 changed files with 26 additions and 19 deletions

View file

@ -51,6 +51,9 @@ pub struct ServerConfig {
/// Cargo feature configurations.
pub cargo_features: CargoFeatures,
/// Enabled if the vscode_lldb extension is available.
pub vscode_lldb: bool,
}
impl Default for ServerConfig {
@ -70,6 +73,7 @@ impl Default for ServerConfig {
additional_out_dirs: FxHashMap::default(),
cargo_features: Default::default(),
rustfmt_args: Vec::new(),
vscode_lldb: false,
}
}
}

View file

@ -185,6 +185,7 @@ pub fn main_loop(
all_targets: config.cargo_watch_all_targets,
},
rustfmt_args: config.rustfmt_args,
vscode_lldb: config.vscode_lldb,
}
};

View file

@ -805,23 +805,25 @@ pub fn handle_code_lens(
}),
data: None,
};
if r.args[0] == "run" {
r.args[0] = "build".into();
} else {
r.args.push("--no-run".into());
}
let debug_lens = CodeLens {
range: r.range,
command: Some(Command {
title: "Debug".into(),
command: "rust-analyzer.debugSingle".into(),
arguments: Some(vec![to_value(r).unwrap()]),
}),
data: None,
};
lenses.push(lens);
lenses.push(debug_lens);
if world.options.vscode_lldb {
if r.args[0] == "run" {
r.args[0] = "build".into();
} else {
r.args.push("--no-run".into());
}
let debug_lens = CodeLens {
range: r.range,
command: Some(Command {
title: "Debug".into(),
command: "rust-analyzer.debugSingle".into(),
arguments: Some(vec![to_value(r).unwrap()]),
}),
data: None,
};
lenses.push(debug_lens);
}
}
// Handle impls

View file

@ -37,6 +37,7 @@ pub struct Options {
pub max_inlay_hint_length: Option<usize>,
pub rustfmt_args: Vec<String>,
pub cargo_watch: CheckOptions,
pub vscode_lldb: bool,
}
/// `WorldState` is the primary mutable state of the language server

View file

@ -51,9 +51,6 @@
"typescript-formatter": "^7.2.2",
"vsce": "^1.74.0"
},
"extensionDependencies": [
"vadimcn.vscode-lldb"
],
"activationEvents": [
"onLanguage:rust",
"onCommand:rust-analyzer.analyzerStatus",

View file

@ -41,6 +41,7 @@ export async function createClient(config: Config, serverPath: string): Promise<
withSysroot: config.withSysroot,
cargoFeatures: config.cargoFeatures,
rustfmtArgs: config.rustfmtArgs,
vscodeLldb: vscode.extensions.getExtension("vadimcn.vscode-lldb") != null,
},
traceOutputChannel,
middleware: {

View file

@ -156,6 +156,7 @@ export class Config {
get featureFlags() { return this.cfg.get("featureFlags") as Record<string, boolean>; }
get additionalOutDirs() { return this.cfg.get("additionalOutDirs") as Record<string, string>; }
get rustfmtArgs() { return this.cfg.get("rustfmtArgs") as string[]; }
get vscodeLldb() { return this.cfg.get("vscodeLldb") as boolean; }
get cargoWatchOptions(): CargoWatchOptions {
return {