Skip to content

yazi: palette doc image + regeneration script for kanagawa-dragon#10

Open
kriswill wants to merge 4 commits into
mainfrom
yazi-palette-doc
Open

yazi: palette doc image + regeneration script for kanagawa-dragon#10
kriswill wants to merge 4 commits into
mainfrom
yazi-palette-doc

Conversation

@kriswill
Copy link
Copy Markdown
Owner

What

Documents the kanagawa-dragon yazi theme's colors in a single rendered image, plus a script that regenerates it from the theme's own source files (so it can't drift).

palette

Changes

  • scripts/render-yazi-palette.ts — a bun script that:
    • parses flavor.toml (color names from the ## Color palette comment block, plus a usage scan showing where each hex is referenced, e.g. mgr.cwd, status.perm_read);
    • parses tmtheme.xml via a minimal plist parser (handles the self-closing <string/> tags used for empty fontStyles);
    • renders a labeled swatch grid via ImageMagick and overwrites palette.png.
    • Re-run anytime: bun scripts/render-yazi-palette.ts. Font is discovered from the Nix store (overridable via FONT_REGULAR/FONT_BOLD); deps are bun + ImageMagick.
  • _themes/kanagawa-dragon/palette.png — the generated documentation image: UI theme (18 colors), tmtheme editor globals (6), and syntax scopes (21 unique colors), each labeled with name / hex / usage.

Notes

  • Fully data-driven — names and usage come from the files themselves, so the image stays correct as the theme changes.
  • Surfaced one gap: #8ea4a2 (used for all borders) is not named in flavor.toml's palette comment block; the script labels it dragonAqua via a small alias map.
  • Independent of yazi: wire lua_ls type checking for font-dark previewer #9 (LSP types) — touches only the script and the image.

Verification

bun scripts/render-yazi-palette.tswrote .../palette.png (1760x2382) · flavor: 18, tmtheme editor: 6, scopes: 21.

@kriswill kriswill force-pushed the yazi-palette-doc branch from 5050d3b to 2c622e0 Compare May 25, 2026 19:44
kriswill added 4 commits May 27, 2026 10:55
Document the kanagawa-dragon flavor's colors in a single rendered image,
generated from the theme's own source files so it stays accurate.

- scripts/render-yazi-palette.ts: bun script that parses flavor.toml
  (palette names + usage scan) and tmtheme.xml (minimal plist parser),
  then renders a labeled swatch grid via ImageMagick to
  _themes/kanagawa-dragon/palette.png. Re-run: `bun scripts/render-yazi-palette.ts`.
- palette.png: UI theme (18 colors), tmtheme editor (6) and syntax
  scopes (21 unique colors), each labeled with name/hex/usage.
…om nix output

The flavor is not strictly the dragon variant and will get local tweaks, so
drop the -dragon suffix. flavor.toml/tmtheme.xml are now nix-generated, so
expose the flavor as the yazi-kanagawa-flavor package and have
render-yazi-palette.ts build it and read color names from lib/kanagawa.nix.
Refactor the single in-repo yazi flavor into four flavors generated from a
single palette source of truth, installed simultaneously, with a plugin to
switch between them at runtime.

- lib/kanagawa.nix → lib/kanagawa/ : raw palette (palette.nix, unchanged) plus
  per-flavor semantic role tables (themes/{wave,dragon,lotus,kris}.nix). wave/
  dragon/lotus are transcribed faithfully from kanagawa.nvim's themes.lua via a
  shared mapper (themes/mk.nix); kris is the prior personal theme (wave editor +
  syntax, dragon-family chrome) kept as explicit literals.
- pkgs/yazi-kanagawa-flavor/ : reusable builder ({name,title,uuid,appearance,
  theme} → flavor.toml + tmtheme.xml), a shared spec list (flavors.nix), and
  all.nix building every flavor. packages.nix exposes yazi-kanagawa-{wave,
  dragon,lotus,kris}. kris output is byte-identical to the previous flavor
  (flavor.toml identical; tmtheme identical sans name/semanticClass).
- yazi module: installs all four flavors; theme.toml is no longer managed by
  programs.yazi but is an out-of-store symlink to a writable
  ~/.local/state/yazi/theme.toml, seeded once (default kanagawa-kris) by an
  activation script so a saved selection survives rebuilds. Adds the
  theme-switcher.yazi plugin (which-key menu → fs.write → notify "restart to
  apply"; yazi has no live flavor reload) bound to `T`.
- render-yazi-palette.ts: documents all four flavors to _palette/kanagawa-*.png.

Note: the new kanagawa-dragon is a faithful canonical dragon, distinct from the
earlier `kanagawa` flavor (now kanagawa-kris).
@kriswill kriswill force-pushed the yazi-palette-doc branch from 2e87e2d to fd540c8 Compare May 27, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant