ui.rs

 1use std::sync::Arc;
 2
 3use futures::StreamExt;
 4use settings::{DEFAULT_KEYMAP_PATH, KeymapFile, SettingsStore, watch_config_file};
 5use settings_ui::open_settings_editor;
 6use ui::BorrowAppContext;
 7
 8fn main() {
 9    let app = gpui::Application::new().with_assets(assets::Assets);
10
11    let fs = Arc::new(fs::RealFs::new(None, app.background_executor()));
12    let mut user_settings_file_rx = watch_config_file(
13        &app.background_executor(),
14        fs.clone(),
15        paths::settings_file().clone(),
16    );
17    zlog::init();
18    zlog::init_output_stderr();
19
20    app.run(move |cx| {
21        <dyn fs::Fs>::set_global(fs.clone(), cx);
22        settings::init(cx);
23        theme::init(theme::LoadThemes::JustBase, cx);
24        workspace::init_settings(cx);
25        project::Project::init_settings(cx);
26        language::init(cx);
27        editor::init(cx);
28        menu::init();
29
30        let keybindings =
31            KeymapFile::load_asset_allow_partial_failure(DEFAULT_KEYMAP_PATH, cx).unwrap();
32        cx.bind_keys(keybindings);
33        cx.spawn(async move |cx| {
34            while let Some(content) = user_settings_file_rx.next().await {
35                cx.update(|cx| {
36                    cx.update_global(|store: &mut SettingsStore, cx| {
37                        store.set_user_settings(&content, cx).unwrap()
38                    })
39                })
40                .ok();
41            }
42        })
43        .detach();
44
45        open_settings_editor(cx).unwrap();
46        cx.activate(true);
47    });
48}