summaryrefslogtreecommitdiff
path: root/tools/gen_themes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 17:35:06 -0300
committerGabriel Schneider <[email protected]>2026-10-30 17:35:06 -0300
commit6d8da8721141284cf33bb901168b26135893eb86 (patch)
tree791d63401d4e85fbca1d597a8ce0326e70efd545 /tools/gen_themes.zig
parentefd43a3a2cf03bb741366331158b368abf9ac583 (diff)
parentbf6810a8f9d6cc82050e7d9c0cfb06358301b574 (diff)
downloadpardes-6d8da8721141284cf33bb901168b26135893eb86.tar.gz
pardes-6d8da8721141284cf33bb901168b26135893eb86.zip
Merge latest upstream into the macOS branch for Zig 0.17
Retain the macOS branch history and local Acme selection color while adopting upstream's current core and platform changes. Pin Zig and ZLS to 0.17.0, and fetch the existing zstbi compatibility commit through upstream after its original fork was removed.
Diffstat (limited to 'tools/gen_themes.zig')
-rw-r--r--tools/gen_themes.zig35
1 files changed, 20 insertions, 15 deletions
diff --git a/tools/gen_themes.zig b/tools/gen_themes.zig
index 3add2040..30808dfe 100644
--- a/tools/gen_themes.zig
+++ b/tools/gen_themes.zig
@@ -11,9 +11,10 @@
//!
//! Why vendored and not read out of ~/05-genizah: `zig build` must work on a
//! fresh clone with no network and no helix checkout. It is the WHOLE of what
-//! both projects ship — helix's 214 runtime themes and zed's three families,
-//! 1.5MB of text — because "which ones are worth having" is not a question a
-//! build tool gets to answer on the user's behalf.
+//! both projects ship — helix's runtime themes and zed's three families —
+//! because "which ones are worth having" is not a question a build tool gets
+//! to answer on the user's behalf. The one exception is helix's copy of a
+//! theme pardes ports by hand (src/themes/: dracula, nord, ...): not vendored.
//!
//! NAMES. A helix theme is its file stem; a zed variant is its `name` slugged
//! with `_zed` on the end. Both projects ship gruvbox, ayu and one, so the
@@ -21,15 +22,18 @@
//! variant is one rule instead of eight exceptions — it also keeps a name from
//! moving when the other source gains or loses a file. helix's own `acme.toml`
//! is vendored as `acme_helix.toml` for the same reason, since pardes ships an
-//! acme of its own; the file is otherwise untouched. Two themes answering to
-//! one name is a bug (`Theme <name>` would silently pick one), so src/pardes.zig
+//! acme of its own; the file is otherwise untouched. So are `monokai`,
+//! `ayu_dark` and `nord` as `<name>_helix.toml`, kept (unlike helix's other
+//! copies of themes ported here) because helix themes inherit them; those
+//! `inherits` lines name the renamed file. Two themes answering to
+//! one name is a bug (`Theme <name>` would silently pick one), so src/colors.zig
//! asserts the ring's names are distinct at comptime.
//!
//! Provenance: vendor/themes/*.toml are helix's own runtime themes (from
//! helix-editor/helix runtime/themes, each file keeping its author's header);
//! *.json are zed's (zed-industries/zed assets/themes). The licences sit beside
//! them as `<name>.LICENSE` — `helix.LICENSE` covering the runtime set, one per
-//! zed family, plus the twenty-two helix keeps in `runtime/themes/licenses/`
+//! zed family, plus the twenty-one helix keeps in `runtime/themes/licenses/`
//! for the themes it took from somewhere else (their names group by SOURCE, not
//! by file: `everforest.LICENSE` covers both everforest themes). build.zig's
//! directory read skips anything that is not a .toml or a .json, which is what
@@ -50,7 +54,7 @@ const Rgb = [3]u8;
/// pardes's Theme, minus the type: the generated file spells an anonymous
/// `.{...}` because a theme file deliberately imports NOTHING (it is data, not
-/// code) — src/pardes.zig's `fold` is what turns it into a real Theme.
+/// code) — src/colors.zig's `fold` is what turns it into a real Theme.
const Theme = struct {
name: []const u8,
bg: ?Rgb,
@@ -132,7 +136,7 @@ pub fn main(init: std.process.Init) !void {
}
// the INDEX, and the only reason it is generated rather than written: a zig
// file cannot list a directory at comptime, so the imports have to come
- // from whoever can. pardes.zig folds its declarations into the ring.
+ // from whoever can. colors.zig folds its declarations into the ring.
buf.clearRetainingCapacity();
try buf.writer.writeAll("// Generated by tools/gen_themes.zig. Do not edit.\n");
for (themes) |t| try buf.writer.print("pub const {s} = @import(\"{s}.zig\");\n", .{ t.name, t.name });
@@ -152,13 +156,14 @@ fn byName(_: void, a: Theme, b: Theme) bool {
fn emit(w: *std.Io.Writer, t: Theme) !void {
try w.writeAll("// Generated by tools/gen_themes.zig. Do not edit.\npub const theme = .{\n");
try w.print(" .name = \"{s}\",\n", .{t.name});
- inline for (@typeInfo(Theme).@"struct".fields) |f| {
- if (comptime std.mem.eql(u8, f.name, "name")) continue;
- if (comptime std.mem.eql(u8, f.name, "palette")) continue;
- try w.print(" .{s} = ", .{f.name});
- if (comptime @typeInfo(f.type) == .optional) {
- if (@field(t, f.name)) |c| try rgb(w, c) else try w.writeAll("null");
- } else try rgb(w, @field(t, f.name));
+ const info = @typeInfo(Theme).@"struct";
+ inline for (info.field_names, info.field_types) |name, T| {
+ if (comptime std.mem.eql(u8, name, "name")) continue;
+ if (comptime std.mem.eql(u8, name, "palette")) continue;
+ try w.print(" .{s} = ", .{name});
+ if (comptime @typeInfo(T) == .optional) {
+ if (@field(t, name)) |c| try rgb(w, c) else try w.writeAll("null");
+ } else try rgb(w, @field(t, name));
try w.writeAll(",\n");
}
if (t.palette) |p| {