zed/crates/settings_ui/examples/ui.rs
Mikayla Maki 53885c00d3
Start up settings UI 2 (#38673)
Release Notes:

- N/A

---------

Co-authored-by: Anthony <hello@anthonyeid.me>
Co-authored-by: Ben Kunkle <ben@zed.dev>
Co-authored-by: Anthony <anthony@zed.dev>
Co-authored-by: Ben Kunkle <ben.kunkle@gmail.com>
2025-09-24 15:45:14 +00:00

48 lines
1.5 KiB
Rust

use std::sync::Arc;
use futures::StreamExt;
use settings::{DEFAULT_KEYMAP_PATH, KeymapFile, SettingsStore, watch_config_file};
use settings_ui::open_settings_editor;
use ui::BorrowAppContext;
fn main() {
let app = gpui::Application::new().with_assets(assets::Assets);
let fs = Arc::new(fs::RealFs::new(None, app.background_executor()));
let mut user_settings_file_rx = watch_config_file(
&app.background_executor(),
fs.clone(),
paths::settings_file().clone(),
);
zlog::init();
zlog::init_output_stderr();
app.run(move |cx| {
<dyn fs::Fs>::set_global(fs.clone(), cx);
settings::init(cx);
theme::init(theme::LoadThemes::JustBase, cx);
workspace::init_settings(cx);
project::Project::init_settings(cx);
language::init(cx);
editor::init(cx);
menu::init();
let keybindings =
KeymapFile::load_asset_allow_partial_failure(DEFAULT_KEYMAP_PATH, cx).unwrap();
cx.bind_keys(keybindings);
cx.spawn(async move |cx| {
while let Some(content) = user_settings_file_rx.next().await {
cx.update(|cx| {
cx.update_global(|store: &mut SettingsStore, cx| {
store.set_user_settings(&content, cx).unwrap()
})
})
.ok();
}
})
.detach();
open_settings_editor(cx).unwrap();
cx.activate(true);
});
}