aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorHannes De Valkeneer <[email protected]>2020-03-12 21:31:47 +0000
committerHannes De Valkeneer <[email protected]>2020-03-12 21:31:47 +0000
commit39c92b38726a4ca0e0e48198cbd5bdd82bbf2fb5 (patch)
tree7ed280f1150354957317b1c499f94289c4765cb0 /crates
parente9d025b618aaa1a5a06e60c17392a18f12471217 (diff)
fixup! feat: add debug code lens
autodetect vscode-lldb
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/config.rs4
-rw-r--r--crates/rust-analyzer/src/main_loop.rs1
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs34
-rw-r--r--crates/rust-analyzer/src/world.rs1
4 files changed, 24 insertions, 16 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index a8bf29ddf..cfca06f56 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -51,6 +51,9 @@ pub struct ServerConfig {
51 51
52 /// Cargo feature configurations. 52 /// Cargo feature configurations.
53 pub cargo_features: CargoFeatures, 53 pub cargo_features: CargoFeatures,
54
55 /// Enabled if the vscode_lldb extension is available.
56 pub vscode_lldb: bool,
54} 57}
55 58
56impl Default for ServerConfig { 59impl Default for ServerConfig {
@@ -70,6 +73,7 @@ impl Default for ServerConfig {
70 additional_out_dirs: FxHashMap::default(), 73 additional_out_dirs: FxHashMap::default(),
71 cargo_features: Default::default(), 74 cargo_features: Default::default(),
72 rustfmt_args: Vec::new(), 75 rustfmt_args: Vec::new(),
76 vscode_lldb: false,
73 } 77 }
74 } 78 }
75} 79}
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 4f7aac754..b4add046f 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(
185 all_targets: config.cargo_watch_all_targets, 185 all_targets: config.cargo_watch_all_targets,
186 }, 186 },
187 rustfmt_args: config.rustfmt_args, 187 rustfmt_args: config.rustfmt_args,
188 vscode_lldb: config.vscode_lldb,
188 } 189 }
189 }; 190 };
190 191
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs
index f9715e675..571a896f3 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(
805 }), 805 }),
806 data: None, 806 data: None,
807 }; 807 };
808 if r.args[0] == "run" {
809 r.args[0] = "build".into();
810 } else {
811 r.args.push("--no-run".into());
812 }
813 let debug_lens = CodeLens {
814 range: r.range,
815 command: Some(Command {
816 title: "Debug".into(),
817 command: "rust-analyzer.debugSingle".into(),
818 arguments: Some(vec![to_value(r).unwrap()]),
819 }),
820 data: None,
821 };
822
823 lenses.push(lens); 808 lenses.push(lens);
824 lenses.push(debug_lens); 809
810 if world.options.vscode_lldb {
811 if r.args[0] == "run" {
812 r.args[0] = "build".into();
813 } else {
814 r.args.push("--no-run".into());
815 }
816 let debug_lens = CodeLens {
817 range: r.range,
818 command: Some(Command {
819 title: "Debug".into(),
820 command: "rust-analyzer.debugSingle".into(),
821 arguments: Some(vec![to_value(r).unwrap()]),
822 }),
823 data: None,
824 };
825 lenses.push(debug_lens);
826 }
825 } 827 }
826 828
827 // Handle impls 829 // Handle impls
diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs
index 9ef368529..a4fda9f80 100644
--- a/crates/rust-analyzer/src/world.rs
+++ b/crates/rust-analyzer/src/world.rs
@@ -37,6 +37,7 @@ pub struct Options {
37 pub max_inlay_hint_length: Option<usize>, 37 pub max_inlay_hint_length: Option<usize>,
38 pub rustfmt_args: Vec<String>, 38 pub rustfmt_args: Vec<String>,
39 pub cargo_watch: CheckOptions, 39 pub cargo_watch: CheckOptions,
40 pub vscode_lldb: bool,
40} 41}
41 42
42/// `WorldState` is the primary mutable state of the language server 43/// `WorldState` is the primary mutable state of the language server