terminal: Allow configuring conda manager (#40577)
Closes #40576 This PR makes Conda activation configurable and transparent by adding a `terminal.detect_venv.on.conda_manager` setting (`"auto" | "conda" | "mamba" | "micromamba"`, default `"auto"`), updating Python environment activation to honor this preference (or the detected manager executable) and fall back to `conda` when necessary. The preference is passed via `ZED_CONDA_MANAGER` from the terminal settings, and the activation command is built accordingly (with proper quoting for paths). Changes span `zed/crates/terminal/src/terminal_settings.rs` (new `CondaManager` and setting), `zed/crates/project/src/terminals.rs` (inject env var), `zed/crates/languages/src/python.rs` (activation logic), and `zed/assets/settings/default.json` (document the setting). Default behavior remains unchanged for most users while enabling explicit selection of `mamba` or `micromamba`. Release Notes: - Added: terminal.detect_venv.on.conda_manager setting to choose the Conda manager (auto, conda, mamba, micromamba). Default: auto. - Changed: Python Conda environment activation now respects the configured manager, otherwise uses the detected environment manager executable, and falls back to conda. - Reliability: Activation commands quote manager paths to handle spaces across platforms. - Compatibility: No breaking changes; non-Conda environments are unaffected; remote terminals are supported. --------- Co-authored-by: Lukas Wirth <me@lukaswirth.dev> Co-authored-by: Lukas Wirth <lukas@zed.dev>
This commit is contained in:
co-authored by
Lukas Wirth
Lukas Wirth
parent
082b80ec89
commit
9d52b6c538
@@ -348,6 +348,22 @@ pub struct TerminalToolbarContent {
|
||||
pub breadcrumbs: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema, MergeFrom,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CondaManager {
|
||||
/// Automatically detect the conda manager
|
||||
#[default]
|
||||
Auto,
|
||||
/// Use conda
|
||||
Conda,
|
||||
/// Use mamba
|
||||
Mamba,
|
||||
/// Use micromamba
|
||||
Micromamba,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema, MergeFrom)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum VenvSettings {
|
||||
@@ -360,6 +376,10 @@ pub enum VenvSettings {
|
||||
activate_script: Option<ActivateScript>,
|
||||
venv_name: Option<String>,
|
||||
directories: Option<Vec<PathBuf>>,
|
||||
/// Preferred Conda manager to use when activating Conda environments.
|
||||
///
|
||||
/// Default: auto
|
||||
conda_manager: Option<CondaManager>,
|
||||
},
|
||||
}
|
||||
#[skip_serializing_none]
|
||||
@@ -367,6 +387,7 @@ pub struct VenvSettingsContent<'a> {
|
||||
pub activate_script: ActivateScript,
|
||||
pub venv_name: &'a str,
|
||||
pub directories: &'a [PathBuf],
|
||||
pub conda_manager: CondaManager,
|
||||
}
|
||||
|
||||
impl VenvSettings {
|
||||
@@ -377,10 +398,12 @@ impl VenvSettings {
|
||||
activate_script,
|
||||
venv_name,
|
||||
directories,
|
||||
conda_manager,
|
||||
} => Some(VenvSettingsContent {
|
||||
activate_script: activate_script.unwrap_or(ActivateScript::Default),
|
||||
venv_name: venv_name.as_deref().unwrap_or(""),
|
||||
directories: directories.as_deref().unwrap_or(&[]),
|
||||
conda_manager: conda_manager.unwrap_or(CondaManager::Auto),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user