Use the word 'keymap' more consistently

Co-authored-by: Keith Simmons <keith@zed.dev>
This commit is contained in:
Max Brunsfeld 2022-04-11 17:02:16 -07:00
parent be11f63f1e
commit ee3eb9658f
6 changed files with 15 additions and 17 deletions

View File

@ -7,14 +7,14 @@ use serde_json::value::RawValue;
#[derive(Deserialize, Default, Clone)]
#[serde(transparent)]
pub struct KeyMapFile(BTreeMap<String, ActionsByKeystroke>);
pub struct KeymapFile(BTreeMap<String, ActionsByKeystroke>);
type ActionsByKeystroke = BTreeMap<String, Box<RawValue>>;
#[derive(Deserialize)]
struct ActionWithData<'a>(#[serde(borrow)] &'a str, #[serde(borrow)] &'a RawValue);
impl KeyMapFile {
impl KeymapFile {
pub fn load_defaults(cx: &mut MutableAppContext) {
for path in ["keymaps/default.json", "keymaps/vim.json"] {
Self::load(path, cx).unwrap();

View File

@ -15,7 +15,7 @@ use std::{collections::HashMap, sync::Arc};
use theme::{Theme, ThemeRegistry};
use util::ResultExt as _;
pub use keymap_file::KeyMapFile;
pub use keymap_file::KeymapFile;
#[derive(Clone)]
pub struct Settings {

View File

@ -24,7 +24,7 @@ impl<'a> VimTestContext<'a> {
editor::init(cx);
crate::init(cx);
settings::KeyMapFile::load("keymaps/vim.json", cx).unwrap();
settings::KeymapFile::load("keymaps/vim.json", cx).unwrap();
});
let params = cx.update(WorkspaceParams::test);

View File

@ -10,7 +10,7 @@ use gpui::{App, AssetSource, Task};
use log::LevelFilter;
use parking_lot::Mutex;
use project::Fs;
use settings::{self, KeyMapFile, Settings, SettingsFileContent};
use settings::{self, KeymapFile, Settings, SettingsFileContent};
use smol::process::Command;
use std::{env, fs, path::PathBuf, sync::Arc};
use theme::{ThemeRegistry, DEFAULT_THEME_NAME};
@ -112,7 +112,7 @@ fn main() {
})
.detach_and_log_err(cx);
let (settings_file, bindings_file) = cx.background().block(config_files).unwrap();
let (settings_file, keymap_file) = cx.background().block(config_files).unwrap();
let mut settings_rx = settings_from_files(
default_settings,
vec![settings_file],
@ -120,7 +120,7 @@ fn main() {
cx.font_cache().clone(),
);
cx.spawn(|cx| watch_keymap_file(bindings_file, cx)).detach();
cx.spawn(|cx| watch_keymap_file(keymap_file, cx)).detach();
let settings = cx.background().block(settings_rx.next()).unwrap();
cx.spawn(|mut cx| async move {
@ -262,7 +262,7 @@ fn load_config_files(
fs: Arc<dyn Fs>,
) -> oneshot::Receiver<(
WatchedJsonFile<SettingsFileContent>,
WatchedJsonFile<KeyMapFile>,
WatchedJsonFile<KeymapFile>,
)> {
let executor = app.background();
let (tx, rx) = oneshot::channel();
@ -271,9 +271,8 @@ fn load_config_files(
.spawn(async move {
let settings_file =
WatchedJsonFile::new(fs.clone(), &executor, zed::SETTINGS_PATH.clone()).await;
let bindings_file =
WatchedJsonFile::new(fs, &executor, zed::BINDINGS_PATH.clone()).await;
tx.send((settings_file, bindings_file)).ok()
let keymap_file = WatchedJsonFile::new(fs, &executor, zed::KEYMAP_PATH.clone()).await;
tx.send((settings_file, keymap_file)).ok()
})
.detach();
rx

View File

@ -4,8 +4,7 @@ use postage::sink::Sink as _;
use postage::{prelude::Stream, watch};
use project::Fs;
use serde::Deserialize;
use settings::KeyMapFile;
use settings::{Settings, SettingsFileContent};
use settings::{KeymapFile, Settings, SettingsFileContent};
use std::{path::Path, sync::Arc, time::Duration};
use theme::ThemeRegistry;
use util::ResultExt;
@ -77,11 +76,11 @@ pub fn settings_from_files(
})
}
pub async fn watch_keymap_file(mut file: WatchedJsonFile<KeyMapFile>, mut cx: AsyncAppContext) {
pub async fn watch_keymap_file(mut file: WatchedJsonFile<KeymapFile>, mut cx: AsyncAppContext) {
while let Some(content) = file.0.recv().await {
cx.update(|cx| {
cx.clear_bindings();
settings::KeyMapFile::load_defaults(cx);
settings::KeymapFile::load_defaults(cx);
content.add(cx).log_err();
});
}

View File

@ -45,7 +45,7 @@ lazy_static! {
.expect("failed to determine home directory")
.join(".zed");
pub static ref SETTINGS_PATH: PathBuf = ROOT_PATH.join("settings.json");
pub static ref BINDINGS_PATH: PathBuf = ROOT_PATH.join("bindings.json");
pub static ref KEYMAP_PATH: PathBuf = ROOT_PATH.join("keymap.json");
}
pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
@ -103,7 +103,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
workspace::lsp_status::init(cx);
settings::KeyMapFile::load_defaults(cx);
settings::KeymapFile::load_defaults(cx);
}
pub fn build_workspace(