aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helix-core/src/syntax.rs4
-rw-r--r--helix-dap/src/client.rs13
-rw-r--r--helix-dap/src/lib.rs2
-rw-r--r--helix-term/src/commands/dap.rs16
-rw-r--r--languages.toml12
5 files changed, 44 insertions, 3 deletions
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index 75c2b179..996823ce 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -5,6 +5,7 @@ use crate::{
Rope, RopeSlice, Tendril,
};
+use helix_dap::DebuggerQuirks;
pub use helix_syntax::get_language;
use arc_swap::ArcSwap;
@@ -107,11 +108,14 @@ pub struct DebugTemplate {
pub struct DebugAdapterConfig {
pub name: String,
pub transport: String,
+ #[serde(default)]
pub command: String,
#[serde(default)]
pub args: Vec<String>,
pub port_arg: Option<String>,
pub templates: Vec<DebugTemplate>,
+ #[serde(default)]
+ pub quirks: DebuggerQuirks,
}
#[derive(Debug, Serialize, Deserialize)]
diff --git a/helix-dap/src/client.rs b/helix-dap/src/client.rs
index 8dd41868..832a70c2 100644
--- a/helix-dap/src/client.rs
+++ b/helix-dap/src/client.rs
@@ -5,6 +5,7 @@ use crate::{
};
use anyhow::anyhow;
pub use log::{error, info};
+use serde::{Deserialize, Serialize};
use std::{
collections::HashMap,
net::{IpAddr, Ipv4Addr, SocketAddr},
@@ -20,6 +21,13 @@ use tokio::{
time,
};
+// Different workarounds for adapters' differences
+#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize)]
+pub struct DebuggerQuirks {
+ #[serde(default)]
+ pub absolute_paths: bool,
+}
+
#[derive(Debug)]
pub struct Client {
id: usize,
@@ -34,6 +42,7 @@ pub struct Client {
/// Currently active frame for the current thread.
pub active_frame: Option<usize>,
pub breakpoints: Vec<Breakpoint>,
+ pub quirks: DebuggerQuirks,
}
impl Client {
@@ -45,6 +54,9 @@ impl Client {
port_arg: Option<String>,
id: usize,
) -> Result<(Self, UnboundedReceiver<Payload>)> {
+ if command == "" {
+ return Result::Err(Error::Other(anyhow!("Command not provided")));
+ }
if transport == "tcp" && port_arg.is_some() {
Self::tcp_process(
&command,
@@ -82,6 +94,7 @@ impl Client {
thread_id: None,
active_frame: None,
breakpoints: vec![],
+ quirks: DebuggerQuirks::default(),
};
tokio::spawn(Self::recv(server_rx, client_rx));
diff --git a/helix-dap/src/lib.rs b/helix-dap/src/lib.rs
index f60b102c..100c0c60 100644
--- a/helix-dap/src/lib.rs
+++ b/helix-dap/src/lib.rs
@@ -2,7 +2,7 @@ mod client;
mod transport;
mod types;
-pub use client::Client;
+pub use client::{Client, DebuggerQuirks};
pub use events::Event;
pub use transport::{Payload, Response, Transport};
pub use types::*;
diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs
index 65a0d33f..3f925490 100644
--- a/helix-term/src/commands/dap.rs
+++ b/helix-term/src/commands/dap.rs
@@ -5,7 +5,7 @@ use crate::{
job::Callback,
ui::{FilePicker, Prompt, PromptEvent},
};
-use helix_core::Selection;
+use helix_core::{syntax::DebugConfigCompletion, Selection};
use helix_dap::{self as dap, Client};
use helix_lsp::block_on;
@@ -206,6 +206,8 @@ pub fn dap_start_impl(
return;
}
+ debugger.quirks = config.quirks;
+
let start_config = match name {
Some(name) => config.templates.iter().find(|t| t.name == name),
None => config.templates.get(0),
@@ -225,8 +227,18 @@ pub fn dap_start_impl(
for (k, t) in template {
let mut value = t;
for (i, x) in params.iter().enumerate() {
+ let mut param = x.to_string();
+ if let Some(DebugConfigCompletion::Advanced(cfg)) = start_config.completion.get(i) {
+ if cfg.completion == Some("filename".to_owned())
+ || cfg.completion == Some("directory".to_owned())
+ {
+ param = std::fs::canonicalize(x).ok()
+ .and_then(|pb| pb.into_os_string().into_string().ok())
+ .unwrap_or(x.to_string());
+ }
+ }
// For param #0 replace {0} in args
- value = value.replace(format!("{{{}}}", i).as_str(), x);
+ value = value.replace(format!("{{{}}}", i).as_str(), &param);
}
if let Ok(integer) = value.parse::<usize>() {
diff --git a/languages.toml b/languages.toml
index eb49a70c..a5640c21 100644
--- a/languages.toml
+++ b/languages.toml
@@ -188,6 +188,18 @@ comment-token = "//"
indent = { tab-width = 2, unit = " " }
+[language.debugger]
+name = "node-debug2"
+transport = "stdio"
+# args consisting of cmd (node) and path to adapter should be added to user's configuration
+quirks = { absolute-paths = true }
+
+[[language.debugger.templates]]
+name = "source"
+request = "launch"
+completion = [ { name = "main", completion = "filename", default = "index.js" } ]
+args = { program = "{0}" }
+
[[language]]
name = "typescript"
scope = "source.ts"