theme_importer: Improve syntax token matching (#3549)

This PR improves the approach we use to match syntax tokens between Zed
and VS Code in the `theme_importer`.

We now use the list of scopes assigned to each Zed syntax token to rank
the possible candidates in the VS Code and then pick the candidate with
the highest rank.

So far this has proved to provide better colors across the board, but
we'll continue to refine the matching over time.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2023-12-07 22:11:31 -05:00 committed by GitHub
parent 89f62a1a69
commit f272881a6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 520 additions and 405 deletions

View file

@ -89,6 +89,14 @@ pub fn ayu() -> UserThemeFamily {
..Default::default()
},
),
(
"comment.doc".into(),
UserHighlightStyle {
color: Some(rgba(0x787b8099).into()),
font_style: Some(UserFontStyle::Italic),
..Default::default()
},
),
(
"constant".into(),
UserHighlightStyle {
@ -122,14 +130,14 @@ pub fn ayu() -> UserThemeFamily {
(
"function".into(),
UserHighlightStyle {
color: Some(rgba(0xf2ae49ff).into()),
color: Some(rgba(0xf07171ff).into()),
..Default::default()
},
),
(
"keyword".into(),
UserHighlightStyle {
color: Some(rgba(0xfa8d3eff).into()),
color: Some(rgba(0x55b4d4ff).into()),
..Default::default()
},
),
@ -171,7 +179,7 @@ pub fn ayu() -> UserThemeFamily {
(
"property".into(),
UserHighlightStyle {
color: Some(rgba(0xf07171ff).into()),
color: Some(rgba(0x55b4d4ff).into()),
..Default::default()
},
),
@ -269,7 +277,7 @@ pub fn ayu() -> UserThemeFamily {
(
"variable.special".into(),
UserHighlightStyle {
color: Some(rgba(0xf07171ff).into()),
color: Some(rgba(0xf2ae49ff).into()),
..Default::default()
},
),
@ -352,6 +360,14 @@ pub fn ayu() -> UserThemeFamily {
..Default::default()
},
),
(
"comment.doc".into(),
UserHighlightStyle {
color: Some(rgba(0xb8cfe680).into()),
font_style: Some(UserFontStyle::Italic),
..Default::default()
},
),
(
"constant".into(),
UserHighlightStyle {
@ -385,14 +401,14 @@ pub fn ayu() -> UserThemeFamily {
(
"function".into(),
UserHighlightStyle {
color: Some(rgba(0xffd173ff).into()),
color: Some(rgba(0xf28779ff).into()),
..Default::default()
},
),
(
"keyword".into(),
UserHighlightStyle {
color: Some(rgba(0xffad66ff).into()),
color: Some(rgba(0x5ccfe6ff).into()),
..Default::default()
},
),
@ -434,7 +450,7 @@ pub fn ayu() -> UserThemeFamily {
(
"property".into(),
UserHighlightStyle {
color: Some(rgba(0xf28779ff).into()),
color: Some(rgba(0x5ccfe6ff).into()),
..Default::default()
},
),
@ -532,7 +548,7 @@ pub fn ayu() -> UserThemeFamily {
(
"variable.special".into(),
UserHighlightStyle {
color: Some(rgba(0xf28779ff).into()),
color: Some(rgba(0xffd173ff).into()),
..Default::default()
},
),
@ -615,6 +631,14 @@ pub fn ayu() -> UserThemeFamily {
..Default::default()
},
),
(
"comment.doc".into(),
UserHighlightStyle {
color: Some(rgba(0xacb6bf8c).into()),
font_style: Some(UserFontStyle::Italic),
..Default::default()
},
),
(
"constant".into(),
UserHighlightStyle {
@ -648,14 +672,14 @@ pub fn ayu() -> UserThemeFamily {
(
"function".into(),
UserHighlightStyle {
color: Some(rgba(0xffb454ff).into()),
color: Some(rgba(0xf07178ff).into()),
..Default::default()
},
),
(
"keyword".into(),
UserHighlightStyle {
color: Some(rgba(0xff8f40ff).into()),
color: Some(rgba(0x39bae6ff).into()),
..Default::default()
},
),
@ -697,7 +721,7 @@ pub fn ayu() -> UserThemeFamily {
(
"property".into(),
UserHighlightStyle {
color: Some(rgba(0xf07178ff).into()),
color: Some(rgba(0x39bae6ff).into()),
..Default::default()
},
),
@ -795,7 +819,7 @@ pub fn ayu() -> UserThemeFamily {
(
"variable.special".into(),
UserHighlightStyle {
color: Some(rgba(0xf07178ff).into()),
color: Some(rgba(0xffb454ff).into()),
..Default::default()
},
),