summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig19
1 files changed, 18 insertions, 1 deletions
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 <name>` 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 };