fallback_themes.rs

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