mirror of
https://github.com/ilyakooo0/helix.git
synced 2024-11-29 13:32:09 +03:00
move debug command to keybinding
This commit is contained in:
parent
e2c74d26e0
commit
9e22842d51
@ -303,6 +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_run, "Begin program execution",
|
||||
suspend, "Suspend"
|
||||
@ -1902,30 +1903,6 @@ mod cmd {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn debug(
|
||||
cx: &mut compositor::Context,
|
||||
_args: &[&str],
|
||||
_event: PromptEvent,
|
||||
) -> anyhow::Result<()> {
|
||||
use helix_dap::Client;
|
||||
use helix_lsp::block_on;
|
||||
let (_, _doc) = current!(cx.editor);
|
||||
|
||||
// look up config for filetype
|
||||
// if multiple available, open picker
|
||||
|
||||
let debugger = Client::tcp_process("dlv", vec!["dap"], "-l 127.0.0.1:{}", 0);
|
||||
let mut debugger = block_on(debugger)?;
|
||||
|
||||
let request = debugger.initialize("go".to_owned());
|
||||
let _ = block_on(request)?;
|
||||
|
||||
// TODO: either await "initialized" or buffer commands until event is received
|
||||
|
||||
cx.editor.debugger = Some(debugger);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
|
||||
TypableCommand {
|
||||
name: "quit",
|
||||
@ -2164,13 +2141,6 @@ mod cmd {
|
||||
doc: "Display tree sitter scopes, primarily for theming and development.",
|
||||
fun: tree_sitter_scopes,
|
||||
completer: None,
|
||||
},
|
||||
TypableCommand {
|
||||
name: "debug",
|
||||
alias: None,
|
||||
doc: "Start a debug session.",
|
||||
fun: debug,
|
||||
completer: None,
|
||||
}
|
||||
];
|
||||
|
||||
@ -4275,6 +4245,25 @@ fn suspend(_cx: &mut Context) {
|
||||
}
|
||||
|
||||
// DAP
|
||||
fn dap_init(cx: &mut Context) {
|
||||
use helix_dap::Client;
|
||||
use helix_lsp::block_on;
|
||||
let (_, _doc) = current!(cx.editor);
|
||||
|
||||
// look up config for filetype
|
||||
// if multiple available, open picker
|
||||
|
||||
let debugger = Client::tcp_process("dlv", vec!["dap"], "-l 127.0.0.1:{}", 0);
|
||||
let mut debugger = block_on(debugger).unwrap();
|
||||
|
||||
let request = debugger.initialize("go".to_owned());
|
||||
let _ = block_on(request).unwrap();
|
||||
|
||||
// TODO: either await "initialized" or buffer commands until event is received
|
||||
|
||||
cx.editor.debugger = Some(debugger);
|
||||
}
|
||||
|
||||
fn dap_toggle_breakpoint(cx: &mut Context) {
|
||||
use helix_lsp::block_on;
|
||||
|
||||
|
@ -486,6 +486,7 @@ impl Default for Keymaps {
|
||||
"a" => code_action,
|
||||
"'" => last_picker,
|
||||
"d" => { "Debug"
|
||||
"i" => dap_init,
|
||||
"s" => dap_launch,
|
||||
"b" => dap_toggle_breakpoint,
|
||||
"r" => dap_run,
|
||||
|
Loading…
Reference in New Issue
Block a user