Move assets to their own crate, load keymaps in vim tests

Also, move assets folder to the top-level.

Co-authored-by: Keith Simmons <keith@zed.dev>
This commit is contained in:
Max Brunsfeld 2022-04-11 15:54:52 -07:00
parent e0096ec1eb
commit c065f283aa
41 changed files with 109 additions and 69 deletions

View file

@ -1,4 +1,5 @@
use anyhow::{Context, Result};
use assets::Assets;
use collections::BTreeMap;
use gpui::{keymap::Binding, MutableAppContext};
use serde::Deserialize;
@ -9,6 +10,16 @@ struct ActionWithData<'a>(#[serde(borrow)] &'a str, #[serde(borrow)] &'a RawValu
type ActionSetsByContext<'a> = BTreeMap<&'a str, ActionsByKeystroke<'a>>;
type ActionsByKeystroke<'a> = BTreeMap<&'a str, &'a RawValue>;
pub fn load_built_in_keymaps(cx: &mut MutableAppContext) {
for path in ["keymaps/default.json", "keymaps/vim.json"] {
load_keymap(
cx,
std::str::from_utf8(Assets::get(path).unwrap().data.as_ref()).unwrap(),
)
.unwrap();
}
}
pub fn load_keymap(cx: &mut MutableAppContext, content: &str) -> Result<()> {
let actions: ActionSetsByContext = serde_json::from_str(content)?;
for (context, actions) in actions {