From 4ee66b876613c3d2c06945520e0c5e392d9315d1 Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Wed, 25 Aug 2021 19:14:47 +0300 Subject: [PATCH] Support remote debug adapter --- helix-term/src/commands.rs | 40 ++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index b83c1e3e5..ecdd2e6d3 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2032,7 +2032,25 @@ mod cmd { 0 => None, _ => Some(args.remove(0)), }; - dap_start_impl(&mut cx.editor, name, Some(args)); + dap_start_impl(&mut cx.editor, name, None, Some(args)); + Ok(()) + } + + fn debug_remote( + cx: &mut compositor::Context, + args: &[&str], + _event: PromptEvent, + ) -> anyhow::Result<()> { + let mut args = args.to_owned(); + let address = match args.len() { + 0 => None, + _ => Some(args.remove(0).parse().unwrap()), + }; + let name = match args.len() { + 0 => None, + _ => Some(args.remove(0)), + }; + dap_start_impl(&mut cx.editor, name, address, Some(args)); Ok(()) } @@ -2282,6 +2300,13 @@ mod cmd { fun: debug_start, completer: Some(completers::filename), }, + TypableCommand { + name: "debug-remote", + alias: Some("dbg-tcp"), + doc: "Connect to a debug adapter by TCP address and start a debugging session from a given template with given parameters.", + fun: debug_remote, + completer: Some(completers::filename), + }, TypableCommand { name: "debug-eval", alias: None, @@ -4406,7 +4431,12 @@ fn suspend(_cx: &mut Context) { } // DAP -fn dap_start_impl(editor: &mut Editor, name: Option<&str>, params: Option>) { +fn dap_start_impl( + editor: &mut Editor, + name: Option<&str>, + socket: Option, + params: Option>, +) { use helix_dap::Client; use helix_lsp::block_on; use serde_json::to_value; @@ -4435,8 +4465,10 @@ fn dap_start_impl(editor: &mut Editor, name: Option<&str>, params: Option block_on(Client::tcp(socket, 0)).unwrap(), + None => block_on(Client::process(config.clone(), 0)).unwrap(), + }; let request = debugger.initialize(config.name.clone()); let _ = block_on(request).unwrap();