Add infrastructure for loading icon themes from extensions (#23203)

This PR adds the supporting infrastructure to support loading icon
themes defined by extensions.

Here's an example icon theme:

```json
{
  "name": "My Icon Theme",
  "author": "Me <me@example.com>",
  "themes": [
    {
      "name": "My Icon Theme",
      "appearance": "dark",
      "file_icons": {
        "gleam": { "path": "./icons/file_type_gleam.svg" },
        "toml": { "path": "./icons/file_type_toml.svg" }
      }
    }
  ]
}
```

The icon paths are resolved relative to the root of the extension
directory.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-01-15 18:33:47 -05:00 committed by GitHub
parent 3b8a5c9647
commit f53915c711
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 303 additions and 10 deletions

View file

@ -560,6 +560,21 @@ fn populate_defaults(manifest: &mut ExtensionManifest, extension_path: &Path) ->
}
}
let icon_themes_dir = extension_path.join("icon_themes");
if icon_themes_dir.exists() {
for entry in fs::read_dir(&icon_themes_dir).context("failed to list icon themes dir")? {
let entry = entry?;
let icon_theme_path = entry.path();
if icon_theme_path.extension() == Some("json".as_ref()) {
let relative_icon_theme_path =
icon_theme_path.strip_prefix(extension_path)?.to_path_buf();
if !manifest.icon_themes.contains(&relative_icon_theme_path) {
manifest.icon_themes.push(relative_icon_theme_path);
}
}
}
}
let snippets_json_path = extension_path.join("snippets.json");
if snippets_json_path.exists() {
manifest.snippets = Some(snippets_json_path);