1use collections::HashMap;
2use gpui::SharedString;
3
4use crate::Appearance;
5
6/// A family of icon themes.
7pub struct IconThemeFamily {
8 /// The unique ID for the icon theme family.
9 pub id: String,
10 /// The name of the icon theme family.
11 pub name: SharedString,
12 /// The author of the icon theme family.
13 pub author: SharedString,
14 /// The list of icon themes in the family.
15 pub themes: Vec<IconTheme>,
16}
17
18/// An icon theme.
19#[derive(Debug, PartialEq)]
20pub struct IconTheme {
21 /// The unique ID for the icon theme.
22 pub id: String,
23 /// The name of the icon theme.
24 pub name: SharedString,
25 /// The appearance of the icon theme (e.g., light or dark).
26 pub appearance: Appearance,
27 /// The icons used for directories.
28 pub directory_icons: DirectoryIcons,
29 /// The icons used for chevrons.
30 pub chevron_icons: ChevronIcons,
31 /// The mapping of file types to icon definitions.
32 pub file_icons: HashMap<String, IconDefinition>,
33}
34
35/// The icons used for directories.
36#[derive(Debug, PartialEq)]
37pub struct DirectoryIcons {
38 /// The path to the icon to use for a collapsed directory.
39 pub collapsed: Option<SharedString>,
40 /// The path to the icon to use for an expanded directory.
41 pub expanded: Option<SharedString>,
42}
43
44/// The icons used for chevrons.
45#[derive(Debug, PartialEq)]
46pub struct ChevronIcons {
47 /// The path to the icon to use for a collapsed chevron.
48 pub collapsed: Option<SharedString>,
49 /// The path to the icon to use for an expanded chevron.
50 pub expanded: Option<SharedString>,
51}
52
53/// An icon definition.
54#[derive(Debug, PartialEq)]
55pub struct IconDefinition {
56 /// The path to the icon file.
57 pub path: SharedString,
58}
59
60/// A mapping of a file type identifier to its corresponding icon.
61const FILE_ICONS: &[(&str, &str)] = &[
62 ("astro", "icons/file_icons/astro.svg"),
63 ("audio", "icons/file_icons/audio.svg"),
64 ("bun", "icons/file_icons/bun.svg"),
65 ("c", "icons/file_icons/c.svg"),
66 ("code", "icons/file_icons/code.svg"),
67 ("coffeescript", "icons/file_icons/coffeescript.svg"),
68 ("cpp", "icons/file_icons/cpp.svg"),
69 ("css", "icons/file_icons/css.svg"),
70 ("dart", "icons/file_icons/dart.svg"),
71 ("default", "icons/file_icons/file.svg"),
72 ("diff", "icons/file_icons/diff.svg"),
73 ("docker", "icons/file_icons/docker.svg"),
74 ("document", "icons/file_icons/book.svg"),
75 ("elixir", "icons/file_icons/elixir.svg"),
76 ("elm", "icons/file_icons/elm.svg"),
77 ("erlang", "icons/file_icons/erlang.svg"),
78 ("eslint", "icons/file_icons/eslint.svg"),
79 ("font", "icons/file_icons/font.svg"),
80 ("fsharp", "icons/file_icons/fsharp.svg"),
81 ("gleam", "icons/file_icons/gleam.svg"),
82 ("go", "icons/file_icons/go.svg"),
83 ("graphql", "icons/file_icons/graphql.svg"),
84 ("haskell", "icons/file_icons/haskell.svg"),
85 ("hcl", "icons/file_icons/hcl.svg"),
86 ("heroku", "icons/file_icons/heroku.svg"),
87 ("image", "icons/file_icons/image.svg"),
88 ("java", "icons/file_icons/java.svg"),
89 ("javascript", "icons/file_icons/javascript.svg"),
90 ("julia", "icons/file_icons/julia.svg"),
91 ("kotlin", "icons/file_icons/kotlin.svg"),
92 ("lock", "icons/file_icons/lock.svg"),
93 ("log", "icons/file_icons/info.svg"),
94 ("lua", "icons/file_icons/lua.svg"),
95 ("metal", "icons/file_icons/metal.svg"),
96 ("nim", "icons/file_icons/nim.svg"),
97 ("nix", "icons/file_icons/nix.svg"),
98 ("ocaml", "icons/file_icons/ocaml.svg"),
99 ("phoenix", "icons/file_icons/phoenix.svg"),
100 ("php", "icons/file_icons/php.svg"),
101 ("prettier", "icons/file_icons/prettier.svg"),
102 ("prisma", "icons/file_icons/prisma.svg"),
103 ("python", "icons/file_icons/python.svg"),
104 ("r", "icons/file_icons/r.svg"),
105 ("react", "icons/file_icons/react.svg"),
106 ("roc", "icons/file_icons/roc.svg"),
107 ("ruby", "icons/file_icons/ruby.svg"),
108 ("rust", "icons/file_icons/rust.svg"),
109 ("sass", "icons/file_icons/sass.svg"),
110 ("scala", "icons/file_icons/scala.svg"),
111 ("settings", "icons/file_icons/settings.svg"),
112 ("storage", "icons/file_icons/database.svg"),
113 ("swift", "icons/file_icons/swift.svg"),
114 ("tcl", "icons/file_icons/tcl.svg"),
115 ("template", "icons/file_icons/html.svg"),
116 ("terminal", "icons/file_icons/terminal.svg"),
117 ("terraform", "icons/file_icons/terraform.svg"),
118 ("toml", "icons/file_icons/toml.svg"),
119 ("typescript", "icons/file_icons/typescript.svg"),
120 ("v", "icons/file_icons/v.svg"),
121 ("vcs", "icons/file_icons/git.svg"),
122 ("video", "icons/file_icons/video.svg"),
123 ("vue", "icons/file_icons/vue.svg"),
124 ("zig", "icons/file_icons/zig.svg"),
125];
126
127/// The name of the default icon theme.
128pub(crate) const DEFAULT_ICON_THEME_NAME: &str = "Zed (Default)";
129
130/// Returns the default icon theme.
131pub fn default_icon_theme() -> IconTheme {
132 IconTheme {
133 id: "zed".into(),
134 name: DEFAULT_ICON_THEME_NAME.into(),
135 appearance: Appearance::Dark,
136 directory_icons: DirectoryIcons {
137 collapsed: Some("icons/file_icons/folder.svg".into()),
138 expanded: Some("icons/file_icons/folder_open.svg".into()),
139 },
140 chevron_icons: ChevronIcons {
141 collapsed: Some("icons/file_icons/chevron_right.svg".into()),
142 expanded: Some("icons/file_icons/chevron_down.svg".into()),
143 },
144 file_icons: HashMap::from_iter(FILE_ICONS.into_iter().map(|(ty, path)| {
145 (
146 ty.to_string(),
147 IconDefinition {
148 path: (*path).into(),
149 },
150 )
151 })),
152 }
153}