Allow icon themes to provide their own file associations (#24926)

This PR adds the ability for icon themes to provide their own file
associations.

The old `file_types.json` that was previously used to make these
associations has been removed in favor of storing them on the default
theme.

Icon themes have two new fields on them:

- `file_stems`: A mapping of file stems to icon keys.
- `file_suffixes`: A mapping of file suffixes to icon keys.

These mappings produce icon keys which can then be used in `file_icons`
to associate them to a particular icon:

```json
{
  "file_stems": {
    "Makefile": "make"
  },
  "file_suffixes": {
    "idr": "idris"
  },
  "file_icons": {
    "idris": { "path": "./icons/idris.svg" },
    "make": { "path": "./icons/make.svg" }
  }
}
```

When loading an icon theme, the `file_stems` and `file_icons` fields
will be merged with the ones from the base icon theme, with the values
from the icon theme being loaded overriding ones in the base theme.

Release Notes:

- Added the ability for icon themes to provide their own file
associations.
This commit is contained in:
Marshall Bowers 2025-02-14 19:35:13 -05:00 committed by GitHub
parent f2776099ab
commit e60123bbdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 286 additions and 370 deletions

View file

@ -18,8 +18,8 @@ use file_icons::FileIcons;
use git::status::GitSummary;
use gpui::{
actions, anchored, deferred, div, impl_actions, point, px, size, uniform_list, Action,
AnyElement, App, AssetSource, AsyncWindowContext, Bounds, ClipboardItem, Context, DismissEvent,
Div, DragMoveEvent, Entity, EventEmitter, ExternalPaths, FocusHandle, Focusable, Hsla,
AnyElement, App, AsyncWindowContext, Bounds, ClipboardItem, Context, DismissEvent, Div,
DragMoveEvent, Entity, EventEmitter, ExternalPaths, FocusHandle, Focusable, Hsla,
InteractiveElement, KeyContext, ListHorizontalSizingBehavior, ListSizingBehavior, MouseButton,
MouseDownEvent, ParentElement, Pixels, Point, PromptLevel, Render, ScrollStrategy, Stateful,
Styled, Subscription, Task, UniformListScrollHandle, WeakEntity, Window,
@ -225,9 +225,8 @@ pub fn init_settings(cx: &mut App) {
ProjectPanelSettings::register(cx);
}
pub fn init(assets: impl AssetSource, cx: &mut App) {
pub fn init(cx: &mut App) {
init_settings(cx);
file_icons::init(assets, cx);
cx.observe_new(|workspace: &mut Workspace, _, _| {
workspace.register_action(|workspace, _: &ToggleFocus, window, cx| {
@ -9484,7 +9483,7 @@ mod tests {
theme::init(theme::LoadThemes::JustBase, cx);
language::init(cx);
editor::init_settings(cx);
crate::init((), cx);
crate::init(cx);
workspace::init_settings(cx);
client::init_settings(cx);
Project::init_settings(cx);
@ -9507,7 +9506,7 @@ mod tests {
init_settings(cx);
language::init(cx);
editor::init(cx);
crate::init((), cx);
crate::init(cx);
workspace::init(app_state.clone(), cx);
Project::init_settings(cx);