diff options
author | Dmitry Sharshakov | 2021-08-25 16:14:47 +0000 |
---|---|---|
committer | Dmitry Sharshakov | 2021-08-25 16:14:47 +0000 |
commit | 4ee66b876613c3d2c06945520e0c5e392d9315d1 (patch) | |
tree | cb5812e4289ac9a86ce6cb0c83dc8e41b5c0e742 | |
parent | ba96f5d2963e77ab13fb7e4fea0ad34948ea4841 (diff) |
Support remote debug adapter
-rw-r--r-- | helix-term/src/commands.rs | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index b83c1e3e..ecdd2e6d 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(()) } @@ -2283,6 +2301,13 @@ mod cmd { 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, doc: "Evaluate expression in current debug context.", @@ -4406,7 +4431,12 @@ fn suspend(_cx: &mut Context) { } // DAP -fn dap_start_impl(editor: &mut Editor, name: Option<&str>, params: Option<Vec<&str>>) { +fn dap_start_impl( + editor: &mut Editor, + name: Option<&str>, + socket: Option<std::net::SocketAddr>, + params: Option<Vec<&str>>, +) { 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<Vec<&s } }; - let started = Client::process(config.clone(), 0); - let (mut debugger, events) = block_on(started).unwrap(); + let (mut debugger, events) = match socket { + Some(socket) => 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(); |