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 ("bicep", "icons/file_icons/file.svg"),
65 ("bun", "icons/file_icons/bun.svg"),
66 ("c", "icons/file_icons/c.svg"),
67 ("code", "icons/file_icons/code.svg"),
68 ("coffeescript", "icons/file_icons/coffeescript.svg"),
69 ("cpp", "icons/file_icons/cpp.svg"),
70 ("crystal", "icons/file_icons/file.svg"),
71 ("csharp", "icons/file_icons/file.svg"),
72 ("css", "icons/file_icons/css.svg"),
73 ("cue", "icons/file_icons/file.svg"),
74 ("dart", "icons/file_icons/dart.svg"),
75 ("default", "icons/file_icons/file.svg"),
76 ("diff", "icons/file_icons/diff.svg"),
77 ("docker", "icons/file_icons/docker.svg"),
78 ("document", "icons/file_icons/book.svg"),
79 ("elixir", "icons/file_icons/elixir.svg"),
80 ("elm", "icons/file_icons/elm.svg"),
81 ("erlang", "icons/file_icons/erlang.svg"),
82 ("eslint", "icons/file_icons/eslint.svg"),
83 ("font", "icons/file_icons/font.svg"),
84 ("fsharp", "icons/file_icons/fsharp.svg"),
85 ("gitlab", "icons/file_icons/settings.svg"),
86 ("gleam", "icons/file_icons/gleam.svg"),
87 ("go", "icons/file_icons/go.svg"),
88 ("graphql", "icons/file_icons/graphql.svg"),
89 ("haskell", "icons/file_icons/haskell.svg"),
90 ("hcl", "icons/file_icons/hcl.svg"),
91 ("heroku", "icons/file_icons/heroku.svg"),
92 ("html", "icons/file_icons/html.svg"),
93 ("image", "icons/file_icons/image.svg"),
94 ("java", "icons/file_icons/java.svg"),
95 ("javascript", "icons/file_icons/javascript.svg"),
96 ("json", "icons/file_icons/code.svg"),
97 ("julia", "icons/file_icons/julia.svg"),
98 ("kotlin", "icons/file_icons/kotlin.svg"),
99 ("lock", "icons/file_icons/lock.svg"),
100 ("log", "icons/file_icons/info.svg"),
101 ("lua", "icons/file_icons/lua.svg"),
102 ("luau", "icons/file_icons/file.svg"),
103 ("markdown", "icons/file_icons/book.svg"),
104 ("metal", "icons/file_icons/metal.svg"),
105 ("nim", "icons/file_icons/nim.svg"),
106 ("nix", "icons/file_icons/nix.svg"),
107 ("ocaml", "icons/file_icons/ocaml.svg"),
108 ("phoenix", "icons/file_icons/phoenix.svg"),
109 ("php", "icons/file_icons/php.svg"),
110 ("prettier", "icons/file_icons/prettier.svg"),
111 ("prisma", "icons/file_icons/prisma.svg"),
112 ("python", "icons/file_icons/python.svg"),
113 ("r", "icons/file_icons/r.svg"),
114 ("react", "icons/file_icons/react.svg"),
115 ("roc", "icons/file_icons/roc.svg"),
116 ("ruby", "icons/file_icons/ruby.svg"),
117 ("rust", "icons/file_icons/rust.svg"),
118 ("sass", "icons/file_icons/sass.svg"),
119 ("scala", "icons/file_icons/scala.svg"),
120 ("settings", "icons/file_icons/settings.svg"),
121 ("solidity", "icons/file_icons/file.svg"),
122 ("storage", "icons/file_icons/database.svg"),
123 ("stylelint", "icons/file_icons/javascript.svg"),
124 ("svelte", "icons/file_icons/html.svg"),
125 ("swift", "icons/file_icons/swift.svg"),
126 ("tcl", "icons/file_icons/tcl.svg"),
127 ("template", "icons/file_icons/html.svg"),
128 ("terminal", "icons/file_icons/terminal.svg"),
129 ("terraform", "icons/file_icons/terraform.svg"),
130 ("toml", "icons/file_icons/toml.svg"),
131 ("typescript", "icons/file_icons/typescript.svg"),
132 ("v", "icons/file_icons/v.svg"),
133 ("vcs", "icons/file_icons/git.svg"),
134 ("video", "icons/file_icons/video.svg"),
135 ("vue", "icons/file_icons/vue.svg"),
136 ("zig", "icons/file_icons/zig.svg"),
137];
138
139/// The name of the default icon theme.
140pub(crate) const DEFAULT_ICON_THEME_NAME: &str = "Zed (Default)";
141
142/// Returns the default icon theme.
143pub fn default_icon_theme() -> IconTheme {
144 IconTheme {
145 id: "zed".into(),
146 name: DEFAULT_ICON_THEME_NAME.into(),
147 appearance: Appearance::Dark,
148 directory_icons: DirectoryIcons {
149 collapsed: Some("icons/file_icons/folder.svg".into()),
150 expanded: Some("icons/file_icons/folder_open.svg".into()),
151 },
152 chevron_icons: ChevronIcons {
153 collapsed: Some("icons/file_icons/chevron_right.svg".into()),
154 expanded: Some("icons/file_icons/chevron_down.svg".into()),
155 },
156 file_icons: HashMap::from_iter(FILE_ICONS.into_iter().map(|(ty, path)| {
157 (
158 ty.to_string(),
159 IconDefinition {
160 path: (*path).into(),
161 },
162 )
163 })),
164 }
165}