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:
parent
e0096ec1eb
commit
c065f283aa
41 changed files with 109 additions and 69 deletions
14
crates/assets/Cargo.toml
Normal file
14
crates/assets/Cargo.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "assets"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
path = "src/assets.rs"
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
gpui = { path = "../gpui" }
|
||||
anyhow = "1.0.38"
|
||||
rust-embed = { version = "6.3", features = ["include-exclude"] }
|
||||
|
20
crates/assets/src/assets.rs
Normal file
20
crates/assets/src/assets.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use gpui::AssetSource;
|
||||
use rust_embed::RustEmbed;
|
||||
|
||||
#[derive(RustEmbed)]
|
||||
#[folder = "../../assets"]
|
||||
#[exclude = "*.DS_Store"]
|
||||
pub struct Assets;
|
||||
|
||||
impl AssetSource for Assets {
|
||||
fn load(&self, path: &str) -> Result<std::borrow::Cow<[u8]>> {
|
||||
Self::get(path)
|
||||
.map(|f| f.data)
|
||||
.ok_or_else(|| anyhow!("could not find asset at path \"{}\"", path))
|
||||
}
|
||||
|
||||
fn list(&self, path: &str) -> Vec<std::borrow::Cow<'static, str>> {
|
||||
Self::iter().filter(|p| p.starts_with(path)).collect()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue