Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/project/src/task_inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use language::{
language_settings::LanguageSettings,
};
use lsp::{LanguageServerId, LanguageServerName};
use paths::{debug_task_file_name, task_file_name};
use paths::{debug_task_file_name, extensions_dir, task_file_name};
use settings::{InvalidSettingsError, parse_json_with_comments};
use task::{
DebugScenario, ResolvedTask, SharedTaskContext, TaskContext, TaskHook, TaskId, TaskTemplate,
Expand Down Expand Up @@ -1125,6 +1125,11 @@ impl ContextProvider for BasicContextProvider {
task_variables.insert(VariableName::Language, language.name().to_string());
}

task_variables.insert(
VariableName::ExtensionWorkDir,
extensions_dir().join("work").to_string_lossy().into_owned(),
);

Task::ready(Ok(task_variables))
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/task/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ pub enum VariableName {
GitRepositoryPath,
/// Name of the Git ref (branch, remote ref, or tag) associated with the task context.
GitRef,
/// Absolute path of the Zed extensions work directory
ExtensionWorkDir,
/// Custom variable, provided by the plugin or other external source.
/// Will be printed with `CUSTOM_` prefix to avoid potential conflicts with other variables.
Custom(Cow<'static, str>),
Expand Down Expand Up @@ -236,6 +238,7 @@ impl FromStr for VariableName {
"GIT_REPOSITORY_NAME" => Self::GitRepositoryName,
"GIT_REPOSITORY_PATH" => Self::GitRepositoryPath,
"GIT_REF" => Self::GitRef,
"EXTENSION_WORK_DIR" => Self::ExtensionWorkDir,
_ => {
if let Some(custom_name) =
without_prefix.strip_prefix(ZED_CUSTOM_VARIABLE_NAME_PREFIX)
Expand Down Expand Up @@ -277,6 +280,7 @@ impl std::fmt::Display for VariableName {
Self::GitRepositoryName => write!(f, "{ZED_VARIABLE_NAME_PREFIX}GIT_REPOSITORY_NAME"),
Self::GitRepositoryPath => write!(f, "{ZED_VARIABLE_NAME_PREFIX}GIT_REPOSITORY_PATH"),
Self::GitRef => write!(f, "{ZED_VARIABLE_NAME_PREFIX}GIT_REF"),
Self::ExtensionWorkDir => write!(f, "{ZED_VARIABLE_NAME_PREFIX}EXTENSION_WORK_DIR"),
Self::Custom(s) => write!(
f,
"{ZED_VARIABLE_NAME_PREFIX}{ZED_CUSTOM_VARIABLE_NAME_PREFIX}{s}"
Expand Down
1 change: 1 addition & 0 deletions docs/src/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ These variables allow you to pull information from the current editor and use it
- `ZED_WORKTREE_ROOT`: absolute path to the root of the current worktree. (e.g. `/Users/my-user/path/to/project`)
- `ZED_MAIN_GIT_WORKTREE`: absolute path to the main git worktree's working directory. For normal checkouts this equals `ZED_WORKTREE_ROOT`; for linked git worktrees this is the original repository's working directory.
- `ZED_CUSTOM_RUST_PACKAGE`: (Rust-specific) name of the parent package of $ZED_FILE source file.
- `ZED_EXTENSION_WORK_DIR`: the absolute path to the Zed extension work directory

To use a variable in a task, prefix it with a dollar sign (`$`):

Expand Down
Loading