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