Improve dev experience for built-in prompts (#16413)
When launching Zed from the CLI via `cargo run`, we'll always prompt load templates from the repo. This restores behavior that I reverted last night in #16403. Also, I've improved the `script/prompts link/unlink` workflow for overriding prompts of your production copy of Zed. Zed now detects when the overrides directory is created or removed, and does the right thing. You can link and unlink repeatedly without restarting Zed. Release Notes: - N/A
This commit is contained in:
parent
7c268d0c6d
commit
c9c5eef8f2
7 changed files with 182 additions and 99 deletions
|
@ -193,15 +193,28 @@ pub fn prompts_dir() -> &'static PathBuf {
|
|||
/// Returns the path to the prompt templates directory.
|
||||
///
|
||||
/// This is where the prompt templates for core features can be overridden with templates.
|
||||
pub fn prompt_overrides_dir() -> &'static PathBuf {
|
||||
static PROMPT_TEMPLATES_DIR: OnceLock<PathBuf> = OnceLock::new();
|
||||
PROMPT_TEMPLATES_DIR.get_or_init(|| {
|
||||
if cfg!(target_os = "macos") {
|
||||
config_dir().join("prompt_overrides")
|
||||
} else {
|
||||
support_dir().join("prompt_overrides")
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `dev_mode` - If true, assumes the current working directory is the Zed repository.
|
||||
pub fn prompt_overrides_dir(repo_path: Option<&Path>) -> PathBuf {
|
||||
if let Some(path) = repo_path {
|
||||
let dev_path = path.join("assets").join("prompts");
|
||||
if dev_path.exists() {
|
||||
return dev_path;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
static PROMPT_TEMPLATES_DIR: OnceLock<PathBuf> = OnceLock::new();
|
||||
PROMPT_TEMPLATES_DIR
|
||||
.get_or_init(|| {
|
||||
if cfg!(target_os = "macos") {
|
||||
config_dir().join("prompt_overrides")
|
||||
} else {
|
||||
support_dir().join("prompt_overrides")
|
||||
}
|
||||
})
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// Returns the path to the semantic search's embeddings directory.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue