From c9d5d97e4d487b92a52d765dd9c467423ddd1de1 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 16:45:54 -0300 Subject: A REPL's language is named and found as the syntax table finds one: aliases, any case Repl took only the grammar's exact name, and a file's language was found by a case-sensitive suffix of its path, apart from the aliases a code fence already had. The aliases move to grammar_manifest with byName and byPath, which syntax, Repl and langOf share, so `Repl py` and a .PY file work. The line-by-line warning is for the python language, not an id that starts with python. Joincol's doc line was sitting on Repl. Co-Authored-By: Claude Opus 5.5 --- src/builtins.zig | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/builtins.zig') diff --git a/src/builtins.zig b/src/builtins.zig index ed42dfe3..79c45325 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -903,7 +903,6 @@ pub const Tty9p = struct { }; /// Fold the active pane's column into the one on its right, keeping its panes. -/// The horizontal mirror of the vertical stacking `New` does. /// Binds this terminal as a language's REPL, by the language's name as the /// syntax table has it: an exec made on the body of a file in that /// language -- a middle click, the execute key, a single word like `ls` @@ -934,10 +933,11 @@ pub const Repl = struct { pane.repl = null; return c.p.setMessage(c.id, "Repl: unbound"); } - const grammars = @import("grammar_manifest.zig").all; - const lang: u8 = for (grammars, 0..) |g, i| { - if (g.exts.len > 0 and std.mem.eql(u8, g.name, arg)) break @intCast(i); - } else { + const manifest = @import("grammar_manifest.zig"); + const grammars = manifest.all; + // Named as a code fence names it: `py`, `Python`, `sh`. + const named: ?u8 = if (manifest.byName(arg)) |i| if (grammars[i].exts.len > 0) @intCast(i) else null else null; + const lang: u8 = named orelse { var w = std.Io.Writer.fixed(&buf); w.print("Repl: no language \"{s}\"; one of", .{arg[0..@min(arg.len, 32)]}) catch {}; for (grammars) |g| if (g.exts.len > 0) w.print(" {s}", .{g.name}) catch break; @@ -962,6 +962,7 @@ pub const Repl = struct { } }; +/// The horizontal mirror of the vertical stacking `New` does. pub const Joincol = struct { pub const scope: Scope = .session; pub fn run(c: Ctx) void { -- cgit v1.3