mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 04:44:30 +00:00
copilot: Colocate copilot_chat_config_path
with the rest of the Copilot code (#15703)
This PR moves the `copilot_chat_config_path` out of `paths` and into `copilot` with the rest of the Copilot code. Since this doesn't actually return a Zed path, it doesn't belong in `paths`. Release Notes: - N/A
This commit is contained in:
parent
e2eb68abca
commit
d6e558e3c9
2 changed files with 18 additions and 15 deletions
|
@ -1,3 +1,5 @@
|
|||
use std::path::PathBuf;
|
||||
use std::sync::OnceLock;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
|
@ -7,6 +9,7 @@ use futures::{io::BufReader, stream::BoxStream, AsyncBufReadExt, AsyncReadExt, S
|
|||
use gpui::{AppContext, AsyncAppContext, Global};
|
||||
use http_client::{AsyncBody, HttpClient, Method, Request as HttpRequest};
|
||||
use isahc::config::Configurable;
|
||||
use paths::home_dir;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings::watch_config_file;
|
||||
use strum::EnumIter;
|
||||
|
@ -164,6 +167,20 @@ pub fn init(fs: Arc<dyn Fs>, client: Arc<dyn HttpClient>, cx: &mut AppContext) {
|
|||
cx.set_global(GlobalCopilotChat(copilot_chat));
|
||||
}
|
||||
|
||||
fn copilot_chat_config_path() -> &'static PathBuf {
|
||||
static COPILOT_CHAT_CONFIG_DIR: OnceLock<PathBuf> = OnceLock::new();
|
||||
|
||||
COPILOT_CHAT_CONFIG_DIR.get_or_init(|| {
|
||||
if cfg!(target_os = "windows") {
|
||||
home_dir().join("AppData").join("Local")
|
||||
} else {
|
||||
home_dir().join(".config")
|
||||
}
|
||||
.join("github-copilot")
|
||||
.join("hosts.json")
|
||||
})
|
||||
}
|
||||
|
||||
impl CopilotChat {
|
||||
pub fn global(cx: &AppContext) -> Option<gpui::Model<Self>> {
|
||||
cx.try_global::<GlobalCopilotChat>()
|
||||
|
@ -174,7 +191,7 @@ impl CopilotChat {
|
|||
let mut config_file_rx = watch_config_file(
|
||||
cx.background_executor(),
|
||||
fs,
|
||||
paths::copilot_chat_config_path().clone(),
|
||||
copilot_chat_config_path().clone(),
|
||||
);
|
||||
|
||||
cx.spawn(|cx| async move {
|
||||
|
|
|
@ -212,20 +212,6 @@ pub fn copilot_dir() -> &'static PathBuf {
|
|||
COPILOT_DIR.get_or_init(|| support_dir().join("copilot"))
|
||||
}
|
||||
|
||||
pub fn copilot_chat_config_path() -> &'static PathBuf {
|
||||
static COPILOT_CHAT_CONFIG_DIR: OnceLock<PathBuf> = OnceLock::new();
|
||||
|
||||
COPILOT_CHAT_CONFIG_DIR.get_or_init(|| {
|
||||
if cfg!(target_os = "windows") {
|
||||
home_dir().join("AppData").join("Local")
|
||||
} else {
|
||||
home_dir().join(".config")
|
||||
}
|
||||
.join("github-copilot")
|
||||
.join("hosts.json")
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the path to the Supermaven directory.
|
||||
pub fn supermaven_dir() -> &'static PathBuf {
|
||||
static SUPERMAVEN_DIR: OnceLock<PathBuf> = OnceLock::new();
|
||||
|
|
Loading…
Reference in a new issue