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 mapping of file types to icon definitions.
28 pub file_icons: HashMap<String, IconDefinition>,
29}
30
31/// An icon definition.
32#[derive(Debug, PartialEq)]
33pub struct IconDefinition {
34 /// The path to the icon file.
35 pub path: SharedString,
36}
37
38/// A mapping of a file type identifier to its corresponding icon.
39const FILE_ICONS: &[(&str, &str)] = &[
40 ("astro", "icons/file_icons/astro.svg"),
41 ("audio", "icons/file_icons/audio.svg"),
42 ("bun", "icons/file_icons/bun.svg"),
43 ("c", "icons/file_icons/c.svg"),
44 ("code", "icons/file_icons/code.svg"),
45 ("coffeescript", "icons/file_icons/coffeescript.svg"),
46 ("collapsed_chevron", "icons/file_icons/chevron_right.svg"),
47 ("collapsed_folder", "icons/file_icons/folder.svg"),
48 ("cpp", "icons/file_icons/cpp.svg"),
49 ("css", "icons/file_icons/css.svg"),
50 ("dart", "icons/file_icons/dart.svg"),
51 ("default", "icons/file_icons/file.svg"),
52 ("diff", "icons/file_icons/diff.svg"),
53 ("docker", "icons/file_icons/docker.svg"),
54 ("document", "icons/file_icons/book.svg"),
55 ("elixir", "icons/file_icons/elixir.svg"),
56 ("elm", "icons/file_icons/elm.svg"),
57 ("erlang", "icons/file_icons/erlang.svg"),
58 ("eslint", "icons/file_icons/eslint.svg"),
59 ("expanded_chevron", "icons/file_icons/chevron_down.svg"),
60 ("expanded_folder", "icons/file_icons/folder_open.svg"),
61 ("font", "icons/file_icons/font.svg"),
62 ("fsharp", "icons/file_icons/fsharp.svg"),
63 ("gleam", "icons/file_icons/gleam.svg"),
64 ("go", "icons/file_icons/go.svg"),
65 ("graphql", "icons/file_icons/graphql.svg"),
66 ("haskell", "icons/file_icons/haskell.svg"),
67 ("hcl", "icons/file_icons/hcl.svg"),
68 ("heroku", "icons/file_icons/heroku.svg"),
69 ("image", "icons/file_icons/image.svg"),
70 ("java", "icons/file_icons/java.svg"),
71 ("javascript", "icons/file_icons/javascript.svg"),
72 ("julia", "icons/file_icons/julia.svg"),
73 ("kotlin", "icons/file_icons/kotlin.svg"),
74 ("lock", "icons/file_icons/lock.svg"),
75 ("log", "icons/file_icons/info.svg"),
76 ("lua", "icons/file_icons/lua.svg"),
77 ("metal", "icons/file_icons/metal.svg"),
78 ("nim", "icons/file_icons/nim.svg"),
79 ("nix", "icons/file_icons/nix.svg"),
80 ("ocaml", "icons/file_icons/ocaml.svg"),
81 ("phoenix", "icons/file_icons/phoenix.svg"),
82 ("php", "icons/file_icons/php.svg"),
83 ("prettier", "icons/file_icons/prettier.svg"),
84 ("prisma", "icons/file_icons/prisma.svg"),
85 ("python", "icons/file_icons/python.svg"),
86 ("r", "icons/file_icons/r.svg"),
87 ("react", "icons/file_icons/react.svg"),
88 ("roc", "icons/file_icons/roc.svg"),
89 ("ruby", "icons/file_icons/ruby.svg"),
90 ("rust", "icons/file_icons/rust.svg"),
91 ("sass", "icons/file_icons/sass.svg"),
92 ("scala", "icons/file_icons/scala.svg"),
93 ("settings", "icons/file_icons/settings.svg"),
94 ("storage", "icons/file_icons/database.svg"),
95 ("swift", "icons/file_icons/swift.svg"),
96 ("tcl", "icons/file_icons/tcl.svg"),
97 ("template", "icons/file_icons/html.svg"),
98 ("terminal", "icons/file_icons/terminal.svg"),
99 ("terraform", "icons/file_icons/terraform.svg"),
100 ("toml", "icons/file_icons/toml.svg"),
101 ("typescript", "icons/file_icons/typescript.svg"),
102 ("v", "icons/file_icons/v.svg"),
103 ("vcs", "icons/file_icons/git.svg"),
104 ("video", "icons/file_icons/video.svg"),
105 ("vue", "icons/file_icons/vue.svg"),
106 ("zig", "icons/file_icons/zig.svg"),
107];
108
109/// The ID of the default icon theme.
110pub(crate) const DEFAULT_ICON_THEME_ID: &str = "zed";
111
112/// Returns the default icon theme.
113pub fn default_icon_theme() -> IconTheme {
114 IconTheme {
115 id: DEFAULT_ICON_THEME_ID.into(),
116 name: "Zed (Default)".into(),
117 appearance: Appearance::Dark,
118 file_icons: HashMap::from_iter(FILE_ICONS.into_iter().map(|(ty, path)| {
119 (
120 ty.to_string(),
121 IconDefinition {
122 path: (*path).into(),
123 },
124 )
125 })),
126 }
127}