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