editor: add debug session config

pull/574/head
Dmitry Sharshakov 3 years ago
parent c5b210df59
commit f55a012fb7
No known key found for this signature in database
GPG Key ID: 471FD32E15FD8473

@ -58,6 +58,8 @@ pub struct LanguageConfiguration {
pub(crate) indent_query: OnceCell<Option<IndentQuery>>, pub(crate) indent_query: OnceCell<Option<IndentQuery>>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub debug_adapter: Option<DebugAdapterConfig>, pub debug_adapter: Option<DebugAdapterConfig>,
#[serde(skip_serializing_if = "Option::is_none")]
pub debug_configs: Option<Vec<HashMap<String, serde_json::Value>>>,
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]

@ -4368,9 +4368,24 @@ fn dap_start(cx: &mut Context) {
let request = debugger.initialize("go".to_owned()); let request = debugger.initialize("go".to_owned());
let _ = block_on(request).unwrap(); let _ = block_on(request).unwrap();
let mut args = HashMap::new(); let sessions = cx
args.insert("mode", "debug"); .editor
args.insert("program", "main.go"); .syn_loader
.language_config_for_file_name(&path)
.and_then(|x| x.debug_configs.clone());
let sessions = match sessions {
Some(c) => c,
None => {
cx.editor.set_error(
"Can't start debug: no debug sessions available for language".to_string(),
);
return;
}
};
// TODO: picker
let args = sessions.get(0);
let request = debugger.launch(to_value(args).unwrap()); let request = debugger.launch(to_value(args).unwrap());
let _ = block_on(request).unwrap(); let _ = block_on(request).unwrap();

@ -95,6 +95,21 @@ language-server = { command = "gopls" }
indent = { tab-width = 4, unit = "\t" } indent = { tab-width = 4, unit = "\t" }
debug-adapter = { command = "dlv", args = ["dap"], port-arg = "-l 127.0.0.1:{}" } debug-adapter = { command = "dlv", args = ["dap"], port-arg = "-l 127.0.0.1:{}" }
[[language.debug-configs]]
request = "launch"
mode = "debug"
program = "main.go"
[[language.debug-configs]]
request = "launch"
mode = "exec"
program = "main"
[[language.debug-configs]]
request = "launch"
mode = "test"
program = "."
[[language]] [[language]]
name = "javascript" name = "javascript"
scope = "source.js" scope = "source.js"

Loading…
Cancel
Save