Unify init and launch commands

pull/574/head
Dmitry Sharshakov 3 years ago
parent 9e22842d51
commit 738e8a4dd3
No known key found for this signature in database
GPG Key ID: 471FD32E15FD8473

@ -303,8 +303,7 @@ impl Command {
select_textobject_around, "Select around object", select_textobject_around, "Select around object",
select_textobject_inner, "Select inside object", select_textobject_inner, "Select inside object",
dap_toggle_breakpoint, "Toggle breakpoint", dap_toggle_breakpoint, "Toggle breakpoint",
dap_init, "Start debug session", dap_start, "Start debug session",
dap_launch, "Launch debugger",
dap_run, "Begin program execution", dap_run, "Begin program execution",
suspend, "Suspend" suspend, "Suspend"
); );
@ -4245,9 +4244,11 @@ fn suspend(_cx: &mut Context) {
} }
// DAP // DAP
fn dap_init(cx: &mut Context) { fn dap_start(cx: &mut Context) {
use helix_dap::Client; use helix_dap::Client;
use helix_lsp::block_on; use helix_lsp::block_on;
use serde_json::to_value;
let (_, _doc) = current!(cx.editor); let (_, _doc) = current!(cx.editor);
// look up config for filetype // look up config for filetype
@ -4259,6 +4260,13 @@ fn dap_init(cx: &mut Context) {
let request = debugger.initialize("go".to_owned()); let request = debugger.initialize("go".to_owned());
let _ = block_on(request).unwrap(); 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 // TODO: either await "initialized" or buffer commands until event is received
cx.editor.debugger = Some(debugger); 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) { fn dap_run(cx: &mut Context) {
use helix_lsp::block_on; use helix_lsp::block_on;

@ -486,8 +486,7 @@ impl Default for Keymaps {
"a" => code_action, "a" => code_action,
"'" => last_picker, "'" => last_picker,
"d" => { "Debug" "d" => { "Debug"
"i" => dap_init, "s" => dap_start,
"s" => dap_launch,
"b" => dap_toggle_breakpoint, "b" => dap_toggle_breakpoint,
"r" => dap_run, "r" => dap_run,
}, },

Loading…
Cancel
Save