1use std::sync::Arc;
2
3use gpui::{hsla, FontStyle, FontWeight, HighlightStyle, Hsla, WindowBackgroundAppearance};
4
5use crate::{
6 default_color_scales, AccentColors, Appearance, PlayerColors, StatusColors,
7 StatusColorsRefinement, SyntaxTheme, SystemColors, Theme, ThemeColors, ThemeFamily,
8 ThemeStyles,
9};
10
11/// The default theme family for Zed.
12///
13/// This is used to construct the default theme fallback values, as well as to
14/// have a theme available at compile time for tests.
15pub fn zed_default_themes() -> ThemeFamily {
16 ThemeFamily {
17 id: "zed-default".to_string(),
18 name: "Zed Default".into(),
19 author: "".into(),
20 themes: vec![zed_default_dark()],
21 scales: default_color_scales(),
22 }
23}
24
25// If a theme customizes a foreground version of a status color, but does not
26// customize the background color, then use a partly-transparent version of the
27// foreground color for the background color.
28pub(crate) fn apply_status_color_defaults(status: &mut StatusColorsRefinement) {
29 for (fg_color, bg_color) in [
30 (&status.deleted, &mut status.deleted_background),
31 (&status.created, &mut status.created_background),
32 (&status.modified, &mut status.modified_background),
33 (&status.conflict, &mut status.conflict_background),
34 (&status.error, &mut status.error_background),
35 (&status.hidden, &mut status.hidden_background),
36 ] {
37 if bg_color.is_none() {
38 if let Some(fg_color) = fg_color {
39 *bg_color = Some(fg_color.opacity(0.25));
40 }
41 }
42 }
43}
44
45pub(crate) fn zed_default_dark() -> Theme {
46 let bg = hsla(215. / 360., 12. / 100., 15. / 100., 1.);
47 let editor = hsla(220. / 360., 12. / 100., 18. / 100., 1.);
48 let elevated_surface = hsla(225. / 360., 12. / 100., 17. / 100., 1.);
49
50 let blue = hsla(207.8 / 360., 81. / 100., 66. / 100., 1.0);
51 let gray = hsla(218.8 / 360., 10. / 100., 40. / 100., 1.0);
52 let green = hsla(95. / 360., 38. / 100., 62. / 100., 1.0);
53 let orange = hsla(29. / 360., 54. / 100., 61. / 100., 1.0);
54 let purple = hsla(286. / 360., 51. / 100., 64. / 100., 1.0);
55 let red = hsla(355. / 360., 65. / 100., 65. / 100., 1.0);
56 let teal = hsla(187. / 360., 47. / 100., 55. / 100., 1.0);
57 let yellow = hsla(39. / 360., 67. / 100., 69. / 100., 1.0);
58
59 const ADDED_COLOR: Hsla = Hsla {
60 h: 142. / 360.,
61 s: 0.68,
62 l: 0.45,
63 a: 1.0,
64 };
65 const MODIFIED_COLOR: Hsla = Hsla {
66 h: 48. / 360.,
67 s: 0.76,
68 l: 0.47,
69 a: 1.0,
70 };
71 const REMOVED_COLOR: Hsla = Hsla {
72 h: 355. / 360.,
73 s: 0.65,
74 l: 0.65,
75 a: 1.0,
76 };
77
78 Theme {
79 id: "one_dark".to_string(),
80 name: "One Dark".into(),
81 appearance: Appearance::Dark,
82 styles: ThemeStyles {
83 window_background_appearance: WindowBackgroundAppearance::Opaque,
84 system: SystemColors::default(),
85 accents: AccentColors(vec![blue, orange, purple, teal, red, green, yellow]),
86 colors: ThemeColors {
87 border: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
88 border_variant: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
89 border_focused: hsla(223. / 360., 78. / 100., 65. / 100., 1.),
90 border_selected: hsla(222.6 / 360., 77.5 / 100., 65.1 / 100., 1.0),
91 border_transparent: SystemColors::default().transparent,
92 border_disabled: hsla(222.0 / 360., 11.6 / 100., 33.7 / 100., 1.0),
93 elevated_surface_background: elevated_surface,
94 surface_background: bg,
95 background: bg,
96 element_background: hsla(223.0 / 360., 13. / 100., 21. / 100., 1.0),
97 element_hover: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 1.0),
98 element_active: hsla(220.0 / 360., 11.8 / 100., 20.0 / 100., 1.0),
99 element_selected: hsla(224.0 / 360., 11.3 / 100., 26.1 / 100., 1.0),
100 element_disabled: SystemColors::default().transparent,
101 drop_target_background: hsla(220.0 / 360., 8.3 / 100., 21.4 / 100., 1.0),
102 ghost_element_background: SystemColors::default().transparent,
103 ghost_element_hover: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 1.0),
104 ghost_element_active: hsla(220.0 / 360., 11.8 / 100., 20.0 / 100., 1.0),
105 ghost_element_selected: hsla(224.0 / 360., 11.3 / 100., 26.1 / 100., 1.0),
106 ghost_element_disabled: SystemColors::default().transparent,
107 text: hsla(221. / 360., 11. / 100., 86. / 100., 1.0),
108 text_muted: hsla(218.0 / 360., 7. / 100., 46. / 100., 1.0),
109 text_placeholder: hsla(220.0 / 360., 6.6 / 100., 44.5 / 100., 1.0),
110 text_disabled: hsla(220.0 / 360., 6.6 / 100., 44.5 / 100., 1.0),
111 text_accent: hsla(222.6 / 360., 77.5 / 100., 65.1 / 100., 1.0),
112 icon: hsla(222.9 / 360., 9.9 / 100., 86.1 / 100., 1.0),
113 icon_muted: hsla(220.0 / 360., 12.1 / 100., 66.1 / 100., 1.0),
114 icon_disabled: hsla(220.0 / 360., 6.4 / 100., 45.7 / 100., 1.0),
115 icon_placeholder: hsla(220.0 / 360., 6.4 / 100., 45.7 / 100., 1.0),
116 icon_accent: blue,
117 debugger_accent: red,
118 status_bar_background: bg,
119 title_bar_background: bg,
120 title_bar_inactive_background: bg,
121 toolbar_background: editor,
122 tab_bar_background: bg,
123 tab_inactive_background: bg,
124 tab_active_background: editor,
125 search_match_background: bg,
126
127 editor_background: editor,
128 editor_gutter_background: editor,
129 editor_subheader_background: bg,
130 editor_active_line_background: hsla(222.9 / 360., 13.5 / 100., 20.4 / 100., 1.0),
131 editor_highlighted_line_background: hsla(207.8 / 360., 81. / 100., 66. / 100., 0.1),
132 editor_debugger_active_line_background: hsla(
133 207.8 / 360.,
134 81. / 100.,
135 66. / 100.,
136 0.2,
137 ),
138 editor_line_number: hsla(222.0 / 360., 11.5 / 100., 34.1 / 100., 1.0),
139 editor_active_line_number: hsla(216.0 / 360., 5.9 / 100., 49.6 / 100., 1.0),
140 editor_hover_line_number: hsla(216.0 / 360., 5.9 / 100., 56.7 / 100., 1.0),
141 editor_invisible: hsla(222.0 / 360., 11.5 / 100., 34.1 / 100., 1.0),
142 editor_wrap_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
143 editor_active_wrap_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
144 editor_indent_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
145 editor_indent_guide_active: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
146 editor_document_highlight_read_background: hsla(
147 207.8 / 360.,
148 81. / 100.,
149 66. / 100.,
150 0.2,
151 ),
152 editor_document_highlight_write_background: gpui::red(),
153 editor_document_highlight_bracket_background: gpui::green(),
154
155 terminal_background: bg,
156 // todo("Use one colors for terminal")
157 terminal_ansi_background: crate::black().dark().step_12(),
158 terminal_foreground: crate::white().dark().step_12(),
159 terminal_bright_foreground: crate::white().dark().step_11(),
160 terminal_dim_foreground: crate::white().dark().step_10(),
161 terminal_ansi_black: crate::black().dark().step_12(),
162 terminal_ansi_red: crate::red().dark().step_11(),
163 terminal_ansi_green: crate::green().dark().step_11(),
164 terminal_ansi_yellow: crate::yellow().dark().step_11(),
165 terminal_ansi_blue: crate::blue().dark().step_11(),
166 terminal_ansi_magenta: crate::violet().dark().step_11(),
167 terminal_ansi_cyan: crate::cyan().dark().step_11(),
168 terminal_ansi_white: crate::neutral().dark().step_12(),
169 terminal_ansi_bright_black: crate::black().dark().step_11(),
170 terminal_ansi_bright_red: crate::red().dark().step_10(),
171 terminal_ansi_bright_green: crate::green().dark().step_10(),
172 terminal_ansi_bright_yellow: crate::yellow().dark().step_10(),
173 terminal_ansi_bright_blue: crate::blue().dark().step_10(),
174 terminal_ansi_bright_magenta: crate::violet().dark().step_10(),
175 terminal_ansi_bright_cyan: crate::cyan().dark().step_10(),
176 terminal_ansi_bright_white: crate::neutral().dark().step_11(),
177 terminal_ansi_dim_black: crate::black().dark().step_10(),
178 terminal_ansi_dim_red: crate::red().dark().step_9(),
179 terminal_ansi_dim_green: crate::green().dark().step_9(),
180 terminal_ansi_dim_yellow: crate::yellow().dark().step_9(),
181 terminal_ansi_dim_blue: crate::blue().dark().step_9(),
182 terminal_ansi_dim_magenta: crate::violet().dark().step_9(),
183 terminal_ansi_dim_cyan: crate::cyan().dark().step_9(),
184 terminal_ansi_dim_white: crate::neutral().dark().step_10(),
185 panel_background: bg,
186 panel_focused_border: blue,
187 panel_indent_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
188 panel_indent_guide_hover: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
189 panel_indent_guide_active: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
190 pane_focused_border: blue,
191 pane_group_border: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
192 scrollbar_thumb_background: gpui::transparent_black(),
193 scrollbar_thumb_hover_background: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 1.0),
194 scrollbar_thumb_border: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
195 scrollbar_track_background: gpui::transparent_black(),
196 scrollbar_track_border: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
197 editor_foreground: hsla(218. / 360., 14. / 100., 71. / 100., 1.),
198 link_text_hover: blue,
199 version_control_added: ADDED_COLOR,
200 version_control_deleted: REMOVED_COLOR,
201 version_control_modified: MODIFIED_COLOR,
202 version_control_renamed: MODIFIED_COLOR,
203 version_control_conflict: crate::orange().light().step_12(),
204 version_control_ignored: crate::gray().light().step_12(),
205 },
206 status: StatusColors {
207 conflict: yellow,
208 conflict_background: yellow,
209 conflict_border: yellow,
210 created: green,
211 created_background: green,
212 created_border: green,
213 deleted: red,
214 deleted_background: red,
215 deleted_border: red,
216 error: red,
217 error_background: red,
218 error_border: red,
219 hidden: gray,
220 hidden_background: gray,
221 hidden_border: gray,
222 hint: blue,
223 hint_background: blue,
224 hint_border: blue,
225 ignored: gray,
226 ignored_background: gray,
227 ignored_border: gray,
228 info: blue,
229 info_background: blue,
230 info_border: blue,
231 modified: yellow,
232 modified_background: yellow,
233 modified_border: yellow,
234 predictive: gray,
235 predictive_background: gray,
236 predictive_border: gray,
237 renamed: blue,
238 renamed_background: blue,
239 renamed_border: blue,
240 success: green,
241 success_background: green,
242 success_border: green,
243 unreachable: gray,
244 unreachable_background: gray,
245 unreachable_border: gray,
246 warning: yellow,
247 warning_background: yellow,
248 warning_border: yellow,
249 },
250 player: PlayerColors::dark(),
251 syntax: Arc::new(SyntaxTheme {
252 highlights: vec![
253 ("attribute".into(), purple.into()),
254 ("boolean".into(), orange.into()),
255 ("comment".into(), gray.into()),
256 ("comment.doc".into(), gray.into()),
257 ("constant".into(), yellow.into()),
258 ("constructor".into(), blue.into()),
259 ("embedded".into(), HighlightStyle::default()),
260 (
261 "emphasis".into(),
262 HighlightStyle {
263 font_style: Some(FontStyle::Italic),
264 ..HighlightStyle::default()
265 },
266 ),
267 (
268 "emphasis.strong".into(),
269 HighlightStyle {
270 font_weight: Some(FontWeight::BOLD),
271 ..HighlightStyle::default()
272 },
273 ),
274 ("enum".into(), HighlightStyle::default()),
275 ("function".into(), blue.into()),
276 ("function.method".into(), blue.into()),
277 ("function.definition".into(), blue.into()),
278 ("hint".into(), blue.into()),
279 ("keyword".into(), purple.into()),
280 ("label".into(), HighlightStyle::default()),
281 ("link_text".into(), blue.into()),
282 (
283 "link_uri".into(),
284 HighlightStyle {
285 color: Some(teal),
286 font_style: Some(FontStyle::Italic),
287 ..HighlightStyle::default()
288 },
289 ),
290 ("number".into(), orange.into()),
291 ("operator".into(), HighlightStyle::default()),
292 ("predictive".into(), HighlightStyle::default()),
293 ("preproc".into(), HighlightStyle::default()),
294 ("primary".into(), HighlightStyle::default()),
295 ("property".into(), red.into()),
296 ("punctuation".into(), HighlightStyle::default()),
297 ("punctuation.bracket".into(), HighlightStyle::default()),
298 ("punctuation.delimiter".into(), HighlightStyle::default()),
299 ("punctuation.list_marker".into(), HighlightStyle::default()),
300 ("punctuation.special".into(), HighlightStyle::default()),
301 ("string".into(), green.into()),
302 ("string.escape".into(), HighlightStyle::default()),
303 ("string.regex".into(), red.into()),
304 ("string.special".into(), HighlightStyle::default()),
305 ("string.special.symbol".into(), HighlightStyle::default()),
306 ("tag".into(), HighlightStyle::default()),
307 ("text.literal".into(), HighlightStyle::default()),
308 ("title".into(), HighlightStyle::default()),
309 ("type".into(), teal.into()),
310 ("variable".into(), HighlightStyle::default()),
311 ("variable.special".into(), red.into()),
312 ("variant".into(), HighlightStyle::default()),
313 ],
314 }),
315 },
316 }
317}