Allow prompt templates to be overridden in the zed configuration directory (#15887)

I need this to refine our prompts on the fly as I work.

Release Notes:

- Templates for prompts driving inline transformation in editors and the
terminal can now be overridden in the `~/.config/zed/prompts/templates`
directory. This is an advanced feature, and prevents you from getting
upstream changes. It's intended for use by Zed developers.
This commit is contained in:
Nathan Sobo 2024-08-06 19:30:48 -06:00 committed by GitHub
parent 6065db174a
commit c8f1358629
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 569 additions and 168 deletions

View file

@ -184,6 +184,20 @@ 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_templates_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("prompts").join("templates")
} else {
support_dir().join("prompts").join("templates")
}
})
}
/// Returns the path to the semantic search's embeddings directory.
///
/// This is where the embeddings used to power semantic search are stored.