From d39baa3b4e1f5bc1a03533e7b22af0043ec1eac9 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Mon, 16 Aug 2021 18:16:06 +0900 Subject: Start integrating into the editor's event loop --- helix-term/src/application.rs | 9 +++++++++ helix-term/src/commands.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) (limited to 'helix-term/src') diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 3d59c33a..59072a09 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -245,6 +245,15 @@ impl Application { } } + pub async fn handle_debugger_message( + &mut self, + call: (), + server_id: usize, + ) { + + // + } + pub async fn handle_language_server_message( &mut self, call: helix_lsp::Call, diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index d7d50109..25367520 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1900,6 +1900,41 @@ mod cmd { Ok(()) } + fn debug( + cx: &mut compositor::Context, + _args: &[&str], + _event: PromptEvent, + ) -> anyhow::Result<()> { + use helix_dap::Client; + use helix_lsp::block_on; + use serde_json::to_value; + let (_, doc) = current!(cx.editor); + + // look up config for filetype + // if multiple available, open picker + + log::error!("1"); + + let client = Client::tcp_process("dlv", vec!["dap"], "-l 127.0.0.1:{}", 0); + let mut client = block_on(client)?; + log::error!("2"); + + let request = client.initialize("go".to_owned()); + let _ = block_on(request)?; + log::error!("3"); + + let mut args = HashMap::new(); + args.insert("mode", "debug"); + // args.insert("program", "path/to/program"); + + let request = client.launch(to_value(args)?); + let _ = block_on(request)?; + + log::error!("4"); + doc.debugger = Some(client); + Ok(()) + } + pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ TypableCommand { name: "quit", @@ -2138,6 +2173,13 @@ 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, } ]; -- cgit v1.2.3-70-g09d2