Files
zed/crates/theme/src/icon_theme_schema.rs
Jacob 5f20b905a5 Add support for named folder icons (#36351)
Adds a `named_directory_icons` field to the icon theme that can be used
to specify a collection of icons for collapsed and expanded folders
based on the folder name.

The `named_directory_icons` is a map from the folder name to a
`DirectoryIcons` object containing the paths to the expanded and
collapsed icons for that folder:

```json
{
  "named_directory_icons": {
    ".angular": {
      "collapsed": "./icons/folder_angular.svg",
      "expanded": "./icons/folder_angular_open.svg"
    }
  }
}

```

Closes #20295

Also referenced
https://github.com/zed-industries/zed/pull/23987#issuecomment-2638869213

Example using https://github.com/jacobtread/zed-vscode-icons/ which I've
ported over from a VSCode theme,

<img width="609" height="1307" alt="image"
src="https://github.com/user-attachments/assets/2d3c120a-b2f0-43fd-889d-641ad4bb9cee"
/>

Release Notes:

- Added support for icon themes to change the folder icon based on the
directory name.

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-09-12 14:55:25 -04:00

51 lines
1.4 KiB
Rust

#![allow(missing_docs)]
use gpui::SharedString;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use crate::AppearanceContent;
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct IconThemeFamilyContent {
pub name: String,
pub author: String,
pub themes: Vec<IconThemeContent>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct IconThemeContent {
pub name: String,
pub appearance: AppearanceContent,
#[serde(default)]
pub directory_icons: DirectoryIconsContent,
#[serde(default)]
pub named_directory_icons: HashMap<String, DirectoryIconsContent>,
#[serde(default)]
pub chevron_icons: ChevronIconsContent,
#[serde(default)]
pub file_stems: HashMap<String, String>,
#[serde(default)]
pub file_suffixes: HashMap<String, String>,
#[serde(default)]
pub file_icons: HashMap<String, IconDefinitionContent>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
pub struct DirectoryIconsContent {
pub collapsed: Option<SharedString>,
pub expanded: Option<SharedString>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
pub struct ChevronIconsContent {
pub collapsed: Option<SharedString>,
pub expanded: Option<SharedString>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct IconDefinitionContent {
pub path: SharedString,
}