aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/app_inventory.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/theme-studio/app_inventory.py')
-rw-r--r--scripts/theme-studio/app_inventory.py71
1 files changed, 46 insertions, 25 deletions
diff --git a/scripts/theme-studio/app_inventory.py b/scripts/theme-studio/app_inventory.py
index 01dcb7db7..ade71a0ef 100644
--- a/scripts/theme-studio/app_inventory.py
+++ b/scripts/theme-studio/app_inventory.py
@@ -7,31 +7,20 @@ import os
from collections.abc import Sequence
from typing import Any
+from face_data import BESPOKE_APP_SPECS
-BESPOKE_APPS = {
- "magit",
- "elfeed",
- "org",
- "org-mode",
- "mu4e",
- "org-faces",
- "ghostel",
- "auto-dim-other-buffers",
- "dashboard",
- "lsp-mode",
- "git-gutter",
- "flycheck",
- "dired",
- "dirvish",
- "calibredb",
- "erc",
- "org-drill",
- "org-noter",
- "signel",
- "pearl",
- "slack",
- "telega",
- "shr",
+
+# Keys of the bespoke apps (single-sourced in face_data), excluded from the
+# generic-inventory path so they aren't also emitted as plain inventory apps.
+# "org" is an explicit alias of the "org-mode" bespoke app, so an inventory
+# package literally named "org" never gets a duplicate generic entry.
+BESPOKE_APPS = {spec[0] for spec in BESPOKE_APP_SPECS} | {"org"}
+
+
+# Inventory apps (not in BESPOKE_APPS) default to the generic preview. A few have
+# a dedicated PACKAGE_PREVIEWS renderer in app.js, keyed by name here.
+PREVIEW_KEYS = {
+ "markdown-mode": "markdown",
}
@@ -55,12 +44,44 @@ def add_inventory_apps(apps: dict[str, Any], inventory_path: str) -> dict[str, A
continue
apps[pkg] = {
"label": pkg,
- "preview": "generic",
+ "preview": PREVIEW_KEYS.get(pkg, "generic"),
"faces": [[face, face_label(face, pkg + "-"), {}] for face in inventory[pkg]],
}
return apps
+def add_nerd_icons_app(apps: dict[str, Any], inventory_path: str, legend: Any,
+ gallery: Any = None) -> dict[str, Any]:
+ """Register nerd-icons as a bespoke legend app from its inventory faces.
+
+ The 34 nerd-icons color faces stay editable rows; LEGEND (the validated rows
+ from generate.load_nerd_icons_legend) rides the app so the bespoke previews.js
+ renderer can draw each filetype glyph in its mapped face color. GALLERY (the
+ full colored catalog grouped by face, from generate.load_nerd_icons_gallery)
+ rides alongside when present so the same renderer can draw the gallery section;
+ a falsy GALLERY simply omits it (legend-only). A no-op when LEGEND is falsy or
+ the inventory lacks nerd-icons -- the caller guards on a valid legend, and
+ add_inventory_apps then creates the generic fallback app. Must run before
+ add_inventory_apps so the generic path skips nerd-icons.
+ """
+ if not legend or not os.path.exists(inventory_path):
+ return apps
+ with open(inventory_path) as src:
+ faces = json.load(src).get("nerd-icons")
+ if not faces:
+ return apps
+ app = {
+ "label": "nerd-icons",
+ "preview": "nerdicons",
+ "faces": [[face, face_label(face, "nerd-icons-"), {}] for face in faces],
+ "legend": legend,
+ }
+ if gallery:
+ app["gallery"] = gallery
+ apps["nerd-icons"] = app
+ return apps
+
+
def apply_default_face_seeds(apps: dict[str, Any], defaults: Any) -> None:
if not defaults.available:
return