Implement all but the UI

This commit is contained in:
Mikayla 2023-11-28 15:18:19 -08:00
parent 8faa1f6e58
commit d927c2f497
No known key found for this signature in database
11 changed files with 468 additions and 428 deletions

View file

@ -13,7 +13,7 @@ use db::kvp::KEY_VALUE_STORE;
use editor::Editor;
use fs::RealFs;
use futures::StreamExt;
use gpui::{Action, App, AppContext, AsyncAppContext, Context, SemanticVersion, Task};
use gpui::{App, AppContext, AsyncAppContext, Context, SemanticVersion, Task};
use isahc::{prelude::Configurable, Request};
use language::LanguageRegistry;
use log::LevelFilter;
@ -48,6 +48,7 @@ use util::{
paths, ResultExt,
};
use uuid::Uuid;
use welcome::{show_welcome_experience, FIRST_OPEN};
use workspace::{AppState, WorkspaceStore};
use zed2::{
build_window_options, ensure_only_instance, handle_cli_connection, initialize_workspace,
@ -163,17 +164,16 @@ fn main() {
// assistant::init(cx);
// component_test::init(cx);
// cx.spawn(|cx| watch_themes(fs.clone(), cx)).detach();
// cx.spawn(|_| watch_languages(fs.clone(), languages.clone()))
// .detach();
// watch_file_types(fs.clone(), cx);
languages.set_theme(cx.theme().clone());
// cx.observe_global::<SettingsStore, _>({
// let languages = languages.clone();
// move |cx| languages.set_theme(theme::current(cx).clone())
// })
// .detach();
cx.observe_global::<SettingsStore>({
let languages = languages.clone();
move |cx| languages.set_theme(cx.theme().clone())
})
.detach();
client.telemetry().start(installation_id, session_id, cx);
let telemetry_settings = *client::TelemetrySettings::get_global(cx);
@ -217,14 +217,13 @@ fn main() {
// journal2::init(app_state.clone(), cx);
// language_selector::init(cx);
// theme_selector::init(cx);
theme_selector::init(cx);
// activity_indicator::init(cx);
// language_tools::init(cx);
call::init(app_state.client.clone(), app_state.user_store.clone(), cx);
collab_ui::init(&app_state, cx);
// feedback::init(cx);
// welcome::init(cx);
// zed::init(&app_state, cx);
welcome::init(cx);
// cx.set_menus(menus::menus());
initialize_workspace(app_state.clone(), cx);
@ -283,6 +282,7 @@ fn main() {
cx.spawn(|mut cx| async move {
// ignore errors here, we'll show a generic "not signed in"
let _ = authenticate(client, &cx).await;
//todo!()
// cx.update(|cx| workspace::join_channel(channel_id, app_state, None, cx))
// .await
anyhow::Ok(())
@ -367,7 +367,8 @@ async fn restore_or_create_workspace(app_state: &Arc<AppState>, mut cx: AsyncApp
.await
.log_err();
} else if matches!(KEY_VALUE_STORE.read_kvp(FIRST_OPEN), Ok(None)) {
cx.update(|cx| show_welcome_experience(app_state, cx));
cx.update(|cx| show_welcome_experience(app_state, cx))
.log_err();
} else {
cx.update(|cx| {
workspace::open_new(app_state, cx, |workspace, cx| {
@ -705,44 +706,23 @@ fn load_embedded_fonts(cx: &AppContext) {
.unwrap();
}
// #[cfg(debug_assertions)]
// async fn watch_themes(fs: Arc<dyn Fs>, mut cx: AsyncAppContext) -> Option<()> {
// let mut events = fs
// .watch("styles/src".as_ref(), Duration::from_millis(100))
// .await;
// while (events.next().await).is_some() {
// let output = Command::new("npm")
// .current_dir("styles")
// .args(["run", "build"])
// .output()
// .await
// .log_err()?;
// if output.status.success() {
// cx.update(|cx| theme_selector::reload(cx))
// } else {
// eprintln!(
// "build script failed {}",
// String::from_utf8_lossy(&output.stderr)
// );
// }
// }
// Some(())
// }
#[cfg(debug_assertions)]
async fn watch_languages(fs: Arc<dyn fs::Fs>, languages: Arc<LanguageRegistry>) -> Option<()> {
use std::time::Duration;
// #[cfg(debug_assertions)]
// async fn watch_languages(fs: Arc<dyn Fs>, languages: Arc<LanguageRegistry>) -> Option<()> {
// let mut events = fs
// .watch(
// "crates/zed/src/languages".as_ref(),
// Duration::from_millis(100),
// )
// .await;
// while (events.next().await).is_some() {
// languages.reload();
// }
// Some(())
// }
let mut events = fs
.watch(
"crates/zed2/src/languages".as_ref(),
Duration::from_millis(100),
)
.await;
while (events.next().await).is_some() {
languages.reload();
}
Some(())
}
//todo!()
// #[cfg(debug_assertions)]
// fn watch_file_types(fs: Arc<dyn Fs>, cx: &mut AppContext) {
// cx.spawn(|mut cx| async move {
@ -763,26 +743,10 @@ fn load_embedded_fonts(cx: &AppContext) {
// .detach()
// }
// #[cfg(not(debug_assertions))]
// async fn watch_themes(_fs: Arc<dyn Fs>, _cx: AsyncAppContext) -> Option<()> {
// None
// }
// #[cfg(not(debug_assertions))]
// async fn watch_languages(_: Arc<dyn Fs>, _: Arc<LanguageRegistry>) -> Option<()> {
// None
//
#[cfg(not(debug_assertions))]
async fn watch_languages(_: Arc<dyn Fs>, _: Arc<LanguageRegistry>) -> Option<()> {
None
}
// #[cfg(not(debug_assertions))]
// fn watch_file_types(_fs: Arc<dyn Fs>, _cx: &mut AppContext) {}
pub fn background_actions() -> &'static [(&'static str, &'static dyn Action)] {
// &[
// ("Go to file", &file_finder::Toggle),
// ("Open command palette", &command_palette::Toggle),
// ("Open recent projects", &recent_projects::OpenRecent),
// ("Change your settings", &zed_actions::OpenSettings),
// ]
// todo!()
&[]
}