Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
WIP
Mikayla Maki2a5565ca93bf
diff --git a/Cargo.lock b/Cargo.lockindex 90482254742..74860439dd8 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -6793,6 +6793,7 @@ version = "0.1.0"dependencies = ["anyhow","backtrace",+ "dirs 3.0.2","futures 0.3.25","git2","lazy_static",@@ -7707,7 +7708,6 @@ dependencies = ["context_menu","ctor","diagnostics",- "dirs 3.0.2","easy-parallel","editor","env_logger",diff --git a/crates/util/Cargo.toml b/crates/util/Cargo.tomlindex fc16eeb53c3..0a0bacf53c0 100644--- a/crates/util/Cargo.toml+++ b/crates/util/Cargo.toml@@ -19,6 +19,7 @@ rand = { workspace = true }tempdir = { version = "0.3.7", optional = true }serde_json = { version = "1.0", features = ["preserve_order"], optional = true }git2 = { version = "0.15", default-features = false, optional = true }+dirs = "3.0"[dev-dependencies]diff --git a/crates/util/src/lib.rs b/crates/util/src/lib.rsindex 19d17c1190a..b03bc21210f 100644--- a/crates/util/src/lib.rs+++ b/crates/util/src/lib.rs@@ -1,3 +1,4 @@+pub mod paths;#[cfg(any(test, feature = "test-support"))]pub mod test;diff --git a/crates/zed/src/paths.rs b/crates/util/src/paths.rssimilarity index 100%rename from crates/zed/src/paths.rsrename to crates/util/src/paths.rsdiff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.tomlindex a3023918e37..7fef0aafcf8 100644--- a/crates/zed/Cargo.toml+++ b/crates/zed/Cargo.toml@@ -62,7 +62,6 @@ async-trait = "0.1"backtrace = "0.3"chrono = "0.4"ctor = "0.1.20"-dirs = "3.0"easy-parallel = "3.1.0"env_logger = "0.9"futures = "0.3"diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rsindex 05f5b8871fb..6e7aaba3c6e 100644--- a/crates/zed/src/main.rs+++ b/crates/zed/src/main.rs@@ -37,7 +37,7 @@ use terminal::terminal_container_view::{get_working_directory, TerminalContaineruse fs::RealFs;use settings::watched_json::{watch_keymap_file, watch_settings_file, WatchedJsonFile};use theme::ThemeRegistry;-use util::{ResultExt, TryFutureExt};+use util::{paths, ResultExt, TryFutureExt};use workspace::{self, AppState, ItemHandle, NewFile, OpenPaths, Workspace};use zed::{self, build_window_options, initialize_workspace, languages, menus, RELEASE_CHANNEL,@@ -57,7 +57,7 @@ fn main() {init_panic_hook(app_version, http.clone(), app.background());let db = app.background().spawn(async move {- project::Db::<project::KeyValue>::open(&*zed::paths::DB_DIR, RELEASE_CHANNEL_NAME.as_str())+ project::Db::<project::KeyValue>::open(&*paths::DB_DIR, RELEASE_CHANNEL_NAME.as_str())});load_embedded_fonts(&app);@@ -91,11 +91,11 @@ fn main() {app.run(move |cx| {cx.set_global(*RELEASE_CHANNEL);- cx.set_global(HomeDir(zed::paths::HOME.to_path_buf()));+ cx.set_global(HomeDir(paths::HOME.to_path_buf()));let client = client::Client::new(http.clone(), cx);let mut languages = LanguageRegistry::new(login_shell_env_loaded);- languages.set_language_server_download_dir(zed::paths::LANGUAGES_DIR.clone());+ languages.set_language_server_download_dir(paths::LANGUAGES_DIR.clone());let languages = Arc::new(languages);let init_languages = cx.background()@@ -106,7 +106,7 @@ fn main() {//Setup settings global before binding actionscx.set_global(SettingsFile::new(- &*zed::paths::SETTINGS,+ &*paths::SETTINGS,settings_file_content.clone(),fs.clone(),));@@ -236,16 +236,15 @@ fn init_logger() {const KIB: u64 = 1024;const MIB: u64 = 1024 * KIB;const MAX_LOG_BYTES: u64 = MIB;- if std::fs::metadata(&*zed::paths::LOG)- .map_or(false, |metadata| metadata.len() > MAX_LOG_BYTES)+ if std::fs::metadata(&*paths::LOG).map_or(false, |metadata| metadata.len() > MAX_LOG_BYTES){- let _ = std::fs::rename(&*zed::paths::LOG, &*zed::paths::OLD_LOG);+ let _ = std::fs::rename(&*paths::LOG, &*paths::OLD_LOG);}let log_file = OpenOptions::new().create(true).append(true)- .open(&*zed::paths::LOG)+ .open(&*paths::LOG).expect("could not open logfile");simplelog::WriteLogger::init(level, simplelog::Config::default(), log_file).expect("could not initialize logger");@@ -257,7 +256,7 @@ fn init_panic_hook(app_version: String, http: Arc<dyn HttpClient>, background: A.spawn({async move {let panic_report_url = format!("{}/api/panic", &*client::ZED_SERVER_URL);- let mut children = smol::fs::read_dir(&*zed::paths::LOGS_DIR).await?;+ let mut children = smol::fs::read_dir(&*paths::LOGS_DIR).await?;while let Some(child) = children.next().await {let child = child?;let child_path = child.path();@@ -345,7 +344,7 @@ fn init_panic_hook(app_version: String, http: Arc<dyn HttpClient>, background: Alet panic_filename = chrono::Utc::now().format("%Y_%m_%d %H_%M_%S").to_string();std::fs::write(- zed::paths::LOGS_DIR.join(format!("zed-{}-{}.panic", app_version, panic_filename)),+ paths::LOGS_DIR.join(format!("zed-{}-{}.panic", app_version, panic_filename)),&message,).context("error writing panic to disk")@@ -479,8 +478,8 @@ fn load_config_files(.clone().spawn(async move {let settings_file =- WatchedJsonFile::new(fs.clone(), &executor, zed::paths::SETTINGS.clone()).await;- let keymap_file = WatchedJsonFile::new(fs, &executor, zed::paths::KEYMAP.clone()).await;+ WatchedJsonFile::new(fs.clone(), &executor, paths::SETTINGS.clone()).await;+ let keymap_file = WatchedJsonFile::new(fs, &executor, paths::KEYMAP.clone()).await;tx.send((settings_file, keymap_file)).ok()}).detach();diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rsindex d6106d78e48..a8ec71bd4b5 100644--- a/crates/zed/src/zed.rs+++ b/crates/zed/src/zed.rs@@ -1,7 +1,6 @@mod feedback;pub mod languages;pub mod menus;-pub mod paths;#[cfg(any(test, feature = "test-support"))]pub mod test;@@ -31,7 +30,7 @@ use serde::Deserialize;use serde_json::to_string_pretty;use settings::{keymap_file_json_schema, settings_file_json_schema, ReleaseChannel, Settings};use std::{env, path::Path, str, sync::Arc};-use util::ResultExt;+use util::{paths, ResultExt};pub use workspace;use workspace::{sidebar::SidebarSide, AppState, Workspace};