use std::str::FromStr;
use syntect::highlighting::{
Color, ScopeSelectors, StyleModifier, Theme, ThemeItem, ThemeSettings,
};
pub fn branchdiff_theme() -> Theme {
Theme {
name: Some("branchdiff".to_string()),
author: None,
settings: ThemeSettings {
foreground: Some(Color {
r: 200,
g: 200,
b: 200,
a: 255,
}),
background: None, ..Default::default()
},
scopes: vec![
theme_item("keyword", 180, 140, 200),
theme_item("storage.type", 180, 140, 200),
theme_item("storage.modifier", 180, 140, 200),
theme_item("string", 220, 180, 140),
theme_item("comment", 128, 128, 140),
theme_item("constant.numeric", 140, 200, 220),
theme_item("constant.language", 140, 200, 220),
theme_item("entity.name.type", 140, 200, 180),
theme_item("entity.name.class", 140, 200, 180),
theme_item("support.type", 140, 200, 180),
theme_item("entity.name.struct", 140, 200, 180),
theme_item("entity.name.enum", 140, 200, 180),
theme_item("entity.name.trait", 140, 200, 180),
theme_item("entity.name.function", 220, 200, 140),
theme_item("support.function", 220, 200, 140),
theme_item("entity.name.method", 220, 200, 140),
theme_item("entity.name.macro", 230, 210, 150),
theme_item("variable.parameter", 190, 190, 200),
theme_item("punctuation", 180, 180, 180),
],
}
}
fn theme_item(scope: &str, r: u8, g: u8, b: u8) -> ThemeItem {
let scope_selectors = ScopeSelectors::from_str(scope)
.expect("hardcoded scope selector should be valid");
ThemeItem {
scope: scope_selectors,
style: StyleModifier {
foreground: Some(Color { r, g, b, a: 255 }),
..Default::default()
},
}
}