on master help sign in
Unify init and launch commands
738e8a4Dmitry Sharshakov
helix-term/src/commands.rs+11−17
@@ -303,8 +303,7 @@ impl Command {
303 select_textobject_around, "Select around object",
303 select_textobject_around, "Select around object",
304 select_textobject_inner, "Select inside object",
304 select_textobject_inner, "Select inside object",
305 dap_toggle_breakpoint, "Toggle breakpoint",
305 dap_toggle_breakpoint, "Toggle breakpoint",
306− dap_init, "Start debug session",
306+ dap_start, "Start debug session",
307− dap_launch, "Launch debugger",
308 dap_run, "Begin program execution",
307 dap_run, "Begin program execution",
309 suspend, "Suspend"
308 suspend, "Suspend"
310 );
309 );
@@ -4245,9 +4244,11 @@ fn suspend(_cx: &mut Context) {
4245}
4244}
4246
4245
4247// DAP
4246// DAP
4248−fn dap_init(cx: &mut Context) {
4247+fn dap_start(cx: &mut Context) {
4249 use helix_dap::Client;
4248 use helix_dap::Client;
4250 use helix_lsp::block_on;
4249 use helix_lsp::block_on;
4250+ use serde_json::to_value;
4251+
4251 let (_, _doc) = current!(cx.editor);
4252 let (_, _doc) = current!(cx.editor);
4252
4253
4253 // look up config for filetype
4254 // look up config for filetype
@@ -4259,6 +4260,13 @@ fn dap_init(cx: &mut Context) {
4259 let request = debugger.initialize("go".to_owned());
4260 let request = debugger.initialize("go".to_owned());
4260 let _ = block_on(request).unwrap();
4261 let _ = block_on(request).unwrap();
4261
4262
4263+ let mut args = HashMap::new();
4264+ args.insert("mode", "debug");
4265+ args.insert("program", "main.go");
4266+
4267+ let request = debugger.launch(to_value(args).unwrap());
4268+ let _ = block_on(request).unwrap();
4269+
4262 // TODO: either await "initialized" or buffer commands until event is received
4270 // TODO: either await "initialized" or buffer commands until event is received
4263
4271
4264 cx.editor.debugger = Some(debugger);
4272 cx.editor.debugger = Some(debugger);
@@ -4303,20 +4311,6 @@ fn dap_toggle_breakpoint(cx: &mut Context) {
4303 }
4311 }
4304}
4312}
4305
4313
4306−fn dap_launch(cx: &mut Context) {
4307− use helix_lsp::block_on;
4308− use serde_json::to_value;
4309−
4310− if let Some(debugger) = &mut cx.editor.debugger {
4311− let mut args = HashMap::new();
4312− args.insert("mode", "debug");
4313− args.insert("program", "main.go");
4314−
4315− let request = debugger.launch(to_value(args).unwrap());
4316− let _ = block_on(request).unwrap();
4317− }
4318−}
4319−
4320fn dap_run(cx: &mut Context) {
4314fn dap_run(cx: &mut Context) {
4321 use helix_lsp::block_on;
4315 use helix_lsp::block_on;
4322
4316
helix-term/src/keymap.rs+1−2
@@ -486,8 +486,7 @@ impl Default for Keymaps {
486 "a" => code_action,
486 "a" => code_action,
487 "'" => last_picker,
487 "'" => last_picker,
488 "d" => { "Debug"
488 "d" => { "Debug"
489− "i" => dap_init,
489+ "s" => dap_start,
490− "s" => dap_launch,
491 "b" => dap_toggle_breakpoint,
490 "b" => dap_toggle_breakpoint,
492 "r" => dap_run,
491 "r" => dap_run,
493 },
492 },