summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helix-dap/src/types.rs2
-rw-r--r--helix-term/src/ui/editor.rs84
-rw-r--r--helix-view/src/editor.rs2
-rw-r--r--languages.toml4
4 files changed, 58 insertions, 34 deletions
diff --git a/helix-dap/src/types.rs b/helix-dap/src/types.rs
index d31b8023..7207f412 100644
--- a/helix-dap/src/types.rs
+++ b/helix-dap/src/types.rs
@@ -7,7 +7,7 @@ use std::{collections::HashMap, path::PathBuf};
pub struct DebugTemplate {
pub name: String,
pub request: String,
- pub completion: Option<Vec<String>>,
+ pub completion: Vec<String>,
pub args: HashMap<String, String>,
}
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 25adc126..cdb68ef6 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -709,6 +709,54 @@ impl EditorView {
);
}
+ fn request_parameter(
+ completions: Vec<String>,
+ config_name: String,
+ cxt: &mut commands::Context,
+ mut params: Vec<String>,
+ ) {
+ let noop = |_input: &str| Vec::new();
+ let completer = match completions.get(0).map(|x| x.as_str()) {
+ Some("filename") => super::completers::filename,
+ Some("directory") => super::completers::directory,
+ Some(complete) => {
+ warn!("Unknown debug config autocompleter: {}", complete);
+ noop
+ }
+ None => noop,
+ };
+ let prompt = Prompt::new(
+ "arg: ".to_owned(),
+ None,
+ completer,
+ move |cx: &mut crate::compositor::Context, input: &str, event: PromptEvent| {
+ if event != PromptEvent::Validate {
+ return;
+ }
+
+ params.push(input.to_owned());
+
+ if params.len() < completions.len() {
+ todo!();
+ // Self::request_parameter(
+ // completions.clone(),
+ // config_name.clone(),
+ // cxt,
+ // params.clone(),
+ // );
+ } else {
+ commands::dap_start_impl(
+ cx.editor,
+ Some(&config_name),
+ None,
+ Some(params.iter().map(|x| x.as_str()).collect()),
+ );
+ }
+ },
+ );
+ cxt.push_layer(Box::new(prompt));
+ }
+
/// Handle events by looking them up in `self.keymaps`. Returns None
/// if event was handled (a command was executed or a subkeymap was
/// activated). Only KeymapResult::{NotFound, Cancelled} is returned
@@ -735,38 +783,10 @@ impl EditorView {
None => return None,
};
let completions = cxt.editor.debug_config_completions.clone().unwrap();
- let noop = |_input: &str| Vec::new();
- let completer = match completions.get(i) {
- Some(Some(completion)) => match completion.get(0).map(|x| x.as_str()) {
- Some("filename") => super::completers::filename,
- Some("directory") => super::completers::directory,
- Some(complete) => {
- warn!("Unknown debug config autocompleter: {}", complete);
- noop
- }
- None => noop,
- },
- _ => noop,
- };
- let prompt = Prompt::new(
- "arg:".to_owned(),
- None,
- completer,
- move |cx: &mut crate::compositor::Context,
- input: &str,
- event: PromptEvent| {
- if event != PromptEvent::Validate {
- return;
- }
- commands::dap_start_impl(
- cx.editor,
- Some(&name),
- None,
- Some(vec![input]),
- );
- },
- );
- cxt.push_layer(Box::new(prompt));
+ let completion = completions.get(i).unwrap().clone();
+ if !completion.is_empty() {
+ Self::request_parameter(completion, name, cxt, Vec::new());
+ }
}
_ => return None,
}
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 9644ba57..235974d7 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -77,7 +77,7 @@ pub struct Editor {
pub debugger: Option<helix_dap::Client>,
pub debugger_events: SelectAll<UnboundedReceiverStream<helix_dap::Payload>>,
pub debug_config_picker: Option<Vec<String>>,
- pub debug_config_completions: Option<Vec<Option<Vec<String>>>>,
+ pub debug_config_completions: Option<Vec<Vec<String>>>,
pub variables: Option<Vec<String>>,
pub variables_page: usize,
diff --git a/languages.toml b/languages.toml
index ef263293..04f7faea 100644
--- a/languages.toml
+++ b/languages.toml
@@ -36,6 +36,7 @@ args = { console = "internalConsole", program = "{0}" }
[[language.debugger.templates]]
name = "attach"
request = "attach"
+completion = [ "none" ]
args = { console = "internalConsole", pid = "{0}" }
[[language]]
@@ -104,6 +105,7 @@ args = { console = "internalConsole", program = "{0}" }
[[language.debugger.templates]]
name = "attach"
request = "attach"
+completion = [ "none" ]
args = { console = "internalConsole", pid = "{0}" }
[[language]]
@@ -133,6 +135,7 @@ args = { console = "internalConsole", program = "{0}" }
[[language.debugger.templates]]
name = "attach"
request = "attach"
+completion = [ "none" ]
args = { console = "internalConsole", pid = "{0}" }
[[language]]
@@ -176,6 +179,7 @@ args = { mode = "test", program = "{0}" }
[[language.debugger.templates]]
name = "attach"
request = "attach"
+completion = [ "none" ]
args = { mode = "local", processId = "{0}" }
[[language]]