Represent theme's syntax colors with string keys
Co-authored-by: Marshall Bowers <marshall@zed.dev>
This commit is contained in:
co-authored by
Marshall Bowers
parent
a569c82492
commit
0eae962abf
@@ -90,13 +90,22 @@ pub struct Theme {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SyntaxTheme {
|
||||
pub comment: Hsla,
|
||||
pub string: Hsla,
|
||||
pub function: Hsla,
|
||||
pub keyword: Hsla,
|
||||
pub highlights: Vec<(String, HighlightStyle)>,
|
||||
}
|
||||
|
||||
impl SyntaxTheme {
|
||||
pub fn get(&self, name: &str) -> HighlightStyle {
|
||||
self.highlights
|
||||
.iter()
|
||||
.find_map(|entry| if entry.0 == name { Some(entry.1) } else { None })
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn color(&self, name: &str) -> Hsla {
|
||||
self.get(name).color.unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct PlayerTheme {
|
||||
pub cursor: Hsla,
|
||||
|
||||
@@ -36,11 +36,31 @@ pub fn one_dark() -> Theme {
|
||||
text_accent: rgba(0x74ade8ff).into(),
|
||||
icon_muted: rgba(0x838994ff).into(),
|
||||
syntax: SyntaxTheme {
|
||||
comment: rgba(0x5d636fff).into(),
|
||||
string: rgba(0xa1c181ff).into(),
|
||||
function: rgba(0x73ade9ff).into(),
|
||||
keyword: rgba(0xb477cfff).into(),
|
||||
highlights: vec![],
|
||||
highlights: vec![
|
||||
("link_text".into(), rgba(0x73ade9ff).into()),
|
||||
("punctuation.special".into(), rgba(0xb1574bff).into()),
|
||||
("enum".into(), rgba(0xd07277ff).into()),
|
||||
("text.literal".into(), rgba(0xa1c181ff).into()),
|
||||
("string".into(), rgba(0xa1c181ff).into()),
|
||||
("operator".into(), rgba(0x6eb4bfff).into()),
|
||||
("constructor".into(), rgba(0x73ade9ff).into()),
|
||||
("emphasis.strong".into(), rgba(0xbf956aff).into()),
|
||||
("comment".into(), rgba(0x5d636fff).into()),
|
||||
("function".into(), rgba(0x73ade9ff).into()),
|
||||
("number".into(), rgba(0xbf956aff).into()),
|
||||
("property".into(), rgba(0xd07277ff).into()),
|
||||
("variable.special".into(), rgba(0xbf956aff).into()),
|
||||
("primary".into(), rgba(0xacb2beff).into()),
|
||||
("punctuation.list_marker".into(), rgba(0xd07277ff).into()),
|
||||
("punctuation".into(), rgba(0xacb2beff).into()),
|
||||
("type".into(), rgba(0x6eb4bfff).into()),
|
||||
("variant".into(), rgba(0x73ade9ff).into()),
|
||||
("constant".into(), rgba(0xdfc184ff).into()),
|
||||
("title".into(), rgba(0xd07277ff).into()),
|
||||
("boolean".into(), rgba(0xbf956aff).into()),
|
||||
("keyword".into(), rgba(0xb477cfff).into()),
|
||||
("link_uri".into(), rgba(0x6eb4bfff).into()),
|
||||
],
|
||||
},
|
||||
status_bar: rgba(0x3b414dff).into(),
|
||||
title_bar: rgba(0x3b414dff).into(),
|
||||
|
||||
@@ -36,11 +36,23 @@ pub fn rose_pine() -> Theme {
|
||||
text_accent: rgba(0x9bced6ff).into(),
|
||||
icon_muted: rgba(0x74708dff).into(),
|
||||
syntax: SyntaxTheme {
|
||||
comment: rgba(0x6e6a86ff).into(),
|
||||
string: rgba(0xf5c177ff).into(),
|
||||
function: rgba(0xebbcbaff).into(),
|
||||
keyword: rgba(0x30738fff).into(),
|
||||
highlights: vec![],
|
||||
highlights: vec![
|
||||
("variable".into(), rgba(0xe0def4ff).into()),
|
||||
("function.method".into(), rgba(0xebbcbaff).into()),
|
||||
("title".into(), rgba(0xf5c177ff).into()),
|
||||
("type.builtin".into(), rgba(0x9ccfd8ff).into()),
|
||||
("type".into(), rgba(0x9ccfd8ff).into()),
|
||||
("tag".into(), rgba(0x9ccfd8ff).into()),
|
||||
("operator".into(), rgba(0x30738fff).into()),
|
||||
("string".into(), rgba(0xf5c177ff).into()),
|
||||
("function".into(), rgba(0xebbcbaff).into()),
|
||||
("comment".into(), rgba(0x6e6a86ff).into()),
|
||||
("keyword".into(), rgba(0x30738fff).into()),
|
||||
("boolean".into(), rgba(0xebbcbaff).into()),
|
||||
("punctuation".into(), rgba(0x908caaff).into()),
|
||||
("link_text".into(), rgba(0x9ccfd8ff).into()),
|
||||
("link_uri".into(), rgba(0xebbcbaff).into()),
|
||||
],
|
||||
},
|
||||
status_bar: rgba(0x292738ff).into(),
|
||||
title_bar: rgba(0x292738ff).into(),
|
||||
@@ -128,11 +140,23 @@ pub fn rose_pine_dawn() -> Theme {
|
||||
text_accent: rgba(0x57949fff).into(),
|
||||
icon_muted: rgba(0x706c8cff).into(),
|
||||
syntax: SyntaxTheme {
|
||||
comment: rgba(0x9893a5ff).into(),
|
||||
string: rgba(0xea9d34ff).into(),
|
||||
function: rgba(0xd7827dff).into(),
|
||||
keyword: rgba(0x276983ff).into(),
|
||||
highlights: Vec::new(),
|
||||
highlights: vec![
|
||||
("link_text".into(), rgba(0x55949fff).into()),
|
||||
("punctuation".into(), rgba(0x797593ff).into()),
|
||||
("string".into(), rgba(0xea9d34ff).into()),
|
||||
("variable".into(), rgba(0x575279ff).into()),
|
||||
("type".into(), rgba(0x55949fff).into()),
|
||||
("comment".into(), rgba(0x9893a5ff).into()),
|
||||
("boolean".into(), rgba(0xd7827dff).into()),
|
||||
("function.method".into(), rgba(0xd7827dff).into()),
|
||||
("operator".into(), rgba(0x276983ff).into()),
|
||||
("function".into(), rgba(0xd7827dff).into()),
|
||||
("keyword".into(), rgba(0x276983ff).into()),
|
||||
("type.builtin".into(), rgba(0x55949fff).into()),
|
||||
("tag".into(), rgba(0x55949fff).into()),
|
||||
("title".into(), rgba(0xea9d34ff).into()),
|
||||
("link_uri".into(), rgba(0xd7827dff).into()),
|
||||
],
|
||||
},
|
||||
status_bar: rgba(0xdcd8d8ff).into(),
|
||||
title_bar: rgba(0xdcd8d8ff).into(),
|
||||
@@ -220,11 +244,23 @@ pub fn rose_pine_moon() -> Theme {
|
||||
text_accent: rgba(0x9bced6ff).into(),
|
||||
icon_muted: rgba(0x85819eff).into(),
|
||||
syntax: SyntaxTheme {
|
||||
comment: rgba(0x6e6a86ff).into(),
|
||||
string: rgba(0xf5c177ff).into(),
|
||||
function: rgba(0xea9a97ff).into(),
|
||||
keyword: rgba(0x3d8fb0ff).into(),
|
||||
highlights: Vec::new(),
|
||||
highlights: vec![
|
||||
("keyword".into(), rgba(0x3d8fb0ff).into()),
|
||||
("boolean".into(), rgba(0xea9a97ff).into()),
|
||||
("function".into(), rgba(0xea9a97ff).into()),
|
||||
("comment".into(), rgba(0x6e6a86ff).into()),
|
||||
("title".into(), rgba(0xf5c177ff).into()),
|
||||
("link_text".into(), rgba(0x9ccfd8ff).into()),
|
||||
("type".into(), rgba(0x9ccfd8ff).into()),
|
||||
("type.builtin".into(), rgba(0x9ccfd8ff).into()),
|
||||
("punctuation".into(), rgba(0x908caaff).into()),
|
||||
("function.method".into(), rgba(0xea9a97ff).into()),
|
||||
("tag".into(), rgba(0x9ccfd8ff).into()),
|
||||
("variable".into(), rgba(0xe0def4ff).into()),
|
||||
("operator".into(), rgba(0x3d8fb0ff).into()),
|
||||
("string".into(), rgba(0xf5c177ff).into()),
|
||||
("link_uri".into(), rgba(0xea9a97ff).into()),
|
||||
],
|
||||
},
|
||||
status_bar: rgba(0x38354eff).into(),
|
||||
title_bar: rgba(0x38354eff).into(),
|
||||
|
||||
@@ -35,13 +35,7 @@ pub fn sandcastle() -> Theme {
|
||||
text_disabled: rgba(0x827568ff).into(),
|
||||
text_accent: rgba(0x518b8bff).into(),
|
||||
icon_muted: rgba(0xa69782ff).into(),
|
||||
syntax: SyntaxTheme {
|
||||
comment: rgba(0xff00ffff).into(),
|
||||
string: rgba(0xff00ffff).into(),
|
||||
function: rgba(0xff00ffff).into(),
|
||||
keyword: rgba(0xff00ffff).into(),
|
||||
highlights: vec![],
|
||||
},
|
||||
syntax: SyntaxTheme { highlights: vec![] },
|
||||
status_bar: rgba(0x333944ff).into(),
|
||||
title_bar: rgba(0x333944ff).into(),
|
||||
toolbar: rgba(0x282c33ff).into(),
|
||||
|
||||
Reference in New Issue
Block a user