diff options
author | Dmitry Sharshakov | 2021-08-23 13:48:06 +0000 |
---|---|---|
committer | Dmitry Sharshakov | 2021-08-23 13:48:06 +0000 |
commit | c5b210df59983a2caa9c389e5cd22aa670fb4a00 (patch) | |
tree | 0db7e64a51a34e7bad746d59d0b610c34820b335 /helix-term | |
parent | dabec2d7993b23d08f03b52dc08176d437a110a9 (diff) |
Add debug-adapter field to languages.toml
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/commands.rs | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index e35b5d51..3b8e1022 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -4336,12 +4336,33 @@ fn dap_start(cx: &mut Context) { use helix_lsp::block_on; use serde_json::to_value; - let (_, _doc) = current!(cx.editor); + let (_, doc) = current!(cx.editor); - // look up config for filetype - // if multiple available, open picker + // TODO config picker + let path = match doc.path() { + Some(path) => path.to_path_buf(), + None => { + cx.editor + .set_error("Can't start debug: document has no path".to_string()); + return; + } + }; - let started = Client::tcp_process("dlv", vec!["dap"], "-l 127.0.0.1:{}", 0); + let config = cx + .editor + .syn_loader + .language_config_for_file_name(&path) + .and_then(|x| x.debug_adapter.clone()); + let config = match config { + Some(c) => c, + None => { + cx.editor.set_error( + "Can't start debug: no debug adapter available for language".to_string(), + ); + return; + } + }; + let started = Client::tcp_process(config, 0); let (mut debugger, events) = block_on(started).unwrap(); let request = debugger.initialize("go".to_owned()); |