Unify init and launch commands

imgbot
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_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;

@ -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,
},

Loading…
Cancel
Save