Use IndexMap for a deterministic order when importing syntax colors

This commit is contained in:
Marshall Bowers 2023-11-09 13:12:36 -05:00
parent 1f0fccc353
commit 978cff8095
15 changed files with 143 additions and 143 deletions

1
Cargo.lock generated
View file

@ -9134,6 +9134,7 @@ dependencies = [
"anyhow", "anyhow",
"convert_case 0.6.0", "convert_case 0.6.0",
"gpui2", "gpui2",
"indexmap 1.9.3",
"log", "log",
"rust-embed", "rust-embed",
"serde", "serde",

View file

@ -62,9 +62,9 @@ pub fn andromeda() -> UserThemeFamily {
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
( (
"punctuation".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x95e072ff).into()), color: Some(rgba(0x9fa0a6cc).into()),
..Default::default() ..Default::default()
}, },
), ),
@ -76,9 +76,9 @@ pub fn andromeda() -> UserThemeFamily {
}, },
), ),
( (
"comment".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x9fa0a6cc).into()), color: Some(rgba(0x95e072ff).into()),
..Default::default() ..Default::default()
}, },
), ),
@ -135,9 +135,9 @@ pub fn andromeda() -> UserThemeFamily {
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
( (
"punctuation".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x95e072ff).into()), color: Some(rgba(0x9fa0a6cc).into()),
..Default::default() ..Default::default()
}, },
), ),
@ -149,9 +149,9 @@ pub fn andromeda() -> UserThemeFamily {
}, },
), ),
( (
"comment".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x9fa0a6cc).into()), color: Some(rgba(0x95e072ff).into()),
..Default::default() ..Default::default()
}, },
), ),

View file

@ -66,16 +66,16 @@ pub fn ayu() -> UserThemeFamily {
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
( (
"something".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0xfa8d3eff).into()), color: Some(rgba(0x787b8099).into()),
..Default::default() ..Default::default()
}, },
), ),
( (
"comment".into(), "something".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x787b8099).into()), color: Some(rgba(0xfa8d3eff).into()),
..Default::default() ..Default::default()
}, },
), ),
@ -143,7 +143,7 @@ pub fn ayu() -> UserThemeFamily {
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
( (
"punctuation".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0xb8cfe680).into()), color: Some(rgba(0xb8cfe680).into()),
..Default::default() ..Default::default()
@ -157,7 +157,7 @@ pub fn ayu() -> UserThemeFamily {
}, },
), ),
( (
"comment".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0xb8cfe680).into()), color: Some(rgba(0xb8cfe680).into()),
..Default::default() ..Default::default()
@ -227,16 +227,16 @@ pub fn ayu() -> UserThemeFamily {
}, },
), ),
( (
"punctuation".into(), "something".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0xabb5be8c).into()), color: Some(rgba(0xff8f3fff).into()),
..Default::default() ..Default::default()
}, },
), ),
( (
"something".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0xff8f3fff).into()), color: Some(rgba(0xabb5be8c).into()),
..Default::default() ..Default::default()
}, },
), ),

View file

@ -74,16 +74,16 @@ pub fn dracula() -> UserThemeFamily {
}, },
), ),
( (
"punctuation".into(), "something".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0xff79c6ff).into()), color: Some(rgba(0xf8f8f2ff).into()),
..Default::default() ..Default::default()
}, },
), ),
( (
"something".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0xf8f8f2ff).into()), color: Some(rgba(0xff79c6ff).into()),
..Default::default() ..Default::default()
}, },
), ),

View file

@ -72,14 +72,14 @@ pub fn gruvbox() -> UserThemeFamily {
}, },
), ),
( (
"punctuation".into(), "something".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x83a598ff).into()), color: Some(rgba(0x83a598ff).into()),
..Default::default() ..Default::default()
}, },
), ),
( (
"something".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x83a598ff).into()), color: Some(rgba(0x83a598ff).into()),
..Default::default() ..Default::default()
@ -140,13 +140,6 @@ pub fn gruvbox() -> UserThemeFamily {
}, },
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
(
"punctuation".into(),
UserHighlightStyle {
color: Some(rgba(0x83a598ff).into()),
..Default::default()
},
),
( (
"comment".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
@ -161,6 +154,13 @@ pub fn gruvbox() -> UserThemeFamily {
..Default::default() ..Default::default()
}, },
), ),
(
"punctuation".into(),
UserHighlightStyle {
color: Some(rgba(0x83a598ff).into()),
..Default::default()
},
),
], ],
}), }),
}, },
@ -217,9 +217,9 @@ pub fn gruvbox() -> UserThemeFamily {
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
( (
"punctuation".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x83a598ff).into()), color: Some(rgba(0x928374ff).into()),
..Default::default() ..Default::default()
}, },
), ),
@ -231,9 +231,9 @@ pub fn gruvbox() -> UserThemeFamily {
}, },
), ),
( (
"comment".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x928374ff).into()), color: Some(rgba(0x83a598ff).into()),
..Default::default() ..Default::default()
}, },
), ),
@ -369,16 +369,16 @@ pub fn gruvbox() -> UserThemeFamily {
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
( (
"something".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x066578ff).into()), color: Some(rgba(0x928374ff).into()),
..Default::default() ..Default::default()
}, },
), ),
( (
"comment".into(), "something".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x928374ff).into()), color: Some(rgba(0x066578ff).into()),
..Default::default() ..Default::default()
}, },
), ),

View file

@ -65,13 +65,6 @@ pub fn night_owl() -> UserThemeFamily {
}, },
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
(
"punctuation".into(),
UserHighlightStyle {
color: Some(rgba(0xd3413dff).into()),
..Default::default()
},
),
( (
"comment".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
@ -86,6 +79,13 @@ pub fn night_owl() -> UserThemeFamily {
..Default::default() ..Default::default()
}, },
), ),
(
"punctuation".into(),
UserHighlightStyle {
color: Some(rgba(0xd3413dff).into()),
..Default::default()
},
),
], ],
}), }),
}, },
@ -144,16 +144,16 @@ pub fn night_owl() -> UserThemeFamily {
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
( (
"something".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x0b969bff).into()), color: Some(rgba(0x989fb1ff).into()),
..Default::default() ..Default::default()
}, },
), ),
( (
"comment".into(), "something".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x989fb1ff).into()), color: Some(rgba(0x0b969bff).into()),
..Default::default() ..Default::default()
}, },
), ),

View file

@ -66,13 +66,6 @@ pub fn nord() -> UserThemeFamily {
}, },
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
(
"something".into(),
UserHighlightStyle {
color: Some(rgba(0xa3be8cff).into()),
..Default::default()
},
),
( (
"comment".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
@ -87,6 +80,13 @@ pub fn nord() -> UserThemeFamily {
..Default::default() ..Default::default()
}, },
), ),
(
"something".into(),
UserHighlightStyle {
color: Some(rgba(0xa3be8cff).into()),
..Default::default()
},
),
], ],
}), }),
}, },

View file

@ -67,6 +67,13 @@ pub fn notctis() -> UserThemeFamily {
}, },
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
(
"comment".into(),
UserHighlightStyle {
color: Some(rgba(0x5888a5ff).into()),
..Default::default()
},
),
( (
"punctuation".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
@ -81,13 +88,6 @@ pub fn notctis() -> UserThemeFamily {
..Default::default() ..Default::default()
}, },
), ),
(
"comment".into(),
UserHighlightStyle {
color: Some(rgba(0x5888a5ff).into()),
..Default::default()
},
),
], ],
}), }),
}, },
@ -154,16 +154,16 @@ pub fn notctis() -> UserThemeFamily {
}, },
), ),
( (
"something".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x49e9a6ff).into()), color: Some(rgba(0x49ace9ff).into()),
..Default::default() ..Default::default()
}, },
), ),
( (
"punctuation".into(), "something".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x49ace9ff).into()), color: Some(rgba(0x49e9a6ff).into()),
..Default::default() ..Default::default()
}, },
), ),
@ -225,13 +225,6 @@ pub fn notctis() -> UserThemeFamily {
}, },
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
(
"something".into(),
UserHighlightStyle {
color: Some(rgba(0x00b368ff).into()),
..Default::default()
},
),
( (
"comment".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
@ -246,6 +239,13 @@ pub fn notctis() -> UserThemeFamily {
..Default::default() ..Default::default()
}, },
), ),
(
"something".into(),
UserHighlightStyle {
color: Some(rgba(0x00b368ff).into()),
..Default::default()
},
),
], ],
}), }),
}, },
@ -304,13 +304,6 @@ pub fn notctis() -> UserThemeFamily {
}, },
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
(
"something".into(),
UserHighlightStyle {
color: Some(rgba(0x00b368ff).into()),
..Default::default()
},
),
( (
"comment".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
@ -325,6 +318,13 @@ pub fn notctis() -> UserThemeFamily {
..Default::default() ..Default::default()
}, },
), ),
(
"something".into(),
UserHighlightStyle {
color: Some(rgba(0x00b368ff).into()),
..Default::default()
},
),
], ],
}), }),
}, },
@ -384,16 +384,16 @@ pub fn notctis() -> UserThemeFamily {
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
( (
"punctuation".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x0094f0ff).into()), color: Some(rgba(0x8ca6a6ff).into()),
..Default::default() ..Default::default()
}, },
), ),
( (
"comment".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x8ca6a6ff).into()), color: Some(rgba(0x0094f0ff).into()),
..Default::default() ..Default::default()
}, },
), ),
@ -462,13 +462,6 @@ pub fn notctis() -> UserThemeFamily {
}, },
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
(
"something".into(),
UserHighlightStyle {
color: Some(rgba(0x72c09fff).into()),
..Default::default()
},
),
( (
"comment".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
@ -483,6 +476,13 @@ pub fn notctis() -> UserThemeFamily {
..Default::default() ..Default::default()
}, },
), ),
(
"something".into(),
UserHighlightStyle {
color: Some(rgba(0x72c09fff).into()),
..Default::default()
},
),
], ],
}), }),
}, },
@ -541,13 +541,6 @@ pub fn notctis() -> UserThemeFamily {
}, },
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
(
"something".into(),
UserHighlightStyle {
color: Some(rgba(0x49e9a6ff).into()),
..Default::default()
},
),
( (
"comment".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
@ -562,6 +555,13 @@ pub fn notctis() -> UserThemeFamily {
..Default::default() ..Default::default()
}, },
), ),
(
"something".into(),
UserHighlightStyle {
color: Some(rgba(0x49e9a6ff).into()),
..Default::default()
},
),
], ],
}), }),
}, },
@ -707,16 +707,16 @@ pub fn notctis() -> UserThemeFamily {
}, },
), ),
( (
"something".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x49e9a6ff).into()), color: Some(rgba(0x49ace9ff).into()),
..Default::default() ..Default::default()
}, },
), ),
( (
"punctuation".into(), "something".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x49ace9ff).into()), color: Some(rgba(0x49e9a6ff).into()),
..Default::default() ..Default::default()
}, },
), ),
@ -779,9 +779,9 @@ pub fn notctis() -> UserThemeFamily {
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
( (
"something".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x49e9a6ff).into()), color: Some(rgba(0x716b93ff).into()),
..Default::default() ..Default::default()
}, },
), ),
@ -793,9 +793,9 @@ pub fn notctis() -> UserThemeFamily {
}, },
), ),
( (
"comment".into(), "something".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x716b93ff).into()), color: Some(rgba(0x49e9a6ff).into()),
..Default::default() ..Default::default()
}, },
), ),
@ -865,16 +865,16 @@ pub fn notctis() -> UserThemeFamily {
}, },
), ),
( (
"something".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x49e9a6ff).into()), color: Some(rgba(0x49ace9ff).into()),
..Default::default() ..Default::default()
}, },
), ),
( (
"punctuation".into(), "something".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x49ace9ff).into()), color: Some(rgba(0x49e9a6ff).into()),
..Default::default() ..Default::default()
}, },
), ),

View file

@ -143,16 +143,16 @@ pub fn palenight() -> UserThemeFamily {
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
( (
"something".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x7fcac3ff).into()), color: Some(rgba(0x687097ff).into()),
..Default::default() ..Default::default()
}, },
), ),
( (
"comment".into(), "something".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x687097ff).into()), color: Some(rgba(0x7fcac3ff).into()),
..Default::default() ..Default::default()
}, },
), ),

View file

@ -230,16 +230,16 @@ pub fn rose_pine() -> UserThemeFamily {
}, },
), ),
( (
"punctuation".into(), "something".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x9893a5ff).into()), color: Some(rgba(0xd7827dff).into()),
..Default::default() ..Default::default()
}, },
), ),
( (
"something".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0xd7827dff).into()), color: Some(rgba(0x9893a5ff).into()),
..Default::default() ..Default::default()
}, },
), ),

View file

@ -61,13 +61,6 @@ pub fn solarized() -> UserThemeFamily {
}, },
syntax: Some(UserSyntaxTheme { syntax: Some(UserSyntaxTheme {
highlights: vec![ highlights: vec![
(
"punctuation".into(),
UserHighlightStyle {
color: Some(rgba(0x657b83ff).into()),
..Default::default()
},
),
( (
"comment".into(), "comment".into(),
UserHighlightStyle { UserHighlightStyle {
@ -82,6 +75,13 @@ pub fn solarized() -> UserThemeFamily {
..Default::default() ..Default::default()
}, },
), ),
(
"punctuation".into(),
UserHighlightStyle {
color: Some(rgba(0x657b83ff).into()),
..Default::default()
},
),
], ],
}), }),
}, },
@ -139,16 +139,16 @@ pub fn solarized() -> UserThemeFamily {
}, },
), ),
( (
"punctuation".into(), "something".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x93a1a1ff).into()), color: Some(rgba(0x657b83ff).into()),
..Default::default() ..Default::default()
}, },
), ),
( (
"something".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0x657b83ff).into()), color: Some(rgba(0x93a1a1ff).into()),
..Default::default() ..Default::default()
}, },
), ),

View file

@ -59,16 +59,16 @@ pub fn synthwave_84() -> UserThemeFamily {
}, },
), ),
( (
"punctuation".into(), "something".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0xfede5cff).into()), color: Some(rgba(0xfe444fff).into()),
..Default::default() ..Default::default()
}, },
), ),
( (
"something".into(), "punctuation".into(),
UserHighlightStyle { UserHighlightStyle {
color: Some(rgba(0xfe444fff).into()), color: Some(rgba(0xfede5cff).into()),
..Default::default() ..Default::default()
}, },
), ),

View file

@ -10,6 +10,7 @@ publish = false
anyhow.workspace = true anyhow.workspace = true
convert_case = "0.6.0" convert_case = "0.6.0"
gpui = { package = "gpui2", path = "../gpui2" } gpui = { package = "gpui2", path = "../gpui2" }
indexmap = "1.6.2"
log.workspace = true log.workspace = true
rust-embed.workspace = true rust-embed.workspace = true
serde.workspace = true serde.workspace = true

View file

@ -1,7 +1,6 @@
use std::collections::HashMap;
use anyhow::Result; use anyhow::Result;
use gpui::{Hsla, Rgba}; use gpui::{Hsla, Rgba};
use indexmap::IndexMap;
use theme::{ use theme::{
StatusColorsRefinement, ThemeColorsRefinement, UserSyntaxTheme, UserTheme, StatusColorsRefinement, ThemeColorsRefinement, UserSyntaxTheme, UserTheme,
UserThemeStylesRefinement, UserThemeStylesRefinement,
@ -34,7 +33,7 @@ impl VsCodeThemeConverter {
let status_color_refinements = self.convert_status_colors()?; let status_color_refinements = self.convert_status_colors()?;
let theme_colors_refinements = self.convert_theme_colors()?; let theme_colors_refinements = self.convert_theme_colors()?;
let mut highlight_styles = HashMap::new(); let mut highlight_styles = IndexMap::new();
for token_color in self.theme.token_colors { for token_color in self.theme.token_colors {
highlight_styles.extend(token_color.highlight_styles()?); highlight_styles.extend(token_color.highlight_styles()?);

View file

@ -2,9 +2,8 @@
// Map tokenColors style to HighlightStyle (fontStyle, foreground, background) // Map tokenColors style to HighlightStyle (fontStyle, foreground, background)
// Take in the scopes from the tokenColors and try to match each to our HighlightStyles // Take in the scopes from the tokenColors and try to match each to our HighlightStyles
use std::collections::HashMap;
use anyhow::Result; use anyhow::Result;
use indexmap::IndexMap;
use serde::Deserialize; use serde::Deserialize;
use theme::UserHighlightStyle; use theme::UserHighlightStyle;
@ -33,13 +32,13 @@ pub struct VsCodeTokenColorSettings {
} }
impl VsCodeTokenColor { impl VsCodeTokenColor {
pub fn highlight_styles(&self) -> Result<HashMap<String, UserHighlightStyle>> { pub fn highlight_styles(&self) -> Result<IndexMap<String, UserHighlightStyle>> {
let mut highlight_styles = HashMap::new(); let mut highlight_styles = IndexMap::new();
let scope = match self.scope { let scope = match self.scope {
Some(VsCodeTokenScope::One(ref scope)) => vec![scope.clone()], Some(VsCodeTokenScope::One(ref scope)) => vec![scope.clone()],
Some(VsCodeTokenScope::Many(ref scopes)) => scopes.clone(), Some(VsCodeTokenScope::Many(ref scopes)) => scopes.clone(),
None => return Ok(HashMap::new()), None => return Ok(IndexMap::new()),
}; };
for scope in &scope { for scope in &scope {