From 5cf16eab0a4beec196e51bdcee731b899a2af07c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 31 Jul 2026 09:59:08 -0300 Subject: every helix and zed theme on the machine, not a curated nine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 228 in the ring: 3 pardes ships plus all 214 helix runtime themes and all 11 zed variants across its three families. No exclusions. inherits is what this cost. 76 themes need it, so the reader is two passes now, and the merge is WHOLE-KEY rather than field-wise because helix merges the theme body at depth 1 — the three *_transparent themes clear their parent's background with an empty table, and a field-wise merge would leave it painted. I had that wrong until I read helix-view/src/theme.rs. At 214 files the generator meets themes that are SPARSE rather than broken, and the old fatal-on-anything-missing would have rejected them. Every fallback is helix's own rule: no background at all means wear the terminal's, so bg and fg go null (13 themes, correctly); the twelve RGB fields that cannot be null fall back to ghostty's default palette entries 7 and 0, which is exactly what a pardes terminal already paints an unstyled ANSI index as. fatal is kept for what genuinely cannot be read. Three real bugs surfaced only at scale: #ccc shorthand doubles the nibble (helix's rule, 58 colours), a quoted inline-table key silently dropped a selection colour, and four themes name a cursor background EQUAL to the page because they are about to reverse that cell — taking it painted an invisible move box. 0 degenerate themes out of 225 now: no fg==bg, no syntax colour on its own background, no invisible box. Collisions get an unconditional rule rather than a clever one: a zed variant is always _zed, because both projects ship gruvbox, ayu and one, and a conditional tag would move a name when the other source changes. A comptime assert holds it. Cost: no-op build 0.257 -> 0.276s, a pardes.zig change 46.8 -> 47.5s, binary +0.98%. The generator does 217 sources in 54ms. NextColor stays and is no longer a way to REACH a theme — but the browse got better, not worse: the generated half sorts by name, so its neighbours are that theme's own family. theme.golden's fourth click moved from ayu_dark to acid, which sorting 225 names does; themesel gained a tail capture proving row 228 renders. --- src/builtins.zig | 14 +++++++++++--- src/pardes.zig | 19 ++++++++++++++++++- 2 files changed, 29 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/builtins.zig b/src/builtins.zig index 620c6b1c..6593be7d 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -176,6 +176,13 @@ pub const Colors = struct { } }; +/// One step along the ring. With 228 themes in it this is no longer a way to +/// REACH a theme — ThemeSel is — but it is still the way to browse one, and the +/// browse got better rather than worse: the generated half is sorted by name, so +/// the neighbours of wherever you are are that theme's own variants (light, +/// hard, soft, the whole gruvbox family in a row). Kept as the topbar word and +/// SPC t n it has always been; a ring you can walk off the end of in three +/// clicks was never what made it useful. pub const NextColor = struct { pub fn run(c: Ctx) void { c.p.theme_idx = (c.p.theme_idx + 1) % pardes.themes.len; @@ -188,9 +195,10 @@ pub const NextColor = struct { /// (there is no theme called nothing), which is also why it has no leader path: /// a key path names a builtin and can never carry the name of a theme. /// -/// A LINEAR SCAN over a couple of dozen names, on a keystroke: the alternative -/// is a comptime name->index map, which is a second copy of the ring to build -/// for a lookup nobody will ever measure. +/// A LINEAR SCAN over 228 names, on a keystroke: the alternative is a comptime +/// name->index map, which is a second copy of the ring to build for a lookup +/// nobody will ever measure. 228 short string compares is microseconds, and it +/// happens once per theme change, not once per frame. pub const Theme = struct { pub fn run(c: Ctx) void { const want = std.mem.trim(u8, c.arg orelse return, " \t\r\n"); diff --git a/src/pardes.zig b/src/pardes.zig index ced4c2f9..fbf48f05 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -326,7 +326,7 @@ const curated = struct { /// only ever a signature to whoever walks it, never a value in its own way. fn fold(comptime C: type) []const Theme { comptime { - @setEvalBranchQuota(20000); // themes x fields, and each field a @field lookup + @setEvalBranchQuota(400000); // 228 themes x 15 fields, each field a @field lookup, and the array re-concatenated per theme var out: []const Theme = &.{}; for (@typeInfo(C).@"struct".decls) |d| { var t: Theme = undefined; @@ -341,8 +341,25 @@ fn fold(comptime C: type) []const Theme { /// helix and zed sources in vendor/themes (build.zig runs it and hands the /// result over as a module). Adding one is dropping a file in there — there is /// no list here to append to, which is the whole point of folding the files. +/// 228 of them: everything helix and zed ship, because "which of these is worth +/// having" is the user's call and not the build's. That length is why ThemeSel +/// exists — NextColor is a browse, not a way to arrive anywhere in particular. pub const themes = fold(curated) ++ fold(@import("generated_themes")); +// Two themes answering to one name is a bug: `Theme ` resolves by name +// and would silently pick whichever came first, and ThemeSel would list the +// loser as a row that does nothing. The generated half cannot collide with +// ITSELF — one file per theme, all imported into one struct, so zig's own +// redeclaration error already catches that — which leaves exactly the cross +// pair to check here, three times 225 rather than 228 squared. This is the +// check that makes helix's `acme.toml` vendored as `acme_helix.toml`. +comptime { + @setEvalBranchQuota(20000); + const ours = fold(curated).len; + for (themes[0..ours]) |c| for (themes[ours..]) |g| if (std.mem.eql(u8, c.name, g.name)) + @compileError("theme name \"" ++ c.name ++ "\" is both ours and generated; rename the vendored source"); +} + // ---- the boundary types ---- pub const Color = union(enum) { default, index: u8, rgb: [3]u8 }; -- cgit v1.3