Skip to content

Commit

Permalink
Extract paths out of util (zed-industries#13182)
Browse files Browse the repository at this point in the history
This PR extracts the definition of the various Zed paths out of `util`
and into a new `paths` crate.

`util` is for generic utils, while these paths are Zed-specific. For
instance, `gpui` depends on `util`, and it shouldn't have knowledge of
these paths, since they are only used by Zed.

Release Notes:

- N/A
  • Loading branch information
maxdeviant authored and fallenwood committed Jun 18, 2024
1 parent d85c150 commit 3d3d1d4
Show file tree
Hide file tree
Showing 49 changed files with 208 additions and 151 deletions.
37 changes: 26 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ members = [
"crates/open_ai",
"crates/outline",
"crates/outline_panel",
"crates/paths",
"crates/picker",
"crates/prettier",
"crates/project",
Expand Down Expand Up @@ -215,6 +216,7 @@ ollama = { path = "crates/ollama" }
open_ai = { path = "crates/open_ai" }
outline = { path = "crates/outline" }
outline_panel = { path = "crates/outline_panel" }
paths = { path = "crates/paths" }
picker = { path = "crates/picker" }
plugin = { path = "crates/plugin" }
plugin_macros = { path = "crates/plugin_macros" }
Expand Down Expand Up @@ -288,10 +290,10 @@ clap = { version = "4.4", features = ["derive"] }
clickhouse = { version = "0.11.6" }
cocoa = "0.25"
ctor = "0.2.6"
signal-hook = "0.3.17"
core-foundation = { version = "0.9.3" }
core-foundation-sys = "0.8.6"
derive_more = "0.99.17"
dirs = "4.0"
emojis = "0.6.1"
env_logger = "0.9"
exec = "0.3.1"
Expand Down Expand Up @@ -354,6 +356,7 @@ serde_repr = "0.1"
sha2 = "0.10"
shellexpand = "2.1.0"
shlex = "1.3.0"
signal-hook = "0.3.17"
similar = "1.3"
smallvec = { version = "1.6", features = ["union"] }
smol = "1.2"
Expand Down
1 change: 1 addition & 0 deletions crates/assistant/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ollama = { workspace = true, features = ["schemars"] }
open_ai = { workspace = true, features = ["schemars"] }
ordered-float.workspace = true
parking_lot.workspace = true
paths.workspace = true
project.workspace = true
regex.workspace = true
rope.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/assistant/src/assistant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub(crate) use context_store::*;
use gpui::{actions, AppContext, Global, SharedString, UpdateGlobal};
pub(crate) use inline_assistant::*;
pub(crate) use model_selector::*;
use paths::EMBEDDINGS_DIR;
use rustdoc::RustdocStore;
use semantic_index::{CloudEmbeddingProvider, SemanticIndex};
use serde::{Deserialize, Serialize};
Expand All @@ -34,7 +35,6 @@ use std::{
sync::Arc,
};
pub(crate) use streaming_diff::*;
use util::paths::EMBEDDINGS_DIR;

actions!(
assistant,
Expand Down
3 changes: 2 additions & 1 deletion crates/assistant/src/assistant_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use language::{
LspAdapterDelegate, OffsetRangeExt as _, Point, ToOffset as _,
};
use multi_buffer::MultiBufferRow;
use paths::CONTEXTS_DIR;
use picker::{Picker, PickerDelegate};
use project::{Project, ProjectLspAdapterDelegate, ProjectTransaction};
use rustdoc::{CrateName, RustdocStore};
Expand All @@ -59,7 +60,7 @@ use ui::{
prelude::*, ButtonLike, ContextMenu, Disclosure, ElevationIndex, KeyBinding, ListItem,
ListItemSpacing, PopoverMenu, PopoverMenuHandle, Tab, TabBar, Tooltip,
};
use util::{paths::CONTEXTS_DIR, post_inc, ResultExt, TryFutureExt};
use util::{post_inc, ResultExt, TryFutureExt};
use uuid::Uuid;
use workspace::NewFile;
use workspace::{
Expand Down
3 changes: 2 additions & 1 deletion crates/assistant/src/context_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ use fs::Fs;
use futures::StreamExt;
use fuzzy::StringMatchCandidate;
use gpui::{AppContext, Model, ModelContext, Task};
use paths::CONTEXTS_DIR;
use regex::Regex;
use serde::{Deserialize, Serialize};
use std::{cmp::Reverse, ffi::OsStr, path::PathBuf, sync::Arc, time::Duration};
use ui::Context;
use util::{paths::CONTEXTS_DIR, ResultExt, TryFutureExt};
use util::{ResultExt, TryFutureExt};

#[derive(Serialize, Deserialize)]
pub struct SavedMessage {
Expand Down
3 changes: 2 additions & 1 deletion crates/assistant/src/prompt_library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use gpui::{
use heed::{types::SerdeBincode, Database, RoTxn};
use language::{language_settings::SoftWrap, Buffer, LanguageRegistry};
use parking_lot::RwLock;
use paths::PROMPTS_DIR;
use picker::{Picker, PickerDelegate};
use rope::Rope;
use serde::{Deserialize, Serialize};
Expand All @@ -36,7 +37,7 @@ use ui::{
div, prelude::*, IconButtonShape, ListItem, ListItemSpacing, ParentElement, Render,
SharedString, Styled, TitleBar, Tooltip, ViewContext, VisualContext,
};
use util::{paths::PROMPTS_DIR, ResultExt, TryFutureExt};
use util::{ResultExt, TryFutureExt};
use uuid::Uuid;
use workspace::Workspace;

Expand Down
1 change: 1 addition & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ anyhow.workspace = true
clap.workspace = true
ipc-channel = "0.18"
once_cell.workspace = true
paths.workspace = true
release_channel.workspace = true
serde.workspace = true
util.workspace = true
Expand Down
1 change: 0 additions & 1 deletion crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ mod linux {
use cli::FORCE_CLI_MODE_ENV_VAR_NAME;
use fork::Fork;
use once_cell::sync::Lazy;
use util::paths;

use crate::{Detect, InstalledApp};

Expand Down
1 change: 1 addition & 0 deletions crates/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ http.workspace = true
lazy_static.workspace = true
log.workspace = true
once_cell.workspace = true
paths.workspace = true
parking_lot.workspace = true
postage.workspace = true
rand.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ impl Client {
let credentials_provider: Arc<dyn CredentialsProvider + Send + Sync + 'static> =
if use_zed_development_auth {
Arc::new(DevelopmentCredentialsProvider {
path: util::paths::CONFIG_DIR.join("development_auth"),
path: paths::CONFIG_DIR.join("development_auth"),
})
} else {
Arc::new(KeychainCredentialsProvider)
Expand Down
2 changes: 1 addition & 1 deletion crates/client/src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl Telemetry {
let state = state.clone();
async move {
if let Some(tempfile) =
NamedTempFile::new_in(util::paths::CONFIG_DIR.as_path()).log_err()
NamedTempFile::new_in(paths::CONFIG_DIR.as_path()).log_err()
{
state.lock().log_file = Some(tempfile);
}
Expand Down
1 change: 1 addition & 0 deletions crates/copilot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ lsp.workspace = true
menu.workspace = true
node_runtime.workspace = true
parking_lot.workspace = true
paths.workspace = true
project.workspace = true
serde.workspace = true
settings.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/copilot/src/copilot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use std::{
path::{Path, PathBuf},
sync::Arc,
};
use util::{fs::remove_matching, maybe, paths, ResultExt};
use util::{fs::remove_matching, maybe, ResultExt};

pub use copilot_completion_provider::CopilotCompletionProvider;
pub use sign_in::CopilotCodeVerification;
Expand Down
1 change: 1 addition & 0 deletions crates/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ gpui.workspace = true
indoc.workspace = true
lazy_static.workspace = true
log.workspace = true
paths.workspace = true
release_channel.workspace = true
smol.workspace = true
sqlez.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/db/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use anyhow::Context;
use gpui::AppContext;
pub use indoc::indoc;
pub use lazy_static;
pub use paths::DB_DIR;
pub use smol;
pub use sqlez;
pub use sqlez_macros;
pub use util::paths::DB_DIR;

use release_channel::ReleaseChannel;
pub use release_channel::RELEASE_CHANNEL;
Expand Down
1 change: 1 addition & 0 deletions crates/extension/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ language.workspace = true
log.workspace = true
lsp.workspace = true
node_runtime.workspace = true
paths.workspace = true
project.workspace = true
release_channel.workspace = true
schemars.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion crates/extension/src/extension_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use language::{
LanguageConfig, LanguageMatcher, LanguageQueries, LanguageRegistry, QUERY_FILENAME_PREFIXES,
};
use node_runtime::NodeRuntime;
use paths::EXTENSIONS_DIR;
use project::ContextProviderWithTasks;
use release_channel::ReleaseChannel;
use semantic_version::SemanticVersion;
Expand All @@ -51,7 +52,7 @@ use std::{
};
use theme::{ThemeRegistry, ThemeSettings};
use url::Url;
use util::{maybe, paths::EXTENSIONS_DIR, ResultExt};
use util::{maybe, ResultExt};
use wasm_host::{
wit::{is_supported_wasm_api_version, wasm_api_version_range},
WasmExtension, WasmHost,
Expand Down
Loading

0 comments on commit 3d3d1d4

Please sign in to comment.