Support remote debug adapter

imgbot
Dmitry Sharshakov 3 years ago
parent ba96f5d296
commit 4ee66b8766
No known key found for this signature in database
GPG Key ID: 471FD32E15FD8473

@ -2032,7 +2032,25 @@ mod cmd {
0 => None, 0 => None,
_ => Some(args.remove(0)), _ => 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(()) Ok(())
} }
@ -2282,6 +2300,13 @@ mod cmd {
fun: debug_start, fun: debug_start,
completer: Some(completers::filename), 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 { TypableCommand {
name: "debug-eval", name: "debug-eval",
alias: None, alias: None,
@ -4406,7 +4431,12 @@ fn suspend(_cx: &mut Context) {
} }
// DAP // 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_dap::Client;
use helix_lsp::block_on; use helix_lsp::block_on;
use serde_json::to_value; 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) = match socket {
let (mut debugger, events) = block_on(started).unwrap(); 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 request = debugger.initialize(config.name.clone());
let _ = block_on(request).unwrap(); let _ = block_on(request).unwrap();

Loading…
Cancel
Save