debugger: Support passing custom arguments to debug adapters (#33251)

Custom arguments replace any arguments that we normally pass to the DAP.
For interpreted languages, they are passed to the interpreter after the
DAP path or module. They can be combined with a custom binary, or you
can omit `dap.binary` and just customize the arguments to the DAPs we
download.

This doesn't take care of updating the extension API to support custom
arguments.

Release Notes:

- debugger: Implemented support for passing custom arguments to a debug
adapter binary using the `dap.args` setting.
- debugger: Fixed not being able to use the `dap` setting in
`.zed/settings.json`.
This commit is contained in:
Cole Miller 2025-06-23 13:06:48 -04:00 committed by GitHub
parent a067c16c82
commit c9bd409732
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 154 additions and 54 deletions

View file

@ -40,7 +40,7 @@ use rpc::{
AnyProtoClient, TypedEnvelope,
proto::{self},
};
use settings::{Settings, WorktreeId};
use settings::{Settings, SettingsLocation, WorktreeId};
use std::{
borrow::Borrow,
collections::BTreeMap,
@ -190,17 +190,23 @@ impl DapStore {
return Task::ready(Err(anyhow!("Failed to find a debug adapter")));
};
let user_installed_path = ProjectSettings::get_global(cx)
let settings_location = SettingsLocation {
worktree_id: worktree.read(cx).id(),
path: Path::new(""),
};
let dap_settings = ProjectSettings::get(Some(settings_location), cx)
.dap
.get(&adapter.name())
.and_then(|s| s.binary.as_ref().map(PathBuf::from));
.get(&adapter.name());
let user_installed_path =
dap_settings.and_then(|s| s.binary.as_ref().map(PathBuf::from));
let user_args = dap_settings.map(|s| s.args.clone());
let delegate = self.delegate(&worktree, console, cx);
let cwd: Arc<Path> = worktree.read(cx).abs_path().as_ref().into();
cx.spawn(async move |this, cx| {
let mut binary = adapter
.get_binary(&delegate, &definition, user_installed_path, cx)
.get_binary(&delegate, &definition, user_installed_path, user_args, cx)
.await?;
let env = this

View file

@ -82,6 +82,8 @@ pub struct ProjectSettings {
#[serde(rename_all = "snake_case")]
pub struct DapSettings {
pub binary: Option<String>,
#[serde(default)]
pub args: Vec<String>,
}
#[derive(Deserialize, Serialize, Clone, PartialEq, Eq, JsonSchema, Debug)]