fallback_themes.rs

  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_invisible: hsla(222.0 / 360., 11.5 / 100., 34.1 / 100., 1.0),
 94                editor_wrap_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
 95                editor_active_wrap_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
 96                editor_indent_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
 97                editor_indent_guide_active: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
 98                editor_document_highlight_read_background: hsla(
 99                    207.8 / 360.,
100                    81. / 100.,
101                    66. / 100.,
102                    0.2,
103                ),
104                editor_document_highlight_write_background: gpui::red(),
105                editor_document_highlight_bracket_background: gpui::green(),
106
107                terminal_background: bg,
108                // todo("Use one colors for terminal")
109                terminal_ansi_background: crate::black().dark().step_12(),
110                terminal_foreground: crate::white().dark().step_12(),
111                terminal_bright_foreground: crate::white().dark().step_11(),
112                terminal_dim_foreground: crate::white().dark().step_10(),
113                terminal_ansi_black: crate::black().dark().step_12(),
114                terminal_ansi_red: crate::red().dark().step_11(),
115                terminal_ansi_green: crate::green().dark().step_11(),
116                terminal_ansi_yellow: crate::yellow().dark().step_11(),
117                terminal_ansi_blue: crate::blue().dark().step_11(),
118                terminal_ansi_magenta: crate::violet().dark().step_11(),
119                terminal_ansi_cyan: crate::cyan().dark().step_11(),
120                terminal_ansi_white: crate::neutral().dark().step_12(),
121                terminal_ansi_bright_black: crate::black().dark().step_11(),
122                terminal_ansi_bright_red: crate::red().dark().step_10(),
123                terminal_ansi_bright_green: crate::green().dark().step_10(),
124                terminal_ansi_bright_yellow: crate::yellow().dark().step_10(),
125                terminal_ansi_bright_blue: crate::blue().dark().step_10(),
126                terminal_ansi_bright_magenta: crate::violet().dark().step_10(),
127                terminal_ansi_bright_cyan: crate::cyan().dark().step_10(),
128                terminal_ansi_bright_white: crate::neutral().dark().step_11(),
129                terminal_ansi_dim_black: crate::black().dark().step_10(),
130                terminal_ansi_dim_red: crate::red().dark().step_9(),
131                terminal_ansi_dim_green: crate::green().dark().step_9(),
132                terminal_ansi_dim_yellow: crate::yellow().dark().step_9(),
133                terminal_ansi_dim_blue: crate::blue().dark().step_9(),
134                terminal_ansi_dim_magenta: crate::violet().dark().step_9(),
135                terminal_ansi_dim_cyan: crate::cyan().dark().step_9(),
136                terminal_ansi_dim_white: crate::neutral().dark().step_10(),
137                panel_background: bg,
138                panel_focused_border: blue,
139                panel_indent_guide: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
140                panel_indent_guide_hover: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
141                panel_indent_guide_active: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
142                pane_focused_border: blue,
143                pane_group_border: hsla(225. / 360., 13. / 100., 12. / 100., 1.),
144                scrollbar_thumb_background: gpui::transparent_black(),
145                scrollbar_thumb_hover_background: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 1.0),
146                scrollbar_thumb_border: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
147                scrollbar_track_background: gpui::transparent_black(),
148                scrollbar_track_border: hsla(228. / 360., 8. / 100., 25. / 100., 1.),
149                editor_foreground: hsla(218. / 360., 14. / 100., 71. / 100., 1.),
150                link_text_hover: blue,
151            },
152            status: StatusColors {
153                conflict: yellow,
154                conflict_background: yellow,
155                conflict_border: yellow,
156                created: green,
157                created_background: green,
158                created_border: green,
159                deleted: red,
160                deleted_background: red,
161                deleted_border: red,
162                error: red,
163                error_background: red,
164                error_border: red,
165                hidden: gray,
166                hidden_background: gray,
167                hidden_border: gray,
168                hint: blue,
169                hint_background: blue,
170                hint_border: blue,
171                ignored: gray,
172                ignored_background: gray,
173                ignored_border: gray,
174                info: blue,
175                info_background: blue,
176                info_border: blue,
177                modified: yellow,
178                modified_background: yellow,
179                modified_border: yellow,
180                predictive: gray,
181                predictive_background: gray,
182                predictive_border: gray,
183                renamed: blue,
184                renamed_background: blue,
185                renamed_border: blue,
186                success: green,
187                success_background: green,
188                success_border: green,
189                unreachable: gray,
190                unreachable_background: gray,
191                unreachable_border: gray,
192                warning: yellow,
193                warning_background: yellow,
194                warning_border: yellow,
195            },
196            player: PlayerColors::dark(),
197            syntax: Arc::new(SyntaxTheme {
198                highlights: vec![
199                    ("attribute".into(), purple.into()),
200                    ("boolean".into(), orange.into()),
201                    ("comment".into(), gray.into()),
202                    ("comment.doc".into(), gray.into()),
203                    ("constant".into(), yellow.into()),
204                    ("constructor".into(), blue.into()),
205                    ("embedded".into(), HighlightStyle::default()),
206                    (
207                        "emphasis".into(),
208                        HighlightStyle {
209                            font_style: Some(FontStyle::Italic),
210                            ..HighlightStyle::default()
211                        },
212                    ),
213                    (
214                        "emphasis.strong".into(),
215                        HighlightStyle {
216                            font_weight: Some(FontWeight::BOLD),
217                            ..HighlightStyle::default()
218                        },
219                    ),
220                    ("enum".into(), HighlightStyle::default()),
221                    ("function".into(), blue.into()),
222                    ("function.method".into(), blue.into()),
223                    ("function.definition".into(), blue.into()),
224                    ("hint".into(), blue.into()),
225                    ("keyword".into(), purple.into()),
226                    ("label".into(), HighlightStyle::default()),
227                    ("link_text".into(), blue.into()),
228                    (
229                        "link_uri".into(),
230                        HighlightStyle {
231                            color: Some(teal),
232                            font_style: Some(FontStyle::Italic),
233                            ..HighlightStyle::default()
234                        },
235                    ),
236                    ("number".into(), orange.into()),
237                    ("operator".into(), HighlightStyle::default()),
238                    ("predictive".into(), HighlightStyle::default()),
239                    ("preproc".into(), HighlightStyle::default()),
240                    ("primary".into(), HighlightStyle::default()),
241                    ("property".into(), red.into()),
242                    ("punctuation".into(), HighlightStyle::default()),
243                    ("punctuation.bracket".into(), HighlightStyle::default()),
244                    ("punctuation.delimiter".into(), HighlightStyle::default()),
245                    ("punctuation.list_marker".into(), HighlightStyle::default()),
246                    ("punctuation.special".into(), HighlightStyle::default()),
247                    ("string".into(), green.into()),
248                    ("string.escape".into(), HighlightStyle::default()),
249                    ("string.regex".into(), red.into()),
250                    ("string.special".into(), HighlightStyle::default()),
251                    ("string.special.symbol".into(), HighlightStyle::default()),
252                    ("tag".into(), HighlightStyle::default()),
253                    ("text.literal".into(), HighlightStyle::default()),
254                    ("title".into(), HighlightStyle::default()),
255                    ("type".into(), teal.into()),
256                    ("variable".into(), HighlightStyle::default()),
257                    ("variable.special".into(), red.into()),
258                    ("variant".into(), HighlightStyle::default()),
259                ],
260            }),
261        },
262    }
263}