on master help sign in
move debug command to keybinding
commit9e22842d51af88b652a66926ac5b5eded182779d authorDmitry Sharshakov <d3dx12.xx@gmail.com> dateFri 20 Aug 2021, 19:06 (5 years ago) parente2c74d2
2 files changed+21−31
helix-term/src/commands.rs+20−31 helix-term/src/keymap.rs+1
helix-term/src/commands.rs+20−31
@@ -303,6 +303,7 @@ impl Command {
303303 select_textobject_around, "Select around object",
304304 select_textobject_inner, "Select inside object",
305305 dap_toggle_breakpoint, "Toggle breakpoint",
306+ dap_init, "Start debug session",
306307 dap_launch, "Launch debugger",
307308 dap_run, "Begin program execution",
308309 suspend, "Suspend"
@@ -1902,30 +1903,6 @@ mod cmd {
19021903 Ok(())
19031904 }
19041905
1905− fn debug(
1906− cx: &mut compositor::Context,
1907− _args: &[&str],
1908− _event: PromptEvent,
1909− ) -> anyhow::Result<()> {
1910− use helix_dap::Client;
1911− use helix_lsp::block_on;
1912− let (_, _doc) = current!(cx.editor);
1913−
1914− // look up config for filetype
1915− // if multiple available, open picker
1916−
1917− let debugger = Client::tcp_process("dlv", vec!["dap"], "-l 127.0.0.1:{}", 0);
1918− let mut debugger = block_on(debugger)?;
1919−
1920− let request = debugger.initialize("go".to_owned());
1921− let _ = block_on(request)?;
1922−
1923− // TODO: either await "initialized" or buffer commands until event is received
1924−
1925− cx.editor.debugger = Some(debugger);
1926− Ok(())
1927− }
1928−
19291906 pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
19301907 TypableCommand {
19311908 name: "quit",
@@ -2164,13 +2141,6 @@ mod cmd {
21642141 doc: "Display tree sitter scopes, primarily for theming and development.",
21652142 fun: tree_sitter_scopes,
21662143 completer: None,
2167− },
2168− TypableCommand {
2169− name: "debug",
2170− alias: None,
2171− doc: "Start a debug session.",
2172− fun: debug,
2173− completer: None,
21742144 }
21752145 ];
21762146
@@ -4275,6 +4245,25 @@ fn suspend(_cx: &mut Context) {
42754245}
42764246
42774247// DAP
4248+fn dap_init(cx: &mut Context) {
4249+ use helix_dap::Client;
4250+ use helix_lsp::block_on;
4251+ let (_, _doc) = current!(cx.editor);
4252+
4253+ // look up config for filetype
4254+ // if multiple available, open picker
4255+
4256+ let debugger = Client::tcp_process("dlv", vec!["dap"], "-l 127.0.0.1:{}", 0);
4257+ let mut debugger = block_on(debugger).unwrap();
4258+
4259+ let request = debugger.initialize("go".to_owned());
4260+ let _ = block_on(request).unwrap();
4261+
4262+ // TODO: either await "initialized" or buffer commands until event is received
4263+
4264+ cx.editor.debugger = Some(debugger);
4265+}
4266+
42784267fn dap_toggle_breakpoint(cx: &mut Context) {
42794268 use helix_lsp::block_on;
42804269
helix-term/src/keymap.rs+1
@@ -486,6 +486,7 @@ impl Default for Keymaps {
486486 "a" => code_action,
487487 "'" => last_picker,
488488 "d" => { "Debug"
489+ "i" => dap_init,
489490 "s" => dap_launch,
490491 "b" => dap_toggle_breakpoint,
491492 "r" => dap_run,