Add cmd-, as a keybinding for opening settings

This commit is contained in:
Max Brunsfeld 2022-03-10 15:51:57 -08:00
parent f32107eb8e
commit 44a68b723c
2 changed files with 20 additions and 12 deletions

View file

@ -16,20 +16,29 @@ use gpui::{
platform::{WindowBounds, WindowOptions},
ModelHandle, ViewContext,
};
use lazy_static::lazy_static;
pub use lsp;
use project::Project;
pub use project::{self, fs};
use project_panel::ProjectPanel;
use std::sync::Arc;
use std::{path::PathBuf, sync::Arc};
pub use workspace;
use workspace::{AppState, Workspace, WorkspaceParams};
action!(About);
action!(Quit);
action!(OpenSettings);
action!(AdjustBufferFontSize, f32);
const MIN_FONT_SIZE: f32 = 6.0;
lazy_static! {
pub static ref ROOT_PATH: PathBuf = dirs::home_dir()
.expect("failed to determine home directory")
.join(".zed");
pub static ref SETTINGS_PATH: PathBuf = ROOT_PATH.join("settings.json");
}
pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
cx.add_global_action(quit);
cx.add_global_action({
@ -40,15 +49,21 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
settings_tx.borrow_mut().buffer_font_size = new_size;
}
});
cx.add_action(open_settings);
workspace::lsp_status::init(cx);
cx.add_bindings(vec![
Binding::new("cmd-=", AdjustBufferFontSize(1.), None),
Binding::new("cmd--", AdjustBufferFontSize(-1.), None),
Binding::new("cmd-,", OpenSettings, None),
])
}
fn open_settings(workspace: &mut Workspace, _: &OpenSettings, cx: &mut ViewContext<Workspace>) {
workspace.open_paths(&[SETTINGS_PATH.clone()], cx).detach();
}
pub fn build_workspace(
project: ModelHandle<Project>,
app_state: &Arc<AppState>,