Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

theme: Specify color format and pattern in schema (#49136)

Julien Roncaglia33f1112fc2af
diff --git a/crates/editor/src/bracket_colorization.rs b/crates/editor/src/bracket_colorization.rs
index d69f6162bd2..cfca232faa7 100644
--- a/crates/editor/src/bracket_colorization.rs
+++ b/crates/editor/src/bracket_colorization.rs
@@ -1800,8 +1800,8 @@ mod foo «1{
theme.to_string(),
ThemeStyleContent {
accents: vec![
- AccentContent(Some("#ff0000".to_string())),
- AccentContent(Some("#0000ff".to_string())),
+ AccentContent(Some("#ff0000".into())),
+ AccentContent(Some("#0000ff".into())),
],
..ThemeStyleContent::default()
},
diff --git a/crates/editor/src/document_symbols.rs b/crates/editor/src/document_symbols.rs
index 5d3d73f405c..3a2f488db8d 100644
--- a/crates/editor/src/document_symbols.rs
+++ b/crates/editor/src/document_symbols.rs
@@ -926,7 +926,7 @@ mod tests {
syntax: IndexMap::from_iter([(
"keyword".to_string(),
HighlightStyleContent {
- color: Some("#ff0000".to_string()),
+ color: Some("#ff0000".into()),
background_color: None,
font_style: None,
font_weight: None,
@@ -986,7 +986,7 @@ mod tests {
syntax: IndexMap::from_iter([(
"keyword".to_string(),
HighlightStyleContent {
- color: Some("#0000ff".to_string()),
+ color: Some("#0000ff".into()),
background_color: None,
font_style: None,
font_weight: None,
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index aa2a5db2f17..89223e7f730 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -9768,7 +9768,8 @@ impl Editor {
.into_iter()
.flatten(),
)
- .flat_map(|accent| accent.0.clone().map(SharedString::from))
+ .flat_map(|accent| accent.0.as_ref().map(|c| c.to_string()))
+ .map(SharedString::from)
.collect();
Some(AccentData {
diff --git a/crates/editor/src/semantic_tokens.rs b/crates/editor/src/semantic_tokens.rs
index 0d8006aad2d..65d22d18673 100644
--- a/crates/editor/src/semantic_tokens.rs
+++ b/crates/editor/src/semantic_tokens.rs
@@ -1837,7 +1837,7 @@ mod tests {
syntax: IndexMap::from_iter([(
"function".to_string(),
HighlightStyleContent {
- color: Some("#ff0000".to_string()),
+ color: Some("#ff0000".into()),
background_color: None,
font_style: None,
font_weight: None,
@@ -1879,7 +1879,7 @@ mod tests {
syntax: IndexMap::from_iter([(
"function".to_string(),
HighlightStyleContent {
- color: Some("#0000ff".to_string()),
+ color: Some("#0000ff".into()),
background_color: None,
font_style: None,
font_weight: None,
@@ -2006,7 +2006,7 @@ mod tests {
syntax: IndexMap::from_iter([(
"function".to_string(),
HighlightStyleContent {
- color: Some("#00ff00".to_string()),
+ color: Some("#00ff00".into()),
background_color: None,
font_style: None,
font_weight: None,
diff --git a/crates/schema_generator/src/main.rs b/crates/schema_generator/src/main.rs
index d34cd897b9e..6386146cb6e 100644
--- a/crates/schema_generator/src/main.rs
+++ b/crates/schema_generator/src/main.rs
@@ -1,3 +1,7 @@
+use std::fs::File;
+use std::io::Write;
+use std::path::PathBuf;
+
use anyhow::Result;
use clap::{Parser, ValueEnum};
use schemars::schema_for;
@@ -9,6 +13,10 @@ use theme_settings::ThemeFamilyContent;
pub struct Args {
#[arg(value_enum)]
pub schema_type: SchemaType,
+
+ /// The path to write the output to.
+ #[arg(long, short)]
+ pub output: Option<PathBuf>,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
@@ -24,19 +32,26 @@ fn main() -> Result<()> {
let args = Args::parse();
- match args.schema_type {
+ let schema_json = match args.schema_type {
SchemaType::Theme => {
let schema = schema_for!(ThemeFamilyContent);
- println!("{}", serde_json::to_string_pretty(&schema)?);
+ serde_json::to_string_pretty(&schema)?
}
SchemaType::IconTheme => {
let schema = schema_for!(IconThemeFamilyContent);
- println!("{}", serde_json::to_string_pretty(&schema)?);
+ serde_json::to_string_pretty(&schema)?
}
SchemaType::Project => {
let schema = schema_for!(ProjectSettingsContent);
- println!("{}", serde_json::to_string_pretty(&schema)?);
+ serde_json::to_string_pretty(&schema)?
}
+ };
+
+ if let Some(output_path) = args.output {
+ let mut file = File::create(output_path)?;
+ file.write_all(schema_json.as_bytes())?;
+ } else {
+ println!("{}", schema_json);
}
Ok(())
diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs
index 39764a066ac..9484f502874 100644
--- a/crates/search/src/project_search.rs
+++ b/crates/search/src/project_search.rs
@@ -3107,7 +3107,7 @@ pub mod tests {
settings.update_user_settings(cx, |settings| {
settings.theme.experimental_theme_overrides = Some(ThemeStyleContent {
colors: ThemeColorsContent {
- search_active_match_background: Some("#ff0000ff".to_string()),
+ search_active_match_background: Some("#ff0000ff".into()),
..Default::default()
},
..Default::default()
diff --git a/crates/settings_content/src/theme.rs b/crates/settings_content/src/theme.rs
index fbfc941d36f..cf12cce9710 100644
--- a/crates/settings_content/src/theme.rs
+++ b/crates/settings_content/src/theme.rs
@@ -3,7 +3,7 @@ use schemars::JsonSchema;
use serde::{Deserialize, Deserializer, Serialize};
use serde_json::Value;
use settings_macros::{MergeFrom, with_fallible_options};
-use std::{borrow::Cow, fmt::Display, sync::Arc};
+use std::{borrow::Cow, fmt::Display, ops::Deref, sync::Arc};
use crate::serialize_f32_with_two_decimal_places;
@@ -111,6 +111,66 @@ impl JsonSchema for FontFeaturesContent {
}
}
+#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, MergeFrom)]
+#[serde(transparent)]
+pub struct ThemeColor(String);
+
+impl JsonSchema for ThemeColor {
+ fn schema_name() -> Cow<'static, str> {
+ "Color".into()
+ }
+
+ fn json_schema(_generator: &mut schemars::SchemaGenerator) -> schemars::Schema {
+ use schemars::json_schema;
+ json_schema!({
+ "type": "string",
+ "pattern": "^#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$",
+ "format": "color"
+ })
+ }
+}
+
+impl From<String> for ThemeColor {
+ fn from(value: String) -> Self {
+ ThemeColor(value)
+ }
+}
+
+impl From<&str> for ThemeColor {
+ fn from(value: &str) -> Self {
+ ThemeColor(value.to_string())
+ }
+}
+
+impl Deref for ThemeColor {
+ type Target = str;
+
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+
+impl From<ThemeColor> for String {
+ fn from(value: ThemeColor) -> Self {
+ value.0
+ }
+}
+
+impl Display for ThemeColor {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", self.0)
+ }
+}
+
+impl TryFrom<&ThemeColor> for gpui::Rgba {
+ type Error = anyhow::Error;
+
+ fn try_from(value: &ThemeColor) -> anyhow::Result<Self> {
+ let s: &str = &value.0;
+ gpui::Rgba::try_from(s)
+ }
+}
+
/// Settings for rendering text in UI and text buffers.
#[with_fallible_options]
@@ -496,13 +556,13 @@ pub struct ThemeStyleContent {
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
-pub struct AccentContent(pub Option<String>);
+pub struct AccentContent(pub Option<ThemeColor>);
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
pub struct PlayerColorContent {
- pub cursor: Option<String>,
- pub background: Option<String>,
- pub selection: Option<String>,
+ pub cursor: Option<ThemeColor>,
+ pub background: Option<ThemeColor>,
+ pub selection: Option<ThemeColor>,
}
/// Theme name.
@@ -523,39 +583,39 @@ pub struct IconThemeName(pub Arc<str>);
pub struct ThemeColorsContent {
/// Border color. Used for most borders, is usually a high contrast color.
#[serde(rename = "border")]
- pub border: Option<String>,
+ pub border: Option<ThemeColor>,
/// Border color. Used for deemphasized borders, like a visual divider between two sections
#[serde(rename = "border.variant")]
- pub border_variant: Option<String>,
+ pub border_variant: Option<ThemeColor>,
/// Border color. Used for focused elements, like keyboard focused list item.
#[serde(rename = "border.focused")]
- pub border_focused: Option<String>,
+ pub border_focused: Option<ThemeColor>,
/// Border color. Used for selected elements, like an active search filter or selected checkbox.
#[serde(rename = "border.selected")]
- pub border_selected: Option<String>,
+ pub border_selected: Option<ThemeColor>,
/// Border color. Used for transparent borders. Used for placeholder borders when an element gains a border on state change.
#[serde(rename = "border.transparent")]
- pub border_transparent: Option<String>,
+ pub border_transparent: Option<ThemeColor>,
/// Border color. Used for disabled elements, like a disabled input or button.
#[serde(rename = "border.disabled")]
- pub border_disabled: Option<String>,
+ pub border_disabled: Option<ThemeColor>,
/// Background color. Used for elevated surfaces, like a context menu, popup, or dialog.
#[serde(rename = "elevated_surface.background")]
- pub elevated_surface_background: Option<String>,
+ pub elevated_surface_background: Option<ThemeColor>,
/// Background Color. Used for grounded surfaces like a panel or tab.
#[serde(rename = "surface.background")]
- pub surface_background: Option<String>,
+ pub surface_background: Option<ThemeColor>,
/// Background Color. Used for the app background and blank panels or windows.
#[serde(rename = "background")]
- pub background: Option<String>,
+ pub background: Option<ThemeColor>,
/// Background Color. Used for the background of an element that should have a different background than the surface it's on.
///
@@ -563,19 +623,19 @@ pub struct ThemeColorsContent {
///
/// For an element that should have the same background as the surface it's on, use `ghost_element_background`.
#[serde(rename = "element.background")]
- pub element_background: Option<String>,
+ pub element_background: Option<ThemeColor>,
/// Background Color. Used for the hover state of an element that should have a different background than the surface it's on.
///
/// Hover states are triggered by the mouse entering an element, or a finger touching an element on a touch screen.
#[serde(rename = "element.hover")]
- pub element_hover: Option<String>,
+ pub element_hover: Option<ThemeColor>,
/// Background Color. Used for the active state of an element that should have a different background than the surface it's on.
///
/// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressed.
#[serde(rename = "element.active")]
- pub element_active: Option<String>,
+ pub element_active: Option<ThemeColor>,
/// Background Color. Used for the selected state of an element that should have a different background than the surface it's on.
///
@@ -583,25 +643,25 @@ pub struct ThemeColorsContent {
///
/// This could include a selected checkbox, a toggleable button that is toggled on, etc.
#[serde(rename = "element.selected")]
- pub element_selected: Option<String>,
+ pub element_selected: Option<ThemeColor>,
/// Background Color. Used for the disabled state of an element that should have a different background than the surface it's on.
///
/// Disabled states are shown when a user cannot interact with an element, like a disabled button or input.
#[serde(rename = "element.disabled")]
- pub element_disabled: Option<String>,
+ pub element_disabled: Option<ThemeColor>,
/// Background Color. Used for the background of selections in a UI element.
#[serde(rename = "element.selection_background")]
- pub element_selection_background: Option<String>,
+ pub element_selection_background: Option<ThemeColor>,
/// Background Color. Used for the area that shows where a dragged element will be dropped.
#[serde(rename = "drop_target.background")]
- pub drop_target_background: Option<String>,
+ pub drop_target_background: Option<ThemeColor>,
/// Border Color. Used for the border that shows where a dragged element will be dropped.
#[serde(rename = "drop_target.border")]
- pub drop_target_border: Option<String>,
+ pub drop_target_border: Option<ThemeColor>,
/// Used for the background of a ghost element that should have the same background as the surface it's on.
///
@@ -609,19 +669,19 @@ pub struct ThemeColorsContent {
///
/// For an element that should have a different background than the surface it's on, use `element_background`.
#[serde(rename = "ghost_element.background")]
- pub ghost_element_background: Option<String>,
+ pub ghost_element_background: Option<ThemeColor>,
/// Background Color. Used for the hover state of a ghost element that should have the same background as the surface it's on.
///
/// Hover states are triggered by the mouse entering an element, or a finger touching an element on a touch screen.
#[serde(rename = "ghost_element.hover")]
- pub ghost_element_hover: Option<String>,
+ pub ghost_element_hover: Option<ThemeColor>,
/// Background Color. Used for the active state of a ghost element that should have the same background as the surface it's on.
///
/// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressed.
#[serde(rename = "ghost_element.active")]
- pub ghost_element_active: Option<String>,
+ pub ghost_element_active: Option<ThemeColor>,
/// Background Color. Used for the selected state of a ghost element that should have the same background as the surface it's on.
///
@@ -629,219 +689,219 @@ pub struct ThemeColorsContent {
///
/// This could include a selected checkbox, a toggleable button that is toggled on, etc.
#[serde(rename = "ghost_element.selected")]
- pub ghost_element_selected: Option<String>,
+ pub ghost_element_selected: Option<ThemeColor>,
/// Background Color. Used for the disabled state of a ghost element that should have the same background as the surface it's on.
///
/// Disabled states are shown when a user cannot interact with an element, like a disabled button or input.
#[serde(rename = "ghost_element.disabled")]
- pub ghost_element_disabled: Option<String>,
+ pub ghost_element_disabled: Option<ThemeColor>,
/// Text Color. Default text color used for most text.
#[serde(rename = "text")]
- pub text: Option<String>,
+ pub text: Option<ThemeColor>,
/// Text Color. Color of muted or deemphasized text. It is a subdued version of the standard text color.
#[serde(rename = "text.muted")]
- pub text_muted: Option<String>,
+ pub text_muted: Option<ThemeColor>,
/// Text Color. Color of the placeholder text typically shown in input fields to guide the user to enter valid data.
#[serde(rename = "text.placeholder")]
- pub text_placeholder: Option<String>,
+ pub text_placeholder: Option<ThemeColor>,
/// Text Color. Color used for text denoting disabled elements. Typically, the color is faded or grayed out to emphasize the disabled state.
#[serde(rename = "text.disabled")]
- pub text_disabled: Option<String>,
+ pub text_disabled: Option<ThemeColor>,
/// Text Color. Color used for emphasis or highlighting certain text, like an active filter or a matched character in a search.
#[serde(rename = "text.accent")]
- pub text_accent: Option<String>,
+ pub text_accent: Option<ThemeColor>,
/// Fill Color. Used for the default fill color of an icon.
#[serde(rename = "icon")]
- pub icon: Option<String>,
+ pub icon: Option<ThemeColor>,
/// Fill Color. Used for the muted or deemphasized fill color of an icon.
///
/// This might be used to show an icon in an inactive pane, or to deemphasize a series of icons to give them less visual weight.
#[serde(rename = "icon.muted")]
- pub icon_muted: Option<String>,
+ pub icon_muted: Option<ThemeColor>,
/// Fill Color. Used for the disabled fill color of an icon.
///
/// Disabled states are shown when a user cannot interact with an element, like a icon button.
#[serde(rename = "icon.disabled")]
- pub icon_disabled: Option<String>,
+ pub icon_disabled: Option<ThemeColor>,
/// Fill Color. Used for the placeholder fill color of an icon.
///
/// This might be used to show an icon in an input that disappears when the user enters text.
#[serde(rename = "icon.placeholder")]
- pub icon_placeholder: Option<String>,
+ pub icon_placeholder: Option<ThemeColor>,
/// Fill Color. Used for the accent fill color of an icon.
///
/// This might be used to show when a toggleable icon button is selected.
#[serde(rename = "icon.accent")]
- pub icon_accent: Option<String>,
+ pub icon_accent: Option<ThemeColor>,
/// Color used to accent some of the debuggers elements
/// Only accent breakpoint & breakpoint related symbols right now
#[serde(rename = "debugger.accent")]
- pub debugger_accent: Option<String>,
+ pub debugger_accent: Option<ThemeColor>,
#[serde(rename = "status_bar.background")]
- pub status_bar_background: Option<String>,
+ pub status_bar_background: Option<ThemeColor>,
#[serde(rename = "title_bar.background")]
- pub title_bar_background: Option<String>,
+ pub title_bar_background: Option<ThemeColor>,
#[serde(rename = "title_bar.inactive_background")]
- pub title_bar_inactive_background: Option<String>,
+ pub title_bar_inactive_background: Option<ThemeColor>,
#[serde(rename = "toolbar.background")]
- pub toolbar_background: Option<String>,
+ pub toolbar_background: Option<ThemeColor>,
#[serde(rename = "tab_bar.background")]
- pub tab_bar_background: Option<String>,
+ pub tab_bar_background: Option<ThemeColor>,
#[serde(rename = "tab.inactive_background")]
- pub tab_inactive_background: Option<String>,
+ pub tab_inactive_background: Option<ThemeColor>,
#[serde(rename = "tab.active_background")]
- pub tab_active_background: Option<String>,
+ pub tab_active_background: Option<ThemeColor>,
#[serde(rename = "search.match_background")]
- pub search_match_background: Option<String>,
+ pub search_match_background: Option<ThemeColor>,
#[serde(rename = "search.active_match_background")]
- pub search_active_match_background: Option<String>,
+ pub search_active_match_background: Option<ThemeColor>,
#[serde(rename = "panel.background")]
- pub panel_background: Option<String>,
+ pub panel_background: Option<ThemeColor>,
#[serde(rename = "panel.focused_border")]
- pub panel_focused_border: Option<String>,
+ pub panel_focused_border: Option<ThemeColor>,
#[serde(rename = "panel.indent_guide")]
- pub panel_indent_guide: Option<String>,
+ pub panel_indent_guide: Option<ThemeColor>,
#[serde(rename = "panel.indent_guide_hover")]
- pub panel_indent_guide_hover: Option<String>,
+ pub panel_indent_guide_hover: Option<ThemeColor>,
#[serde(rename = "panel.indent_guide_active")]
- pub panel_indent_guide_active: Option<String>,
+ pub panel_indent_guide_active: Option<ThemeColor>,
#[serde(rename = "panel.overlay_background")]
- pub panel_overlay_background: Option<String>,
+ pub panel_overlay_background: Option<ThemeColor>,
#[serde(rename = "panel.overlay_hover")]
- pub panel_overlay_hover: Option<String>,
+ pub panel_overlay_hover: Option<ThemeColor>,
#[serde(rename = "pane.focused_border")]
- pub pane_focused_border: Option<String>,
+ pub pane_focused_border: Option<ThemeColor>,
#[serde(rename = "pane_group.border")]
- pub pane_group_border: Option<String>,
+ pub pane_group_border: Option<ThemeColor>,
/// The deprecated version of `scrollbar.thumb.background`.
///
/// Don't use this field.
#[serde(rename = "scrollbar_thumb.background", skip_serializing)]
#[schemars(skip)]
- pub deprecated_scrollbar_thumb_background: Option<String>,
+ pub deprecated_scrollbar_thumb_background: Option<ThemeColor>,
/// The color of the scrollbar thumb.
#[serde(rename = "scrollbar.thumb.background")]
- pub scrollbar_thumb_background: Option<String>,
+ pub scrollbar_thumb_background: Option<ThemeColor>,
/// The color of the scrollbar thumb when hovered over.
#[serde(rename = "scrollbar.thumb.hover_background")]
- pub scrollbar_thumb_hover_background: Option<String>,
+ pub scrollbar_thumb_hover_background: Option<ThemeColor>,
/// The color of the scrollbar thumb whilst being actively dragged.
#[serde(rename = "scrollbar.thumb.active_background")]
- pub scrollbar_thumb_active_background: Option<String>,
+ pub scrollbar_thumb_active_background: Option<ThemeColor>,
/// The border color of the scrollbar thumb.
#[serde(rename = "scrollbar.thumb.border")]
- pub scrollbar_thumb_border: Option<String>,
+ pub scrollbar_thumb_border: Option<ThemeColor>,
/// The background color of the scrollbar track.
#[serde(rename = "scrollbar.track.background")]
- pub scrollbar_track_background: Option<String>,
+ pub scrollbar_track_background: Option<ThemeColor>,
/// The border color of the scrollbar track.
#[serde(rename = "scrollbar.track.border")]
- pub scrollbar_track_border: Option<String>,
+ pub scrollbar_track_border: Option<ThemeColor>,
/// The color of the minimap thumb.
#[serde(rename = "minimap.thumb.background")]
- pub minimap_thumb_background: Option<String>,
+ pub minimap_thumb_background: Option<ThemeColor>,
/// The color of the minimap thumb when hovered over.
#[serde(rename = "minimap.thumb.hover_background")]
- pub minimap_thumb_hover_background: Option<String>,
+ pub minimap_thumb_hover_background: Option<ThemeColor>,
/// The color of the minimap thumb whilst being actively dragged.
#[serde(rename = "minimap.thumb.active_background")]
- pub minimap_thumb_active_background: Option<String>,
+ pub minimap_thumb_active_background: Option<ThemeColor>,
/// The border color of the minimap thumb.
#[serde(rename = "minimap.thumb.border")]
- pub minimap_thumb_border: Option<String>,
+ pub minimap_thumb_border: Option<ThemeColor>,
#[serde(rename = "editor.foreground")]
- pub editor_foreground: Option<String>,
+ pub editor_foreground: Option<ThemeColor>,
#[serde(rename = "editor.background")]
- pub editor_background: Option<String>,
+ pub editor_background: Option<ThemeColor>,
#[serde(rename = "editor.gutter.background")]
- pub editor_gutter_background: Option<String>,
+ pub editor_gutter_background: Option<ThemeColor>,
#[serde(rename = "editor.subheader.background")]
- pub editor_subheader_background: Option<String>,
+ pub editor_subheader_background: Option<ThemeColor>,
#[serde(rename = "editor.active_line.background")]
- pub editor_active_line_background: Option<String>,
+ pub editor_active_line_background: Option<ThemeColor>,
#[serde(rename = "editor.highlighted_line.background")]
- pub editor_highlighted_line_background: Option<String>,
+ pub editor_highlighted_line_background: Option<ThemeColor>,
/// Background of active line of debugger
#[serde(rename = "editor.debugger_active_line.background")]
- pub editor_debugger_active_line_background: Option<String>,
+ pub editor_debugger_active_line_background: Option<ThemeColor>,
/// Text Color. Used for the text of the line number in the editor gutter.
#[serde(rename = "editor.line_number")]
- pub editor_line_number: Option<String>,
+ pub editor_line_number: Option<ThemeColor>,
/// Text Color. Used for the text of the line number in the editor gutter when the line is highlighted.
#[serde(rename = "editor.active_line_number")]
- pub editor_active_line_number: Option<String>,
+ pub editor_active_line_number: Option<ThemeColor>,
/// Text Color. Used for the text of the line number in the editor gutter when the line is hovered over.
#[serde(rename = "editor.hover_line_number")]
- pub editor_hover_line_number: Option<String>,
+ pub editor_hover_line_number: Option<ThemeColor>,
/// Text Color. Used to mark invisible characters in the editor.
///
/// Example: spaces, tabs, carriage returns, etc.
#[serde(rename = "editor.invisible")]
- pub editor_invisible: Option<String>,
+ pub editor_invisible: Option<ThemeColor>,
#[serde(rename = "editor.wrap_guide")]
- pub editor_wrap_guide: Option<String>,
+ pub editor_wrap_guide: Option<ThemeColor>,
#[serde(rename = "editor.active_wrap_guide")]
- pub editor_active_wrap_guide: Option<String>,
+ pub editor_active_wrap_guide: Option<ThemeColor>,
#[serde(rename = "editor.indent_guide")]
- pub editor_indent_guide: Option<String>,
+ pub editor_indent_guide: Option<ThemeColor>,
#[serde(rename = "editor.indent_guide_active")]
- pub editor_indent_guide_active: Option<String>,
+ pub editor_indent_guide_active: Option<ThemeColor>,
/// Read-access of a symbol, like reading a variable.
///
@@ -849,7 +909,7 @@ pub struct ThemeColorsContent {
/// special attention. Usually a document highlight is visualized by changing
/// the background color of its range.
#[serde(rename = "editor.document_highlight.read_background")]
- pub editor_document_highlight_read_background: Option<String>,
+ pub editor_document_highlight_read_background: Option<ThemeColor>,
/// Read-access of a symbol, like reading a variable.
///
@@ -857,271 +917,271 @@ pub struct ThemeColorsContent {
/// special attention. Usually a document highlight is visualized by changing
/// the background color of its range.
#[serde(rename = "editor.document_highlight.write_background")]
- pub editor_document_highlight_write_background: Option<String>,
+ pub editor_document_highlight_write_background: Option<ThemeColor>,
/// Highlighted brackets background color.
///
/// Matching brackets in the cursor scope are highlighted with this background color.
#[serde(rename = "editor.document_highlight.bracket_background")]
- pub editor_document_highlight_bracket_background: Option<String>,
+ pub editor_document_highlight_bracket_background: Option<ThemeColor>,
/// Filled background color for added diff hunk row highlights in the editor.
#[serde(rename = "editor.diff_hunk.added.background")]
- pub editor_diff_hunk_added_background: Option<String>,
+ pub editor_diff_hunk_added_background: Option<ThemeColor>,
/// Hollow background color for added diff hunk row highlights in the editor.
#[serde(rename = "editor.diff_hunk.added.hollow_background")]
- pub editor_diff_hunk_added_hollow_background: Option<String>,
+ pub editor_diff_hunk_added_hollow_background: Option<ThemeColor>,
/// Hollow border color for added diff hunk row highlights in the editor.
#[serde(rename = "editor.diff_hunk.added.hollow_border")]
- pub editor_diff_hunk_added_hollow_border: Option<String>,
+ pub editor_diff_hunk_added_hollow_border: Option<ThemeColor>,
/// Filled background color for deleted diff hunk row highlights in the editor.
#[serde(rename = "editor.diff_hunk.deleted.background")]
- pub editor_diff_hunk_deleted_background: Option<String>,
+ pub editor_diff_hunk_deleted_background: Option<ThemeColor>,
/// Hollow background color for deleted diff hunk row highlights in the editor.
#[serde(rename = "editor.diff_hunk.deleted.hollow_background")]
- pub editor_diff_hunk_deleted_hollow_background: Option<String>,
+ pub editor_diff_hunk_deleted_hollow_background: Option<ThemeColor>,
/// Hollow border color for deleted diff hunk row highlights in the editor.
#[serde(rename = "editor.diff_hunk.deleted.hollow_border")]
- pub editor_diff_hunk_deleted_hollow_border: Option<String>,
+ pub editor_diff_hunk_deleted_hollow_border: Option<ThemeColor>,
/// Terminal background color.
#[serde(rename = "terminal.background")]
- pub terminal_background: Option<String>,
+ pub terminal_background: Option<ThemeColor>,
/// Terminal foreground color.
#[serde(rename = "terminal.foreground")]
- pub terminal_foreground: Option<String>,
+ pub terminal_foreground: Option<ThemeColor>,
/// Terminal ANSI background color.
#[serde(rename = "terminal.ansi.background")]
- pub terminal_ansi_background: Option<String>,
+ pub terminal_ansi_background: Option<ThemeColor>,
/// Bright terminal foreground color.
#[serde(rename = "terminal.bright_foreground")]
- pub terminal_bright_foreground: Option<String>,
+ pub terminal_bright_foreground: Option<ThemeColor>,
/// Dim terminal foreground color.
#[serde(rename = "terminal.dim_foreground")]
- pub terminal_dim_foreground: Option<String>,
+ pub terminal_dim_foreground: Option<ThemeColor>,
/// Black ANSI terminal color.
#[serde(rename = "terminal.ansi.black")]
- pub terminal_ansi_black: Option<String>,
+ pub terminal_ansi_black: Option<ThemeColor>,
/// Bright black ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_black")]
- pub terminal_ansi_bright_black: Option<String>,
+ pub terminal_ansi_bright_black: Option<ThemeColor>,
/// Dim black ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_black")]
- pub terminal_ansi_dim_black: Option<String>,
+ pub terminal_ansi_dim_black: Option<ThemeColor>,
/// Red ANSI terminal color.
#[serde(rename = "terminal.ansi.red")]
- pub terminal_ansi_red: Option<String>,
+ pub terminal_ansi_red: Option<ThemeColor>,
/// Bright red ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_red")]
- pub terminal_ansi_bright_red: Option<String>,
+ pub terminal_ansi_bright_red: Option<ThemeColor>,
/// Dim red ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_red")]
- pub terminal_ansi_dim_red: Option<String>,
+ pub terminal_ansi_dim_red: Option<ThemeColor>,
/// Green ANSI terminal color.
#[serde(rename = "terminal.ansi.green")]
- pub terminal_ansi_green: Option<String>,
+ pub terminal_ansi_green: Option<ThemeColor>,
/// Bright green ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_green")]
- pub terminal_ansi_bright_green: Option<String>,
+ pub terminal_ansi_bright_green: Option<ThemeColor>,
/// Dim green ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_green")]
- pub terminal_ansi_dim_green: Option<String>,
+ pub terminal_ansi_dim_green: Option<ThemeColor>,
/// Yellow ANSI terminal color.
#[serde(rename = "terminal.ansi.yellow")]
- pub terminal_ansi_yellow: Option<String>,
+ pub terminal_ansi_yellow: Option<ThemeColor>,
/// Bright yellow ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_yellow")]
- pub terminal_ansi_bright_yellow: Option<String>,
+ pub terminal_ansi_bright_yellow: Option<ThemeColor>,
/// Dim yellow ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_yellow")]
- pub terminal_ansi_dim_yellow: Option<String>,
+ pub terminal_ansi_dim_yellow: Option<ThemeColor>,
/// Blue ANSI terminal color.
#[serde(rename = "terminal.ansi.blue")]
- pub terminal_ansi_blue: Option<String>,
+ pub terminal_ansi_blue: Option<ThemeColor>,
/// Bright blue ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_blue")]
- pub terminal_ansi_bright_blue: Option<String>,
+ pub terminal_ansi_bright_blue: Option<ThemeColor>,
/// Dim blue ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_blue")]
- pub terminal_ansi_dim_blue: Option<String>,
+ pub terminal_ansi_dim_blue: Option<ThemeColor>,
/// Magenta ANSI terminal color.
#[serde(rename = "terminal.ansi.magenta")]
- pub terminal_ansi_magenta: Option<String>,
+ pub terminal_ansi_magenta: Option<ThemeColor>,
/// Bright magenta ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_magenta")]
- pub terminal_ansi_bright_magenta: Option<String>,
+ pub terminal_ansi_bright_magenta: Option<ThemeColor>,
/// Dim magenta ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_magenta")]
- pub terminal_ansi_dim_magenta: Option<String>,
+ pub terminal_ansi_dim_magenta: Option<ThemeColor>,
/// Cyan ANSI terminal color.
#[serde(rename = "terminal.ansi.cyan")]
- pub terminal_ansi_cyan: Option<String>,
+ pub terminal_ansi_cyan: Option<ThemeColor>,
/// Bright cyan ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_cyan")]
- pub terminal_ansi_bright_cyan: Option<String>,
+ pub terminal_ansi_bright_cyan: Option<ThemeColor>,
/// Dim cyan ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_cyan")]
- pub terminal_ansi_dim_cyan: Option<String>,
+ pub terminal_ansi_dim_cyan: Option<ThemeColor>,
/// White ANSI terminal color.
#[serde(rename = "terminal.ansi.white")]
- pub terminal_ansi_white: Option<String>,
+ pub terminal_ansi_white: Option<ThemeColor>,
/// Bright white ANSI terminal color.
#[serde(rename = "terminal.ansi.bright_white")]
- pub terminal_ansi_bright_white: Option<String>,
+ pub terminal_ansi_bright_white: Option<ThemeColor>,
/// Dim white ANSI terminal color.
#[serde(rename = "terminal.ansi.dim_white")]
- pub terminal_ansi_dim_white: Option<String>,
+ pub terminal_ansi_dim_white: Option<ThemeColor>,
#[serde(rename = "link_text.hover")]
- pub link_text_hover: Option<String>,
+ pub link_text_hover: Option<ThemeColor>,
/// Added version control color.
#[serde(rename = "version_control.added")]
- pub version_control_added: Option<String>,
+ pub version_control_added: Option<ThemeColor>,
/// Deleted version control color.
#[serde(rename = "version_control.deleted")]
- pub version_control_deleted: Option<String>,
+ pub version_control_deleted: Option<ThemeColor>,
/// Modified version control color.
#[serde(rename = "version_control.modified")]
- pub version_control_modified: Option<String>,
+ pub version_control_modified: Option<ThemeColor>,
/// Renamed version control color.
#[serde(rename = "version_control.renamed")]
- pub version_control_renamed: Option<String>,
+ pub version_control_renamed: Option<ThemeColor>,
/// Conflict version control color.
#[serde(rename = "version_control.conflict")]
- pub version_control_conflict: Option<String>,
+ pub version_control_conflict: Option<ThemeColor>,
/// Ignored version control color.
#[serde(rename = "version_control.ignored")]
- pub version_control_ignored: Option<String>,
+ pub version_control_ignored: Option<ThemeColor>,
/// Color for added words in word diffs.
#[serde(rename = "version_control.word_added")]
- pub version_control_word_added: Option<String>,
+ pub version_control_word_added: Option<ThemeColor>,
/// Color for deleted words in word diffs.
#[serde(rename = "version_control.word_deleted")]
- pub version_control_word_deleted: Option<String>,
+ pub version_control_word_deleted: Option<ThemeColor>,
/// Background color for row highlights of "ours" regions in merge conflicts.
#[serde(rename = "version_control.conflict_marker.ours")]
- pub version_control_conflict_marker_ours: Option<String>,
+ pub version_control_conflict_marker_ours: Option<ThemeColor>,
/// Background color for row highlights of "theirs" regions in merge conflicts.
#[serde(rename = "version_control.conflict_marker.theirs")]
- pub version_control_conflict_marker_theirs: Option<String>,
+ pub version_control_conflict_marker_theirs: Option<ThemeColor>,
/// Deprecated in favor of `version_control_conflict_marker_ours`.
#[deprecated]
- pub version_control_conflict_ours_background: Option<String>,
+ pub version_control_conflict_ours_background: Option<ThemeColor>,
/// Deprecated in favor of `version_control_conflict_marker_theirs`.
#[deprecated]
- pub version_control_conflict_theirs_background: Option<String>,
+ pub version_control_conflict_theirs_background: Option<ThemeColor>,
/// Background color for Vim Normal mode indicator.
#[serde(rename = "vim.normal.background")]
- pub vim_normal_background: Option<String>,
+ pub vim_normal_background: Option<ThemeColor>,
/// Background color for Vim Insert mode indicator.
#[serde(rename = "vim.insert.background")]
- pub vim_insert_background: Option<String>,
+ pub vim_insert_background: Option<ThemeColor>,
/// Background color for Vim Replace mode indicator.
#[serde(rename = "vim.replace.background")]
- pub vim_replace_background: Option<String>,
+ pub vim_replace_background: Option<ThemeColor>,
/// Background color for Vim Visual mode indicator.
#[serde(rename = "vim.visual.background")]
- pub vim_visual_background: Option<String>,
+ pub vim_visual_background: Option<ThemeColor>,
/// Background color for Vim Visual Line mode indicator.
#[serde(rename = "vim.visual_line.background")]
- pub vim_visual_line_background: Option<String>,
+ pub vim_visual_line_background: Option<ThemeColor>,
/// Background color for Vim Visual Block mode indicator.
#[serde(rename = "vim.visual_block.background")]
- pub vim_visual_block_background: Option<String>,
+ pub vim_visual_block_background: Option<ThemeColor>,
/// Background color for Vim yank highlight.
#[serde(rename = "vim.yank.background")]
- pub vim_yank_background: Option<String>,
+ pub vim_yank_background: Option<ThemeColor>,
/// Foreground color for Helix jump labels.
#[serde(rename = "vim.helix_jump_label.foreground")]
- pub vim_helix_jump_label_foreground: Option<String>,
+ pub vim_helix_jump_label_foreground: Option<ThemeColor>,
/// Background color for Vim Helix Normal mode indicator.
#[serde(rename = "vim.helix_normal.background")]
- pub vim_helix_normal_background: Option<String>,
+ pub vim_helix_normal_background: Option<ThemeColor>,
/// Background color for Vim Helix Select mode indicator.
#[serde(rename = "vim.helix_select.background")]
- pub vim_helix_select_background: Option<String>,
+ pub vim_helix_select_background: Option<ThemeColor>,
/// Background color for Vim Normal mode indicator.
#[serde(rename = "vim.normal.foreground")]
- pub vim_normal_foreground: Option<String>,
+ pub vim_normal_foreground: Option<ThemeColor>,
/// Foreground color for Vim Insert mode indicator.
#[serde(rename = "vim.insert.foreground")]
- pub vim_insert_foreground: Option<String>,
+ pub vim_insert_foreground: Option<ThemeColor>,
/// Foreground color for Vim Replace mode indicator.
#[serde(rename = "vim.replace.foreground")]
- pub vim_replace_foreground: Option<String>,
+ pub vim_replace_foreground: Option<ThemeColor>,
/// Foreground color for Vim Visual mode indicator.
#[serde(rename = "vim.visual.foreground")]
- pub vim_visual_foreground: Option<String>,
+ pub vim_visual_foreground: Option<ThemeColor>,
/// Foreground color for Vim Visual Line mode indicator.
#[serde(rename = "vim.visual_line.foreground")]
- pub vim_visual_line_foreground: Option<String>,
+ pub vim_visual_line_foreground: Option<ThemeColor>,
/// Foreground color for Vim Visual Block mode indicator.
#[serde(rename = "vim.visual_block.foreground")]
- pub vim_visual_block_foreground: Option<String>,
+ pub vim_visual_block_foreground: Option<ThemeColor>,
/// Foreground color for Vim Helix Normal mode indicator.
#[serde(rename = "vim.helix_normal.foreground")]
- pub vim_helix_normal_foreground: Option<String>,
+ pub vim_helix_normal_foreground: Option<ThemeColor>,
/// Foreground color for Vim Helix Select mode indicator.
#[serde(rename = "vim.helix_select.foreground")]
- pub vim_helix_select_foreground: Option<String>,
+ pub vim_helix_select_foreground: Option<ThemeColor>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
#[serde(default)]
pub struct HighlightStyleContent {
- pub color: Option<String>,
+ pub color: Option<ThemeColor>,
#[serde(
skip_serializing_if = "Option::is_none",
deserialize_with = "treat_error_as_none"
)]
- pub background_color: Option<String>,
+ pub background_color: Option<ThemeColor>,
#[serde(
skip_serializing_if = "Option::is_none",
@@ -1161,143 +1221,143 @@ pub struct StatusColorsContent {
/// Indicates some kind of conflict, like a file changed on disk while it was open, or
/// merge conflicts in a Git repository.
#[serde(rename = "conflict")]
- pub conflict: Option<String>,
+ pub conflict: Option<ThemeColor>,
#[serde(rename = "conflict.background")]
- pub conflict_background: Option<String>,
+ pub conflict_background: Option<ThemeColor>,
#[serde(rename = "conflict.border")]
- pub conflict_border: Option<String>,
+ pub conflict_border: Option<ThemeColor>,
/// Indicates something new, like a new file added to a Git repository.
#[serde(rename = "created")]
- pub created: Option<String>,
+ pub created: Option<ThemeColor>,
#[serde(rename = "created.background")]
- pub created_background: Option<String>,
+ pub created_background: Option<ThemeColor>,
#[serde(rename = "created.border")]
- pub created_border: Option<String>,
+ pub created_border: Option<ThemeColor>,
/// Indicates that something no longer exists, like a deleted file.
#[serde(rename = "deleted")]
- pub deleted: Option<String>,
+ pub deleted: Option<ThemeColor>,
#[serde(rename = "deleted.background")]
- pub deleted_background: Option<String>,
+ pub deleted_background: Option<ThemeColor>,
#[serde(rename = "deleted.border")]
- pub deleted_border: Option<String>,
+ pub deleted_border: Option<ThemeColor>,
/// Indicates a system error, a failed operation or a diagnostic error.
#[serde(rename = "error")]
- pub error: Option<String>,
+ pub error: Option<ThemeColor>,
#[serde(rename = "error.background")]
- pub error_background: Option<String>,
+ pub error_background: Option<ThemeColor>,
#[serde(rename = "error.border")]
- pub error_border: Option<String>,
+ pub error_border: Option<ThemeColor>,
/// Represents a hidden status, such as a file being hidden in a file tree.
#[serde(rename = "hidden")]
- pub hidden: Option<String>,
+ pub hidden: Option<ThemeColor>,
#[serde(rename = "hidden.background")]
- pub hidden_background: Option<String>,
+ pub hidden_background: Option<ThemeColor>,
#[serde(rename = "hidden.border")]
- pub hidden_border: Option<String>,
+ pub hidden_border: Option<ThemeColor>,
/// Indicates a hint or some kind of additional information.
#[serde(rename = "hint")]
- pub hint: Option<String>,
+ pub hint: Option<ThemeColor>,
#[serde(rename = "hint.background")]
- pub hint_background: Option<String>,
+ pub hint_background: Option<ThemeColor>,
#[serde(rename = "hint.border")]
- pub hint_border: Option<String>,
+ pub hint_border: Option<ThemeColor>,
/// Indicates that something is deliberately ignored, such as a file or operation ignored by Git.
#[serde(rename = "ignored")]
- pub ignored: Option<String>,
+ pub ignored: Option<ThemeColor>,
#[serde(rename = "ignored.background")]
- pub ignored_background: Option<String>,
+ pub ignored_background: Option<ThemeColor>,
#[serde(rename = "ignored.border")]
- pub ignored_border: Option<String>,
+ pub ignored_border: Option<ThemeColor>,
/// Represents informational status updates or messages.
#[serde(rename = "info")]
- pub info: Option<String>,
+ pub info: Option<ThemeColor>,
#[serde(rename = "info.background")]
- pub info_background: Option<String>,
+ pub info_background: Option<ThemeColor>,
#[serde(rename = "info.border")]
- pub info_border: Option<String>,
+ pub info_border: Option<ThemeColor>,
/// Indicates a changed or altered status, like a file that has been edited.
#[serde(rename = "modified")]
- pub modified: Option<String>,
+ pub modified: Option<ThemeColor>,
#[serde(rename = "modified.background")]
- pub modified_background: Option<String>,
+ pub modified_background: Option<ThemeColor>,
#[serde(rename = "modified.border")]
- pub modified_border: Option<String>,
+ pub modified_border: Option<ThemeColor>,
/// Indicates something that is predicted, like automatic code completion, or generated code.
#[serde(rename = "predictive")]
- pub predictive: Option<String>,
+ pub predictive: Option<ThemeColor>,
#[serde(rename = "predictive.background")]
- pub predictive_background: Option<String>,
+ pub predictive_background: Option<ThemeColor>,
#[serde(rename = "predictive.border")]
- pub predictive_border: Option<String>,
+ pub predictive_border: Option<ThemeColor>,
/// Represents a renamed status, such as a file that has been renamed.
#[serde(rename = "renamed")]
- pub renamed: Option<String>,
+ pub renamed: Option<ThemeColor>,
#[serde(rename = "renamed.background")]
- pub renamed_background: Option<String>,
+ pub renamed_background: Option<ThemeColor>,
#[serde(rename = "renamed.border")]
- pub renamed_border: Option<String>,
+ pub renamed_border: Option<ThemeColor>,
/// Indicates a successful operation or task completion.
#[serde(rename = "success")]
- pub success: Option<String>,
+ pub success: Option<ThemeColor>,
#[serde(rename = "success.background")]
- pub success_background: Option<String>,
+ pub success_background: Option<ThemeColor>,
#[serde(rename = "success.border")]
- pub success_border: Option<String>,
+ pub success_border: Option<ThemeColor>,
/// Indicates some kind of unreachable status, like a block of code that can never be reached.
#[serde(rename = "unreachable")]
- pub unreachable: Option<String>,
+ pub unreachable: Option<ThemeColor>,
#[serde(rename = "unreachable.background")]
- pub unreachable_background: Option<String>,
+ pub unreachable_background: Option<ThemeColor>,
#[serde(rename = "unreachable.border")]
- pub unreachable_border: Option<String>,
+ pub unreachable_border: Option<ThemeColor>,
/// Represents a warning status, like an operation that is about to fail.
#[serde(rename = "warning")]
- pub warning: Option<String>,
+ pub warning: Option<ThemeColor>,
#[serde(rename = "warning.background")]
- pub warning_background: Option<String>,
+ pub warning_background: Option<ThemeColor>,
#[serde(rename = "warning.border")]
- pub warning_border: Option<String>,
+ pub warning_border: Option<ThemeColor>,
}
/// The background appearance of the window.
diff --git a/crates/theme_importer/src/vscode/converter.rs b/crates/theme_importer/src/vscode/converter.rs
index 70b7c0e9f66..cc7005847ad 100644
--- a/crates/theme_importer/src/vscode/converter.rs
+++ b/crates/theme_importer/src/vscode/converter.rs
@@ -70,7 +70,7 @@ impl VsCodeThemeConverter {
let vscode_colors = &self.theme.colors;
let vscode_base_status_colors = StatusColorsContent {
- hint: Some("#969696ff".to_string()),
+ hint: Some("#969696ff".into()),
..Default::default()
};
@@ -78,32 +78,79 @@ impl VsCodeThemeConverter {
conflict: vscode_colors
.git_decoration
.conflicting_resource_foreground
- .clone(),
- created: vscode_colors.editor_gutter.added_background.clone(),
- deleted: vscode_colors.editor_gutter.deleted_background.clone(),
- error: vscode_colors.editor_error.foreground.clone(),
- error_background: vscode_colors.editor_error.background.clone(),
- error_border: vscode_colors.editor_error.border.clone(),
- hidden: vscode_colors.tab.inactive_foreground.clone(),
+ .as_deref()
+ .map(Into::into),
+ created: vscode_colors
+ .editor_gutter
+ .added_background
+ .as_deref()
+ .map(Into::into),
+ deleted: vscode_colors
+ .editor_gutter
+ .deleted_background
+ .as_deref()
+ .map(Into::into),
+ error: vscode_colors
+ .editor_error
+ .foreground
+ .as_deref()
+ .map(Into::into),
+ error_background: vscode_colors
+ .editor_error
+ .background
+ .as_deref()
+ .map(Into::into),
+ error_border: vscode_colors.editor_error.border.as_deref().map(Into::into),
+ hidden: vscode_colors
+ .tab
+ .inactive_foreground
+ .as_deref()
+ .map(Into::into),
hint: vscode_colors
.editor_inlay_hint
.foreground
- .clone()
+ .as_deref()
+ .map(Into::into)
.or(vscode_base_status_colors.hint),
- hint_border: vscode_colors.editor_hint.border.clone(),
+ hint_border: vscode_colors.editor_hint.border.as_deref().map(Into::into),
ignored: vscode_colors
.git_decoration
.ignored_resource_foreground
- .clone(),
- info: vscode_colors.editor_info.foreground.clone(),
- info_background: vscode_colors.editor_info.background.clone(),
- info_border: vscode_colors.editor_info.border.clone(),
- modified: vscode_colors.editor_gutter.modified_background.clone(),
+ .as_deref()
+ .map(Into::into),
+ info: vscode_colors
+ .editor_info
+ .foreground
+ .as_deref()
+ .map(Into::into),
+ info_background: vscode_colors
+ .editor_info
+ .background
+ .as_deref()
+ .map(Into::into),
+ info_border: vscode_colors.editor_info.border.as_deref().map(Into::into),
+ modified: vscode_colors
+ .editor_gutter
+ .modified_background
+ .as_deref()
+ .map(Into::into),
// renamed: None,
// success: None,
- warning: vscode_colors.editor_warning.foreground.clone(),
- warning_background: vscode_colors.editor_warning.background.clone(),
- warning_border: vscode_colors.editor_warning.border.clone(),
+ warning: vscode_colors
+ .editor_warning
+ .foreground
+ .as_deref()
+ .map(Into::into),
+ warning_background: vscode_colors
+ .editor_warning
+ .background
+ .as_deref()
+ .map(Into::into),
+ warning_border: vscode_colors
+ .editor_warning
+ .border
+ .as_deref()
+ .map(Into::into),
..Default::default()
})
}
@@ -125,89 +172,221 @@ impl VsCodeThemeConverter {
.cloned();
Ok(ThemeColorsContent {
- border: vscode_panel_border.clone(),
- border_variant: vscode_panel_border.clone(),
- border_focused: vscode_colors.focus_border.clone(),
- border_selected: vscode_panel_border.clone(),
- border_transparent: vscode_panel_border.clone(),
- border_disabled: vscode_panel_border.clone(),
- elevated_surface_background: vscode_colors.dropdown.background.clone(),
- surface_background: vscode_colors.panel.background.clone(),
- background: vscode_editor_background.clone(),
- element_background: vscode_colors.button.background.clone(),
- element_hover: vscode_colors.list.hover_background.clone(),
- element_selected: vscode_colors.list.active_selection_background.clone(),
- drop_target_background: vscode_colors.list.drop_background.clone(),
- ghost_element_hover: vscode_colors.list.hover_background.clone(),
- ghost_element_selected: vscode_colors.list.active_selection_background.clone(),
+ border: vscode_panel_border.as_deref().map(Into::into),
+ border_variant: vscode_panel_border.as_deref().map(Into::into),
+ border_focused: vscode_colors.focus_border.as_deref().map(Into::into),
+ border_selected: vscode_panel_border.as_deref().map(Into::into),
+ border_transparent: vscode_panel_border.as_deref().map(Into::into),
+ border_disabled: vscode_panel_border.as_deref().map(Into::into),
+ elevated_surface_background: vscode_colors
+ .dropdown
+ .background
+ .as_deref()
+ .map(Into::into),
+ surface_background: vscode_colors.panel.background.as_deref().map(Into::into),
+ background: vscode_editor_background.as_deref().map(Into::into),
+ element_background: vscode_colors.button.background.as_deref().map(Into::into),
+ element_hover: vscode_colors
+ .list
+ .hover_background
+ .as_deref()
+ .map(Into::into),
+ element_selected: vscode_colors
+ .list
+ .active_selection_background
+ .as_deref()
+ .map(Into::into),
+ drop_target_background: vscode_colors
+ .list
+ .drop_background
+ .as_deref()
+ .map(Into::into),
+ ghost_element_hover: vscode_colors
+ .list
+ .hover_background
+ .as_deref()
+ .map(Into::into),
+ ghost_element_selected: vscode_colors
+ .list
+ .active_selection_background
+ .as_deref()
+ .map(Into::into),
text: vscode_colors
.foreground
.clone()
- .or(vscode_token_colors_foreground.clone()),
- text_muted: vscode_colors.tab.inactive_foreground.clone(),
- status_bar_background: vscode_colors.status_bar.background.clone(),
- title_bar_background: vscode_colors.title_bar.active_background.clone(),
+ .or(vscode_token_colors_foreground.clone())
+ .as_deref()
+ .map(Into::into),
+ text_muted: vscode_colors
+ .tab
+ .inactive_foreground
+ .as_deref()
+ .map(Into::into),
+ status_bar_background: vscode_colors
+ .status_bar
+ .background
+ .as_deref()
+ .map(Into::into),
+ title_bar_background: vscode_colors
+ .title_bar
+ .active_background
+ .as_deref()
+ .map(Into::into),
toolbar_background: vscode_colors
.breadcrumb
.background
.clone()
- .or(vscode_editor_background.clone()),
- tab_bar_background: vscode_colors.editor_group_header.tabs_background.clone(),
- tab_inactive_background: vscode_tab_inactive_background.clone(),
+ .or(vscode_editor_background.clone())
+ .as_deref()
+ .map(Into::into),
+ tab_bar_background: vscode_colors
+ .editor_group_header
+ .tabs_background
+ .as_deref()
+ .map(Into::into),
+ tab_inactive_background: vscode_tab_inactive_background.as_deref().map(Into::into),
tab_active_background: vscode_colors
.tab
.active_background
.clone()
- .or(vscode_tab_inactive_background),
- search_match_background: vscode_colors.editor.find_match_background.clone(),
- panel_background: vscode_colors.panel.background.clone(),
- pane_group_border: vscode_colors.editor_group.border.clone(),
- scrollbar_thumb_background: vscode_scrollbar_slider_background.clone(),
+ .or(vscode_tab_inactive_background)
+ .as_deref()
+ .map(Into::into),
+ search_match_background: vscode_colors
+ .editor
+ .find_match_background
+ .as_deref()
+ .map(Into::into),
+ panel_background: vscode_colors.panel.background.as_deref().map(Into::into),
+ pane_group_border: vscode_colors.editor_group.border.as_deref().map(Into::into),
+ scrollbar_thumb_background: vscode_scrollbar_slider_background
+ .as_deref()
+ .map(Into::into),
scrollbar_thumb_hover_background: vscode_colors
.scrollbar_slider
.hover_background
- .clone(),
+ .as_deref()
+ .map(Into::into),
scrollbar_thumb_active_background: vscode_colors
.scrollbar_slider
.active_background
- .clone(),
- scrollbar_thumb_border: vscode_scrollbar_slider_background,
- scrollbar_track_background: vscode_editor_background.clone(),
- scrollbar_track_border: vscode_colors.editor_overview_ruler.border.clone(),
- minimap_thumb_background: vscode_colors.minimap_slider.background.clone(),
- minimap_thumb_hover_background: vscode_colors.minimap_slider.hover_background.clone(),
- minimap_thumb_active_background: vscode_colors.minimap_slider.active_background.clone(),
- editor_foreground: vscode_editor_foreground.or(vscode_token_colors_foreground),
- editor_background: vscode_editor_background.clone(),
- editor_gutter_background: vscode_editor_background,
- editor_active_line_background: vscode_colors.editor.line_highlight_background.clone(),
- editor_line_number: vscode_colors.editor_line_number.foreground.clone(),
- editor_active_line_number: vscode_colors.editor.foreground.clone(),
- editor_wrap_guide: vscode_panel_border.clone(),
- editor_active_wrap_guide: vscode_panel_border,
+ .as_deref()
+ .map(Into::into),
+ scrollbar_thumb_border: vscode_scrollbar_slider_background
+ .as_deref()
+ .map(Into::into),
+ scrollbar_track_background: vscode_editor_background.as_deref().map(Into::into),
+ scrollbar_track_border: vscode_colors
+ .editor_overview_ruler
+ .border
+ .as_deref()
+ .map(Into::into),
+ minimap_thumb_background: vscode_colors
+ .minimap_slider
+ .background
+ .as_deref()
+ .map(Into::into),
+ minimap_thumb_hover_background: vscode_colors
+ .minimap_slider
+ .hover_background
+ .as_deref()
+ .map(Into::into),
+ minimap_thumb_active_background: vscode_colors
+ .minimap_slider
+ .active_background
+ .as_deref()
+ .map(Into::into),
+ editor_foreground: vscode_editor_foreground
+ .or(vscode_token_colors_foreground)
+ .as_deref()
+ .map(Into::into),
+ editor_background: vscode_editor_background.as_deref().map(Into::into),
+ editor_gutter_background: vscode_editor_background.as_deref().map(Into::into),
+ editor_active_line_background: vscode_colors
+ .editor
+ .line_highlight_background
+ .as_deref()
+ .map(Into::into),
+ editor_line_number: vscode_colors
+ .editor_line_number
+ .foreground
+ .as_deref()
+ .map(Into::into),
+ editor_active_line_number: vscode_colors.editor.foreground.as_deref().map(Into::into),
+ editor_wrap_guide: vscode_panel_border.as_deref().map(Into::into),
+ editor_active_wrap_guide: vscode_panel_border.as_deref().map(Into::into),
editor_document_highlight_bracket_background: vscode_colors
.editor_bracket_match
.background
- .clone(),
- terminal_background: vscode_colors.terminal.background.clone(),
- terminal_ansi_black: vscode_colors.terminal.ansi_black.clone(),
- terminal_ansi_bright_black: vscode_colors.terminal.ansi_bright_black.clone(),
- terminal_ansi_red: vscode_colors.terminal.ansi_red.clone(),
- terminal_ansi_bright_red: vscode_colors.terminal.ansi_bright_red.clone(),
- terminal_ansi_green: vscode_colors.terminal.ansi_green.clone(),
- terminal_ansi_bright_green: vscode_colors.terminal.ansi_bright_green.clone(),
- terminal_ansi_yellow: vscode_colors.terminal.ansi_yellow.clone(),
- terminal_ansi_bright_yellow: vscode_colors.terminal.ansi_bright_yellow.clone(),
- terminal_ansi_blue: vscode_colors.terminal.ansi_blue.clone(),
- terminal_ansi_bright_blue: vscode_colors.terminal.ansi_bright_blue.clone(),
- terminal_ansi_magenta: vscode_colors.terminal.ansi_magenta.clone(),
- terminal_ansi_bright_magenta: vscode_colors.terminal.ansi_bright_magenta.clone(),
- terminal_ansi_cyan: vscode_colors.terminal.ansi_cyan.clone(),
- terminal_ansi_bright_cyan: vscode_colors.terminal.ansi_bright_cyan.clone(),
- terminal_ansi_white: vscode_colors.terminal.ansi_white.clone(),
- terminal_ansi_bright_white: vscode_colors.terminal.ansi_bright_white.clone(),
- link_text_hover: vscode_colors.text_link.active_foreground.clone(),
- vim_yank_background: vscode_colors.editor.range_highlight_background.clone(),
+ .as_deref()
+ .map(Into::into),
+ terminal_background: vscode_colors.terminal.background.as_deref().map(Into::into),
+ terminal_ansi_black: vscode_colors.terminal.ansi_black.as_deref().map(Into::into),
+ terminal_ansi_bright_black: vscode_colors
+ .terminal
+ .ansi_bright_black
+ .as_deref()
+ .map(Into::into),
+ terminal_ansi_red: vscode_colors.terminal.ansi_red.as_deref().map(Into::into),
+ terminal_ansi_bright_red: vscode_colors
+ .terminal
+ .ansi_bright_red
+ .as_deref()
+ .map(Into::into),
+ terminal_ansi_green: vscode_colors.terminal.ansi_green.as_deref().map(Into::into),
+ terminal_ansi_bright_green: vscode_colors
+ .terminal
+ .ansi_bright_green
+ .as_deref()
+ .map(Into::into),
+ terminal_ansi_yellow: vscode_colors
+ .terminal
+ .ansi_yellow
+ .as_deref()
+ .map(Into::into),
+ terminal_ansi_bright_yellow: vscode_colors
+ .terminal
+ .ansi_bright_yellow
+ .as_deref()
+ .map(Into::into),
+ terminal_ansi_blue: vscode_colors.terminal.ansi_blue.as_deref().map(Into::into),
+ terminal_ansi_bright_blue: vscode_colors
+ .terminal
+ .ansi_bright_blue
+ .as_deref()
+ .map(Into::into),
+ terminal_ansi_magenta: vscode_colors
+ .terminal
+ .ansi_magenta
+ .as_deref()
+ .map(Into::into),
+ terminal_ansi_bright_magenta: vscode_colors
+ .terminal
+ .ansi_bright_magenta
+ .as_deref()
+ .map(Into::into),
+ terminal_ansi_cyan: vscode_colors.terminal.ansi_cyan.as_deref().map(Into::into),
+ terminal_ansi_bright_cyan: vscode_colors
+ .terminal
+ .ansi_bright_cyan
+ .as_deref()
+ .map(Into::into),
+ terminal_ansi_white: vscode_colors.terminal.ansi_white.as_deref().map(Into::into),
+ terminal_ansi_bright_white: vscode_colors
+ .terminal
+ .ansi_bright_white
+ .as_deref()
+ .map(Into::into),
+ link_text_hover: vscode_colors
+ .text_link
+ .active_foreground
+ .as_deref()
+ .map(Into::into),
+ vim_yank_background: vscode_colors
+ .editor
+ .range_highlight_background
+ .as_deref()
+ .map(Into::into),
..Default::default()
})
}
@@ -251,8 +430,8 @@ impl VsCodeThemeConverter {
);
let highlight_style = HighlightStyleContent {
- color: token_color.settings.foreground.clone(),
- background_color: token_color.settings.background.clone(),
+ color: token_color.settings.foreground.as_deref().map(Into::into),
+ background_color: token_color.settings.background.as_deref().map(Into::into),
font_style: token_color
.settings
.font_style
diff --git a/crates/theme_settings/src/schema.rs b/crates/theme_settings/src/schema.rs
index 3f4a20adbfb..904c2167154 100644
--- a/crates/theme_settings/src/schema.rs
+++ b/crates/theme_settings/src/schema.rs
@@ -919,14 +919,14 @@ mod tests {
#[test]
fn explicit_diff_hunk_colors_take_precedence_over_fallbacks() {
let mut colors = ThemeColorsContent::default();
- colors.editor_diff_hunk_added_background = Some("#112233".to_string());
- colors.editor_diff_hunk_added_hollow_background = Some("#223344".to_string());
- colors.editor_diff_hunk_added_hollow_border = Some("#334455".to_string());
- colors.editor_diff_hunk_deleted_background = Some("#445566".to_string());
- colors.editor_diff_hunk_deleted_hollow_background = Some("#556677".to_string());
- colors.editor_diff_hunk_deleted_hollow_border = Some("#667788".to_string());
- colors.version_control_added = Some("#00ff00".to_string());
- colors.version_control_deleted = Some("#ff0000".to_string());
+ colors.editor_diff_hunk_added_background = Some("#112233".into());
+ colors.editor_diff_hunk_added_hollow_background = Some("#223344".into());
+ colors.editor_diff_hunk_added_hollow_border = Some("#334455".into());
+ colors.editor_diff_hunk_deleted_background = Some("#445566".into());
+ colors.editor_diff_hunk_deleted_hollow_background = Some("#556677".into());
+ colors.editor_diff_hunk_deleted_hollow_border = Some("#667788".into());
+ colors.version_control_added = Some("#00ff00".into());
+ colors.version_control_deleted = Some("#ff0000".into());
let refinement = theme_colors_refinement(
&colors,
@@ -963,8 +963,8 @@ mod tests {
#[test]
fn diff_hunk_colors_fallback_to_version_control_colors() {
let mut colors = ThemeColorsContent::default();
- colors.version_control_added = Some("#00ff00".to_string());
- colors.version_control_deleted = Some("#ff0000".to_string());
+ colors.version_control_added = Some("#00ff00".into());
+ colors.version_control_deleted = Some("#ff0000".into());
let refinement = theme_colors_refinement(
&colors,
@@ -1004,7 +1004,7 @@ mod tests {
#[test]
fn diff_hunk_opacity_fallbacks_use_correct_values_for_light_and_dark_themes() {
let mut colors = ThemeColorsContent::default();
- colors.version_control_added = Some("#00ff00".to_string());
+ colors.version_control_added = Some("#00ff00".into());
let light_refinement = theme_colors_refinement(
&colors,
@@ -1091,7 +1091,7 @@ mod tests {
let override_refinement = theme_colors_refinement(
&ThemeColorsContent {
- vim_helix_jump_label_foreground: Some("#00ff00".to_string()),
+ vim_helix_jump_label_foreground: Some("#00ff00".into()),
..Default::default()
},
&status_colors,
diff --git a/crates/vim/src/helix.rs b/crates/vim/src/helix.rs
index 6408fd7a388..df1cd9606df 100644
--- a/crates/vim/src/helix.rs
+++ b/crates/vim/src/helix.rs
@@ -4035,7 +4035,7 @@ mod test {
store.update_user_settings(cx, |settings| {
settings.theme.experimental_theme_overrides = Some(ThemeStyleContent {
colors: ThemeColorsContent {
- vim_helix_jump_label_foreground: Some("#00ff00".to_string()),
+ vim_helix_jump_label_foreground: Some("#00ff00".into()),
..Default::default()
},
..Default::default()