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_importer: Format generated themes (#3255)

Marshall Bowers25876161f866
diff --git a/crates/theme2/src/registry.rs b/crates/theme2/src/registry.rs
index 37055da3618..c9ff549c156 100644
--- a/crates/theme2/src/registry.rs
+++ b/crates/theme2/src/registry.rs
@@ -52,7 +52,10 @@ impl ThemeRegistry {
status: StatusColors::default(),
git: GitStatusColors::default(),
player: PlayerColors::default(),
- syntax: SyntaxTheme::default_dark(),
+ syntax: match user_theme.appearance {
+ Appearance::Light => SyntaxTheme::default_light(),
+ Appearance::Dark => SyntaxTheme::default_dark(),
+ },
},
}
}));
@@ -81,7 +84,7 @@ impl Default for ThemeRegistry {
};
this.insert_theme_families([zed_pro_family()]);
- this.insert_user_theme_familes(crate::all_imported_themes());
+ this.insert_user_theme_familes(crate::all_user_themes());
this
}
diff --git a/crates/theme2/src/themes/andromeda.rs b/crates/theme2/src/themes/andromeda.rs
index 0d58dc9d56e..22a0a8741c4 100644
--- a/crates/theme2/src/themes/andromeda.rs
+++ b/crates/theme2/src/themes/andromeda.rs
@@ -1,3 +1,6 @@
+// This file was generated by the `theme_importer`.
+// Be careful when modifying it by hand.
+
use gpui::rgba;
use crate::{
diff --git a/crates/theme2/src/themes/ayu.rs b/crates/theme2/src/themes/ayu.rs
index 6298de40eec..8d79289046b 100644
--- a/crates/theme2/src/themes/ayu.rs
+++ b/crates/theme2/src/themes/ayu.rs
@@ -1,3 +1,6 @@
+// This file was generated by the `theme_importer`.
+// Be careful when modifying it by hand.
+
use gpui::rgba;
use crate::{
diff --git a/crates/theme2/src/themes/dracula.rs b/crates/theme2/src/themes/dracula.rs
index ea0e185e055..57c04851a5a 100644
--- a/crates/theme2/src/themes/dracula.rs
+++ b/crates/theme2/src/themes/dracula.rs
@@ -1,3 +1,6 @@
+// This file was generated by the `theme_importer`.
+// Be careful when modifying it by hand.
+
use gpui::rgba;
use crate::{
diff --git a/crates/theme2/src/themes/gruvbox.rs b/crates/theme2/src/themes/gruvbox.rs
index d06f53da675..2e79b250dac 100644
--- a/crates/theme2/src/themes/gruvbox.rs
+++ b/crates/theme2/src/themes/gruvbox.rs
@@ -1,3 +1,6 @@
+// This file was generated by the `theme_importer`.
+// Be careful when modifying it by hand.
+
use gpui::rgba;
use crate::{
diff --git a/crates/theme2/src/themes/mod.rs b/crates/theme2/src/themes/mod.rs
index b013a86989c..c48338b184a 100644
--- a/crates/theme2/src/themes/mod.rs
+++ b/crates/theme2/src/themes/mod.rs
@@ -1,3 +1,6 @@
+// This file was generated by the `theme_importer`.
+// Be careful when modifying it by hand.
+
mod andromeda;
mod ayu;
mod dracula;
@@ -24,7 +27,7 @@ pub use synthwave_84::*;
use crate::UserThemeFamily;
-pub(crate) fn all_imported_themes() -> Vec<UserThemeFamily> {
+pub(crate) fn all_user_themes() -> Vec<UserThemeFamily> {
vec![
rose_pine(),
night_owl(),
diff --git a/crates/theme2/src/themes/night_owl.rs b/crates/theme2/src/themes/night_owl.rs
index 4227c53b7a0..90ae45f8797 100644
--- a/crates/theme2/src/themes/night_owl.rs
+++ b/crates/theme2/src/themes/night_owl.rs
@@ -1,3 +1,6 @@
+// This file was generated by the `theme_importer`.
+// Be careful when modifying it by hand.
+
use gpui::rgba;
use crate::{
diff --git a/crates/theme2/src/themes/nord.rs b/crates/theme2/src/themes/nord.rs
index 981b460d10e..b1dedd6b16e 100644
--- a/crates/theme2/src/themes/nord.rs
+++ b/crates/theme2/src/themes/nord.rs
@@ -1,3 +1,6 @@
+// This file was generated by the `theme_importer`.
+// Be careful when modifying it by hand.
+
use gpui::rgba;
use crate::{
diff --git a/crates/theme2/src/themes/notctis.rs b/crates/theme2/src/themes/notctis.rs
index d8673824db6..f5b8f1207d4 100644
--- a/crates/theme2/src/themes/notctis.rs
+++ b/crates/theme2/src/themes/notctis.rs
@@ -1,3 +1,6 @@
+// This file was generated by the `theme_importer`.
+// Be careful when modifying it by hand.
+
use gpui::rgba;
use crate::{
diff --git a/crates/theme2/src/themes/palenight.rs b/crates/theme2/src/themes/palenight.rs
index 64df5d7ecbf..7ed27d3b757 100644
--- a/crates/theme2/src/themes/palenight.rs
+++ b/crates/theme2/src/themes/palenight.rs
@@ -1,3 +1,6 @@
+// This file was generated by the `theme_importer`.
+// Be careful when modifying it by hand.
+
use gpui::rgba;
use crate::{
diff --git a/crates/theme2/src/themes/rose_pine.rs b/crates/theme2/src/themes/rose_pine.rs
index 6fd641861a2..913af127fbb 100644
--- a/crates/theme2/src/themes/rose_pine.rs
+++ b/crates/theme2/src/themes/rose_pine.rs
@@ -1,3 +1,6 @@
+// This file was generated by the `theme_importer`.
+// Be careful when modifying it by hand.
+
use gpui::rgba;
use crate::{
diff --git a/crates/theme2/src/themes/solarized.rs b/crates/theme2/src/themes/solarized.rs
index 1f1c55f0817..0a78328e2e8 100644
--- a/crates/theme2/src/themes/solarized.rs
+++ b/crates/theme2/src/themes/solarized.rs
@@ -1,3 +1,6 @@
+// This file was generated by the `theme_importer`.
+// Be careful when modifying it by hand.
+
use gpui::rgba;
use crate::{
diff --git a/crates/theme2/src/themes/synthwave_84.rs b/crates/theme2/src/themes/synthwave_84.rs
index a512c087ff8..8c0520ee11d 100644
--- a/crates/theme2/src/themes/synthwave_84.rs
+++ b/crates/theme2/src/themes/synthwave_84.rs
@@ -1,3 +1,6 @@
+// This file was generated by the `theme_importer`.
+// Be careful when modifying it by hand.
+
use gpui::rgba;
use crate::{
diff --git a/crates/theme_importer/src/main.rs b/crates/theme_importer/src/main.rs
index e2ece76b128..b41994a0be0 100644
--- a/crates/theme_importer/src/main.rs
+++ b/crates/theme_importer/src/main.rs
@@ -5,6 +5,7 @@ mod vscode;
use std::fs::{self, File};
use std::io::Write;
use std::path::PathBuf;
+use std::process::Command;
use std::str::FromStr;
use anyhow::{anyhow, Context, Result};
@@ -152,6 +153,9 @@ fn main() -> Result<()> {
let theme_module = format!(
r#"
+ // This file was generated by the `theme_importer`.
+ // Be careful when modifying it by hand.
+
use gpui::rgba;
use crate::{{
@@ -174,7 +178,7 @@ fn main() -> Result<()> {
r#"
use crate::UserThemeFamily;
- pub(crate) fn all_imported_themes() -> Vec<UserThemeFamily> {{
+ pub(crate) fn all_user_themes() -> Vec<UserThemeFamily> {{
vec![{all_themes}]
}}
"#,
@@ -187,6 +191,9 @@ fn main() -> Result<()> {
let mod_rs_contents = format!(
r#"
+ // This file was generated by the `theme_importer`.
+ // Be careful when modifying it by hand.
+
{mod_statements}
{use_statements}
@@ -208,5 +215,23 @@ fn main() -> Result<()> {
mod_rs_file.write_all(mod_rs_contents.as_bytes())?;
+ println!("Formatting themes...");
+
+ let format_result = format_themes_crate()
+ // We need to format a second time to catch all of the formatting issues.
+ .and_then(|_| format_themes_crate());
+
+ if let Err(err) = format_result {
+ eprintln!("Failed to format themes: {}", err);
+ }
+
+ println!("Done!");
+
Ok(())
}
+
+fn format_themes_crate() -> std::io::Result<std::process::Output> {
+ Command::new("cargo")
+ .args(["fmt", "--package", "theme2"])
+ .output()
+}