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