Use cosmic theme background when using cosmic syntax theme

This commit is contained in:
Jeremy Soller 2024-01-31 15:26:31 -07:00
parent 2e5cedbb03
commit 10da8f36db
No known key found for this signature in database
GPG key ID: D02FD439211AF56F

View file

@ -84,13 +84,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
SYNTAX_SYSTEM.get_or_init(|| { SYNTAX_SYSTEM.get_or_init(|| {
let lazy_theme_set = two_face::theme::LazyThemeSet::from(two_face::theme::extra()); let lazy_theme_set = two_face::theme::LazyThemeSet::from(two_face::theme::extra());
let mut theme_set = syntect::highlighting::ThemeSet::from(&lazy_theme_set); let mut theme_set = syntect::highlighting::ThemeSet::from(&lazy_theme_set);
// Hardcoded COSMIC themes
for (theme_name, theme_data) in &[ for (theme_name, theme_data) in &[
("COSMIC Dark", cosmic_syntax_theme::COSMIC_DARK_TM_THEME), ("COSMIC Dark", cosmic_syntax_theme::COSMIC_DARK_TM_THEME),
("COSMIC Light", cosmic_syntax_theme::COSMIC_LIGHT_TM_THEME), ("COSMIC Light", cosmic_syntax_theme::COSMIC_LIGHT_TM_THEME),
] { ] {
let mut cursor = io::Cursor::new(theme_data); let mut cursor = io::Cursor::new(theme_data);
match syntect::highlighting::ThemeSet::load_from_reader(&mut cursor) { match syntect::highlighting::ThemeSet::load_from_reader(&mut cursor) {
Ok(theme) => { Ok(mut theme) => {
// Use cosmic theme background
theme.settings.background = Some(syntect::highlighting::Color {
r: 0, g: 0, b: 0, a: 0
});
theme_set.themes.insert(theme_name.to_string(), theme); theme_set.themes.insert(theme_name.to_string(), theme);
} }
Err(err) => { Err(err) => {