aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorDmitry Sharshakov2021-08-28 11:23:54 +0000
committerDmitry Sharshakov2021-08-28 11:23:54 +0000
commit8df6739759396b45d06356dd78c39117590b062b (patch)
tree605369d7ca24fab5d26e62171737776c5cf8e9dd /helix-term/src/commands.rs
parent5e4da09be264c2d6c16837a5ce81d99f69a584d6 (diff)
New way of starting debug sessions
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs38
1 files changed, 37 insertions, 1 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 62200d76..5eb51965 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -304,6 +304,7 @@ impl Command {
surround_delete, "Surround delete",
select_textobject_around, "Select around object",
select_textobject_inner, "Select inside object",
+ dap_launch, "Launch debug target",
dap_toggle_breakpoint, "Toggle breakpoint",
dap_run, "Begin program execution",
dap_continue, "Continue program execution",
@@ -4491,7 +4492,7 @@ fn suspend(_cx: &mut Context) {
}
// DAP
-fn dap_start_impl(
+pub fn dap_start_impl(
editor: &mut Editor,
name: Option<&str>,
socket: Option<std::net::SocketAddr>,
@@ -4596,6 +4597,41 @@ fn dap_start_impl(
editor.debugger_events.push(stream);
}
+fn dap_launch(cx: &mut Context) {
+ if cx.editor.debugger.is_some() {
+ cx.editor
+ .set_error("Can't start debug: debugger is running".to_string());
+ return;
+ }
+
+ let (_, doc) = current!(cx.editor);
+ let path = match doc.path() {
+ Some(path) => path.to_path_buf(),
+ None => {
+ cx.editor
+ .set_error("Can't start debug: document has no path".to_string());
+ return;
+ }
+ };
+
+ let config = cx
+ .editor
+ .syn_loader
+ .language_config_for_file_name(&path)
+ .and_then(|x| x.debugger.clone());
+ let config = match config {
+ Some(c) => c,
+ None => {
+ cx.editor.set_error(
+ "Can't start debug: no debug adapter available for language".to_string(),
+ );
+ return;
+ }
+ };
+
+ cx.editor.debug_config_picker = Some(config.templates.iter().map(|t| t.name.clone()).collect());
+}
+
fn dap_toggle_breakpoint(cx: &mut Context) {
use helix_lsp::block_on;