summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 16:45:54 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commitc9d5d97e4d487b92a52d765dd9c467423ddd1de1 (patch)
tree35547658ee733fb2631a41568c682c93b5fd4746 /src/builtins.zig
parentd09c1c36e4d4e1bc57aa14f5ba4c6131b6111429 (diff)
downloadpardes-c9d5d97e4d487b92a52d765dd9c467423ddd1de1.tar.gz
pardes-c9d5d97e4d487b92a52d765dd9c467423ddd1de1.zip
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 <[email protected]>
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig11
1 files changed, 6 insertions, 5 deletions
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 {