Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T05:03:58.430Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

icon_theme.rs

456 lines · 14.4 KB · rust
1use std::sync::{Arc, LazyLock};
2
3use collections::HashMap;
4use gpui::SharedString;
5
6use crate::Appearance;
7
8/// A family of icon themes.
9pub struct IconThemeFamily {
10    /// The unique ID for the icon theme family.
11    pub id: String,
12    /// The name of the icon theme family.
13    pub name: SharedString,
14    /// The author of the icon theme family.
15    pub author: SharedString,
16    /// The list of icon themes in the family.
17    pub themes: Vec<IconTheme>,
18}
19
20/// An icon theme.
21#[derive(Debug, PartialEq)]
22pub struct IconTheme {
23    /// The unique ID for the icon theme.
24    pub id: String,
25    /// The name of the icon theme.
26    pub name: SharedString,
27    /// The appearance of the icon theme (e.g., light or dark).
28    pub appearance: Appearance,
29    /// The icons used for directories.
30    pub directory_icons: DirectoryIcons,
31    /// The icons used for named directories.
32    pub named_directory_icons: HashMap<String, DirectoryIcons>,
33    /// The icons used for chevrons.
34    pub chevron_icons: ChevronIcons,
35    /// The mapping of file stems to their associated icon keys.
36    pub file_stems: HashMap<String, String>,
37    /// The mapping of file suffixes to their associated icon keys.
38    pub file_suffixes: HashMap<String, String>,
39    /// The mapping of icon keys to icon definitions.
40    pub file_icons: HashMap<String, IconDefinition>,
41}
42
43/// The icons used for directories.
44#[derive(Debug, PartialEq, Clone)]
45pub struct DirectoryIcons {
46    /// The path to the icon to use for a collapsed directory.
47    pub collapsed: Option<SharedString>,
48    /// The path to the icon to use for an expanded directory.
49    pub expanded: Option<SharedString>,
50}
51
52/// The icons used for chevrons.
53#[derive(Debug, PartialEq)]
54pub struct ChevronIcons {
55    /// The path to the icon to use for a collapsed chevron.
56    pub collapsed: Option<SharedString>,
57    /// The path to the icon to use for an expanded chevron.
58    pub expanded: Option<SharedString>,
59}
60
61/// An icon definition.
62#[derive(Debug, PartialEq)]
63pub struct IconDefinition {
64    /// The path to the icon file.
65    pub path: SharedString,
66}
67
68const FILE_STEMS_BY_ICON_KEY: &[(&str, &[&str])] = &[
69    ("docker", &["Containerfile", "Dockerfile"]),
70    ("ruby", &["Podfile"]),
71    ("heroku", &["Procfile"]),
72];
73
74const FILE_SUFFIXES_BY_ICON_KEY: &[(&str, &[&str])] = &[
75    ("astro", &["astro"]),
76    (
77        "audio",
78        &[
79            "aac", "flac", "m4a", "mka", "mp3", "ogg", "opus", "wav", "wma", "wv",
80        ],
81    ),
82    ("backup", &["bak"]),
83    ("ballerina", &["bal"]),
84    ("bicep", &["bicep"]),
85    ("bun", &["lockb"]),
86    ("c", &["c", "h"]),
87    ("cairo", &["cairo"]),
88    ("code", &["handlebars", "metadata", "rkt", "scm"]),
89    ("coffeescript", &["coffee"]),
90    (
91        "cpp",
92        &[
93            "c++", "h++", "cc", "cpp", "cppm", "cxx", "hh", "hpp", "hxx", "inl", "ixx",
94        ],
95    ),
96    ("crystal", &["cr", "ecr"]),
97    ("csharp", &["cs"]),
98    ("csproj", &["csproj"]),
99    ("css", &["css", "pcss", "postcss"]),
100    ("cue", &["cue"]),
101    ("dart", &["dart"]),
102    ("diff", &["diff"]),
103    (
104        "docker",
105        &[
106            "docker-compose.yml",
107            "docker-compose.yaml",
108            "compose.yml",
109            "compose.yaml",
110        ],
111    ),
112    (
113        "document",
114        &[
115            "doc", "docx", "mdx", "odp", "ods", "odt", "pdf", "ppt", "pptx", "rtf", "txt", "xls",
116            "xlsx",
117        ],
118    ),
119    ("editorconfig", &["editorconfig"]),
120    ("elixir", &["eex", "ex", "exs", "heex", "leex", "neex"]),
121    ("elm", &["elm"]),
122    (
123        "erlang",
124        &[
125            "Emakefile",
126            "app.src",
127            "erl",
128            "escript",
129            "hrl",
130            "rebar.config",
131            "xrl",
132            "yrl",
133        ],
134    ),
135    (
136        "eslint",
137        &[
138            "eslint.config.cjs",
139            "eslint.config.cts",
140            "eslint.config.js",
141            "eslint.config.mjs",
142            "eslint.config.mts",
143            "eslint.config.ts",
144            "eslintrc",
145            "eslintrc.js",
146            "eslintrc.json",
147        ],
148    ),
149    ("font", &["otf", "ttf", "woff", "woff2"]),
150    ("fsharp", &["fs"]),
151    ("fsproj", &["fsproj"]),
152    ("gitlab", &["gitlab-ci.yml", "gitlab-ci.yaml"]),
153    ("gleam", &["gleam"]),
154    ("go", &["go", "mod", "work"]),
155    ("graphql", &["gql", "graphql", "graphqls"]),
156    ("haskell", &["hs"]),
157    ("hcl", &["hcl"]),
158    (
159        "helm",
160        &[
161            "helmfile.yaml",
162            "helmfile.yml",
163            "Chart.yaml",
164            "Chart.yml",
165            "Chart.lock",
166            "values.yaml",
167            "values.yml",
168            "requirements.yaml",
169            "requirements.yml",
170            "tpl",
171        ],
172    ),
173    ("html", &["htm", "html"]),
174    (
175        "image",
176        &[
177            "avif", "bmp", "gif", "heic", "heif", "ico", "j2k", "jfif", "jp2", "jpeg", "jpg",
178            "jxl", "png", "psd", "qoi", "svg", "tiff", "webp",
179        ],
180    ),
181    ("ipynb", &["ipynb"]),
182    ("java", &["java"]),
183    ("javascript", &["cjs", "js", "mjs"]),
184    ("json", &["json", "jsonc"]),
185    ("julia", &["jl"]),
186    ("kdl", &["kdl"]),
187    ("kotlin", &["kt"]),
188    ("lock", &["lock"]),
189    ("log", &["log"]),
190    ("lua", &["lua"]),
191    ("luau", &["luau"]),
192    ("markdown", &["markdown", "md"]),
193    ("metal", &["metal"]),
194    ("nim", &["nim", "nims", "nimble"]),
195    ("nix", &["nix"]),
196    ("ocaml", &["ml", "mli", "mlx"]),
197    ("odin", &["odin"]),
198    ("php", &["php"]),
199    (
200        "prettier",
201        &[
202            "prettier.config.cjs",
203            "prettier.config.js",
204            "prettier.config.mjs",
205            "prettierignore",
206            "prettierrc",
207            "prettierrc.cjs",
208            "prettierrc.js",
209            "prettierrc.json",
210            "prettierrc.json5",
211            "prettierrc.mjs",
212            "prettierrc.toml",
213            "prettierrc.yaml",
214            "prettierrc.yml",
215        ],
216    ),
217    ("prisma", &["prisma"]),
218    ("puppet", &["pp"]),
219    ("python", &["py"]),
220    ("r", &["r", "R"]),
221    ("react", &["cjsx", "ctsx", "jsx", "mjsx", "mtsx", "tsx"]),
222    ("roc", &["roc"]),
223    ("ruby", &["rb"]),
224    ("rust", &["rs"]),
225    ("sass", &["sass", "scss"]),
226    ("scala", &["scala", "sc"]),
227    ("settings", &["conf", "ini"]),
228    ("solidity", &["sol"]),
229    (
230        "storage",
231        &[
232            "accdb", "csv", "dat", "db", "dbf", "dll", "fmp", "fp7", "frm", "gdb", "ib", "ldf",
233            "mdb", "mdf", "myd", "myi", "pdb", "RData", "rdata", "sav", "sdf", "sql", "sqlite",
234            "tsv",
235        ],
236    ),
237    (
238        "stylelint",
239        &[
240            "stylelint.config.cjs",
241            "stylelint.config.js",
242            "stylelint.config.mjs",
243            "stylelintignore",
244            "stylelintrc",
245            "stylelintrc.cjs",
246            "stylelintrc.js",
247            "stylelintrc.json",
248            "stylelintrc.mjs",
249            "stylelintrc.yaml",
250            "stylelintrc.yml",
251        ],
252    ),
253    ("surrealql", &["surql"]),
254    ("svelte", &["svelte"]),
255    ("swift", &["swift"]),
256    ("tcl", &["tcl"]),
257    ("template", &["hbs", "plist", "xml"]),
258    (
259        "terminal",
260        &[
261            "bash",
262            "bash_aliases",
263            "bash_login",
264            "bash_logout",
265            "bash_profile",
266            "bashrc",
267            "fish",
268            "nu",
269            "profile",
270            "ps1",
271            "sh",
272            "zlogin",
273            "zlogout",
274            "zprofile",
275            "zsh",
276            "zsh_aliases",
277            "zsh_histfile",
278            "zsh_history",
279            "zshenv",
280            "zshrc",
281        ],
282    ),
283    ("terraform", &["tf", "tfvars"]),
284    ("toml", &["toml"]),
285    ("typescript", &["cts", "mts", "ts"]),
286    ("v", &["v", "vsh", "vv"]),
287    (
288        "vcs",
289        &[
290            "COMMIT_EDITMSG",
291            "EDIT_DESCRIPTION",
292            "MERGE_MSG",
293            "NOTES_EDITMSG",
294            "TAG_EDITMSG",
295            "gitattributes",
296            "gitignore",
297            "gitkeep",
298            "gitmodules",
299        ],
300    ),
301    ("vbproj", &["vbproj"]),
302    ("video", &["avi", "m4v", "mkv", "mov", "mp4", "webm", "wmv"]),
303    ("vs_sln", &["sln"]),
304    ("vs_suo", &["suo"]),
305    ("vue", &["vue"]),
306    ("vyper", &["vy", "vyi"]),
307    ("wgsl", &["wgsl"]),
308    ("yaml", &["yaml", "yml"]),
309    ("zig", &["zig"]),
310];
311
312/// A mapping of a file type identifier to its corresponding icon.
313const FILE_ICONS: &[(&str, &str)] = &[
314    ("astro", "icons/file_icons/astro.svg"),
315    ("audio", "icons/file_icons/audio.svg"),
316    ("ballerina", "icons/file_icons/ballerina.svg"),
317    ("bicep", "icons/file_icons/file.svg"),
318    ("bun", "icons/file_icons/bun.svg"),
319    ("c", "icons/file_icons/c.svg"),
320    ("cairo", "icons/file_icons/cairo.svg"),
321    ("code", "icons/file_icons/code.svg"),
322    ("coffeescript", "icons/file_icons/coffeescript.svg"),
323    ("cpp", "icons/file_icons/cpp.svg"),
324    ("crystal", "icons/file_icons/file.svg"),
325    ("csharp", "icons/file_icons/file.svg"),
326    ("csproj", "icons/file_icons/file.svg"),
327    ("css", "icons/file_icons/css.svg"),
328    ("cue", "icons/file_icons/file.svg"),
329    ("dart", "icons/file_icons/dart.svg"),
330    ("default", "icons/file_icons/file.svg"),
331    ("diff", "icons/file_icons/diff.svg"),
332    ("docker", "icons/file_icons/docker.svg"),
333    ("document", "icons/file_icons/book.svg"),
334    ("editorconfig", "icons/file_icons/editorconfig.svg"),
335    ("elixir", "icons/file_icons/elixir.svg"),
336    ("elm", "icons/file_icons/elm.svg"),
337    ("erlang", "icons/file_icons/erlang.svg"),
338    ("eslint", "icons/file_icons/eslint.svg"),
339    ("font", "icons/file_icons/font.svg"),
340    ("fsharp", "icons/file_icons/fsharp.svg"),
341    ("fsproj", "icons/file_icons/file.svg"),
342    ("gitlab", "icons/file_icons/gitlab.svg"),
343    ("gleam", "icons/file_icons/gleam.svg"),
344    ("go", "icons/file_icons/go.svg"),
345    ("graphql", "icons/file_icons/graphql.svg"),
346    ("haskell", "icons/file_icons/haskell.svg"),
347    ("hcl", "icons/file_icons/hcl.svg"),
348    ("helm", "icons/file_icons/helm.svg"),
349    ("heroku", "icons/file_icons/heroku.svg"),
350    ("html", "icons/file_icons/html.svg"),
351    ("image", "icons/file_icons/image.svg"),
352    ("ipynb", "icons/file_icons/jupyter.svg"),
353    ("java", "icons/file_icons/java.svg"),
354    ("javascript", "icons/file_icons/javascript.svg"),
355    ("json", "icons/file_icons/code.svg"),
356    ("julia", "icons/file_icons/julia.svg"),
357    ("kdl", "icons/file_icons/kdl.svg"),
358    ("kotlin", "icons/file_icons/kotlin.svg"),
359    ("lock", "icons/file_icons/lock.svg"),
360    ("log", "icons/file_icons/info.svg"),
361    ("lua", "icons/file_icons/lua.svg"),
362    ("luau", "icons/file_icons/luau.svg"),
363    ("markdown", "icons/file_icons/book.svg"),
364    ("metal", "icons/file_icons/metal.svg"),
365    ("nim", "icons/file_icons/nim.svg"),
366    ("nix", "icons/file_icons/nix.svg"),
367    ("ocaml", "icons/file_icons/ocaml.svg"),
368    ("odin", "icons/file_icons/odin.svg"),
369    ("phoenix", "icons/file_icons/phoenix.svg"),
370    ("php", "icons/file_icons/php.svg"),
371    ("prettier", "icons/file_icons/prettier.svg"),
372    ("prisma", "icons/file_icons/prisma.svg"),
373    ("puppet", "icons/file_icons/puppet.svg"),
374    ("python", "icons/file_icons/python.svg"),
375    ("r", "icons/file_icons/r.svg"),
376    ("react", "icons/file_icons/react.svg"),
377    ("roc", "icons/file_icons/roc.svg"),
378    ("ruby", "icons/file_icons/ruby.svg"),
379    ("rust", "icons/file_icons/rust.svg"),
380    ("sass", "icons/file_icons/sass.svg"),
381    ("scala", "icons/file_icons/scala.svg"),
382    ("settings", "icons/file_icons/settings.svg"),
383    ("solidity", "icons/file_icons/file.svg"),
384    ("storage", "icons/file_icons/database.svg"),
385    ("stylelint", "icons/file_icons/javascript.svg"),
386    ("surrealql", "icons/file_icons/surrealql.svg"),
387    ("svelte", "icons/file_icons/html.svg"),
388    ("swift", "icons/file_icons/swift.svg"),
389    ("tcl", "icons/file_icons/tcl.svg"),
390    ("template", "icons/file_icons/html.svg"),
391    ("terminal", "icons/file_icons/terminal.svg"),
392    ("terraform", "icons/file_icons/terraform.svg"),
393    ("toml", "icons/file_icons/toml.svg"),
394    ("typescript", "icons/file_icons/typescript.svg"),
395    ("v", "icons/file_icons/v.svg"),
396    ("vbproj", "icons/file_icons/file.svg"),
397    ("vcs", "icons/file_icons/git.svg"),
398    ("video", "icons/file_icons/video.svg"),
399    ("vs_sln", "icons/file_icons/file.svg"),
400    ("vs_suo", "icons/file_icons/file.svg"),
401    ("vue", "icons/file_icons/vue.svg"),
402    ("vyper", "icons/file_icons/vyper.svg"),
403    ("wgsl", "icons/file_icons/wgsl.svg"),
404    ("yaml", "icons/file_icons/yaml.svg"),
405    ("zig", "icons/file_icons/zig.svg"),
406];
407
408/// Returns a mapping of file associations to icon keys.
409fn icon_keys_by_association(
410    associations_by_icon_key: &[(&str, &[&str])],
411) -> HashMap<String, String> {
412    let mut icon_keys_by_association = HashMap::default();
413    for (icon_key, associations) in associations_by_icon_key {
414        for association in *associations {
415            icon_keys_by_association.insert(association.to_string(), icon_key.to_string());
416        }
417    }
418
419    icon_keys_by_association
420}
421
422/// The name of the default icon theme.
423pub const DEFAULT_ICON_THEME_NAME: &str = "Omega (Default)";
424
425static DEFAULT_ICON_THEME: LazyLock<Arc<IconTheme>> = LazyLock::new(|| {
426    Arc::new(IconTheme {
427        id: "zed".into(),
428        name: DEFAULT_ICON_THEME_NAME.into(),
429        appearance: Appearance::Dark,
430        directory_icons: DirectoryIcons {
431            collapsed: Some("icons/file_icons/folder.svg".into()),
432            expanded: Some("icons/file_icons/folder_open.svg".into()),
433        },
434        named_directory_icons: HashMap::default(),
435        chevron_icons: ChevronIcons {
436            collapsed: Some("icons/file_icons/chevron_right.svg".into()),
437            expanded: Some("icons/file_icons/chevron_down.svg".into()),
438        },
439        file_stems: icon_keys_by_association(FILE_STEMS_BY_ICON_KEY),
440        file_suffixes: icon_keys_by_association(FILE_SUFFIXES_BY_ICON_KEY),
441        file_icons: HashMap::from_iter(FILE_ICONS.iter().map(|(ty, path)| {
442            (
443                ty.to_string(),
444                IconDefinition {
445                    path: (*path).into(),
446                },
447            )
448        })),
449    })
450});
451
452/// Returns the default icon theme.
453pub fn default_icon_theme() -> Arc<IconTheme> {
454    DEFAULT_ICON_THEME.clone()
455}
456
Served at tenant.openagents/omega Member data and write actions are omitted.