diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index a8bf29ddf0..cfca06f569 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -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, } } } diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 4f7aac7540..b4add046f0 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -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, } }; diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index f9715e675c..571a896f30 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/main_loop/handlers.rs @@ -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 diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs index 9ef368529e..a4fda9f806 100644 --- a/crates/rust-analyzer/src/world.rs +++ b/crates/rust-analyzer/src/world.rs @@ -37,6 +37,7 @@ pub struct Options { pub max_inlay_hint_length: Option, pub rustfmt_args: Vec, pub cargo_watch: CheckOptions, + pub vscode_lldb: bool, } /// `WorldState` is the primary mutable state of the language server diff --git a/editors/code/package.json b/editors/code/package.json index 7445857218..1fe8e9f8ae 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -51,9 +51,6 @@ "typescript-formatter": "^7.2.2", "vsce": "^1.74.0" }, - "extensionDependencies": [ - "vadimcn.vscode-lldb" - ], "activationEvents": [ "onLanguage:rust", "onCommand:rust-analyzer.analyzerStatus", diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 6ce3b9235c..99c9c5ae70 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -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: { diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 3ade7e900f..40f4c7a0d6 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -156,6 +156,7 @@ export class Config { get featureFlags() { return this.cfg.get("featureFlags") as Record; } get additionalOutDirs() { return this.cfg.get("additionalOutDirs") as Record; } get rustfmtArgs() { return this.cfg.get("rustfmtArgs") as string[]; } + get vscodeLldb() { return this.cfg.get("vscodeLldb") as boolean; } get cargoWatchOptions(): CargoWatchOptions { return {