@@ -2027,8 +2027,12 @@ mod cmd {
20272027 args: &[&str],
20282028 _event: PromptEvent,
20292029 ) -> anyhow::Result<()> {
2030− dap_start_impl(&mut cx.editor, args.get(0).map(|name| name.to_string()));
2031− // TODO templating
2030+ let mut args = args.to_owned();
2031+ let name = match args.len() {
2032+ 0 => None,
2033+ _ => Some(args.remove(0)),
2034+ };
2035+ dap_start_impl(&mut cx.editor, name, Some(args));
20322036 Ok(())
20332037 }
20342038
@@ -4402,7 +4406,7 @@ fn suspend(_cx: &mut Context) {
44024406}
44034407
44044408// DAP
4405−fn dap_start_impl(editor: &mut Editor, name: Option<String>) {
4409+fn dap_start_impl(editor: &mut Editor, name: Option<&str>, params: Option<Vec<&str>>) {
44064410 use helix_dap::Client;
44074411 use helix_lsp::block_on;
44084412 use serde_json::to_value;
@@ -4449,7 +4453,22 @@ fn dap_start_impl(editor: &mut Editor, name: Option<String>) {
44494453 }
44504454 };
44514455
4452− let args = to_value(start_config.args.clone()).unwrap();
4456+ let template = start_config.args.clone();
4457+ let mut args = HashMap::new();
4458+
4459+ if let Some(params) = params {
4460+ for (k, t) in template {
4461+ let mut value = t;
4462+ for (i, x) in params.iter().enumerate() {
4463+ // For param #0 replace {0} in args
4464+ value = value.replace(format!("{{{}}}", i).as_str(), x);
4465+ }
4466+
4467+ args.insert(k, value);
4468+ }
4469+ }
4470+
4471+ let args = to_value(args).unwrap();
44534472
44544473 // TODO gracefully handle errors from debugger
44554474 match &start_config.request[..] {
@@ -4470,7 +4489,7 @@ fn dap_start_impl(editor: &mut Editor, name: Option<String>) {
44704489fn dap_start(cx: &mut Context) {
44714490 // TODO: check that first config does not have templates
44724491 // which cannot be handled with a shortcut
4473− dap_start_impl(&mut cx.editor, None);
4492+ dap_start_impl(&mut cx.editor, None, None);
44744493}
44754494
44764495fn dap_toggle_breakpoint(cx: &mut Context) {