@@ -14,19 +14,14 @@ use toml::{map::Map, Value};
1414use crate::graphics::UnderlineStyle;
1515pub use crate::graphics::{Color, Modifier, Style};
1616
17−pub static DEFAULT_THEME: Lazy<Theme> = Lazy::new(|| {
18− // let raw_theme: Value = toml::from_slice(include_bytes!("../../theme.toml"))
19− // .expect("Failed to parse default theme");
20− // Theme::from(raw_theme)
21−
22− toml::from_slice(include_bytes!("../../theme.toml")).expect("Failed to parse default theme")
17+pub static DEFAULT_THEME: Lazy<Theme> = Lazy::new(|| Theme {
18+ name: "default".into(),
19+ ..toml::from_slice(include_bytes!("../../theme.toml")).expect("Failed to parse default theme")
2320});
24−pub static BASE16_DEFAULT_THEME: Lazy<Theme> = Lazy::new(|| {
25− // let raw_theme: Value = toml::from_slice(include_bytes!("../../base16_theme.toml"))
26− // .expect("Failed to parse base 16 default theme");
27− // Theme::from(raw_theme)
2821
29− toml::from_slice(include_bytes!("../../base16_theme.toml"))
22+pub static BASE16_DEFAULT_THEME: Lazy<Theme> = Lazy::new(|| Theme {
23+ name: "base16_theme".into(),
24+ ..toml::from_slice(include_bytes!("../../base16_theme.toml"))
3025 .expect("Failed to parse base 16 default theme")
3126});
3227
@@ -53,7 +48,12 @@ impl Loader {
5348 return Ok(self.base16_default());
5449 }
5550
56− self.load_theme(name, name, false).map(Theme::from)
51+ let theme = self.load_theme(name, name, false).map(Theme::from)?;
52+
53+ Ok(Theme {
54+ name: name.into(),
55+ ..theme
56+ })
5757 }
5858
5959 // load the theme and its parent recursively and merge them
@@ -180,8 +180,10 @@ impl Loader {
180180 }
181181}
182182
183−#[derive(Clone, Debug)]
183+#[derive(Clone, Debug, Default)]
184184pub struct Theme {
185+ name: String,
186+
185187 // UI styles are stored in a HashMap
186188 styles: HashMap<String, Style>,
187189 // tree-sitter highlight styles are stored in a Vec to optimize lookups
@@ -200,6 +202,7 @@ impl From<Value> for Theme {
200202 styles,
201203 scopes,
202204 highlights,
205+ ..Default::default()
203206 }
204207 }
205208}
@@ -217,6 +220,7 @@ impl<'de> Deserialize<'de> for Theme {
217220 styles,
218221 scopes,
219222 highlights,
223+ ..Default::default()
220224 })
221225 }
222226}
@@ -266,6 +270,10 @@ impl Theme {
266270 self.highlights[index]
267271 }
268272
273+ pub fn name(&self) -> &str {
274+ &self.name
275+ }
276+
269277 pub fn get(&self, scope: &str) -> Style {
270278 self.try_get(scope).unwrap_or_default()
271279 }