Unnamed repository; edit this file 'description' to name the repository.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use helix_view::theme::Loader;

use crate::{path, DynError};

pub fn theme_check() -> Result<(), DynError> {
    let theme_names = [
        vec!["default".to_string(), "base16_default".to_string()],
        Loader::read_names(&path::themes()),
    ]
    .concat();
    let loader = Loader::new(&[path::runtime()]);
    let mut errors_present = false;

    for name in theme_names {
        let (_, warnings) = loader.load_with_warnings(&name).unwrap();

        if !warnings.is_empty() {
            errors_present = true;
            println!("Theme '{name}' loaded with errors:");
            for warning in warnings {
                println!("\t* {}", warning);
            }
        }
    }

    match errors_present {
        true => Err("Errors found when loading bundled themes".into()),
        false => {
            println!("Theme check successful!");
            Ok(())
        }
    }
}