aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Sharshakov2021-08-20 16:11:37 +0000
committerDmitry Sharshakov2021-08-20 16:11:37 +0000
commit738e8a4dd3e9b22cd8b2d35a48ddc104a53187c4 (patch)
tree2ef16cb941c8abf5d24a130e5143f7310a6fa26f
parent9e22842d51af88b652a66926ac5b5eded182779d (diff)
Unify init and launch commands
-rw-r--r--helix-term/src/commands.rs28
-rw-r--r--helix-term/src/keymap.rs3
2 files changed, 12 insertions, 19 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 35e1c406..0b222a2a 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -303,8 +303,7 @@ impl Command {
select_textobject_around, "Select around object",
select_textobject_inner, "Select inside object",
dap_toggle_breakpoint, "Toggle breakpoint",
- dap_init, "Start debug session",
- dap_launch, "Launch debugger",
+ dap_start, "Start debug session",
dap_run, "Begin program execution",
suspend, "Suspend"
);
@@ -4245,9 +4244,11 @@ fn suspend(_cx: &mut Context) {
}
// DAP
-fn dap_init(cx: &mut Context) {
+fn dap_start(cx: &mut Context) {
use helix_dap::Client;
use helix_lsp::block_on;
+ use serde_json::to_value;
+
let (_, _doc) = current!(cx.editor);
// look up config for filetype
@@ -4259,6 +4260,13 @@ fn dap_init(cx: &mut Context) {
let request = debugger.initialize("go".to_owned());
let _ = block_on(request).unwrap();
+ let mut args = HashMap::new();
+ args.insert("mode", "debug");
+ args.insert("program", "main.go");
+
+ let request = debugger.launch(to_value(args).unwrap());
+ let _ = block_on(request).unwrap();
+
// TODO: either await "initialized" or buffer commands until event is received
cx.editor.debugger = Some(debugger);
@@ -4303,20 +4311,6 @@ fn dap_toggle_breakpoint(cx: &mut Context) {
}
}
-fn dap_launch(cx: &mut Context) {
- use helix_lsp::block_on;
- use serde_json::to_value;
-
- if let Some(debugger) = &mut cx.editor.debugger {
- let mut args = HashMap::new();
- args.insert("mode", "debug");
- args.insert("program", "main.go");
-
- let request = debugger.launch(to_value(args).unwrap());
- let _ = block_on(request).unwrap();
- }
-}
-
fn dap_run(cx: &mut Context) {
use helix_lsp::block_on;
diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs
index 3318a607..13905bbf 100644
--- a/helix-term/src/keymap.rs
+++ b/helix-term/src/keymap.rs
@@ -486,8 +486,7 @@ impl Default for Keymaps {
"a" => code_action,
"'" => last_picker,
"d" => { "Debug"
- "i" => dap_init,
- "s" => dap_launch,
+ "s" => dap_start,
"b" => dap_toggle_breakpoint,
"r" => dap_run,
},