From 046979b877f02a91cf52cc86b84c5619cb9363d3 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 6 Oct 2026 19:06:32 -0300 Subject: Def and Refs in a language-served file's tag, a diff viewer's tinted word edits, context rows that hold still under a scroll, and the pardes skill Def and Refs (gd, gr, Ctrl-click; chorded 2-1 at the selection) for a file a language server speaks for; hunks.zig stacks a unified diff as a diff viewer does, its changed words on a tinted ground as delta's do; the tree-sitter context rows stay put while the body glides under a scroll; .agents/skills gains the pardes skill beside pardes-9p. --- src/builtins.zig | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'src/builtins.zig') diff --git a/src/builtins.zig b/src/builtins.zig index 77e1169d..c1424b2f 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -46,6 +46,10 @@ pub const PaneKind = enum { /// An image pane, or a terminal, whose program's kitty graphics are /// pictures too. picture, + /// A terminal, or a +Pager: a program's colours. + program_colors, + /// A text pane showing a diff: a .diff, a .patch, a +Pager holding one. + diff, pub fn has(kind: PaneKind, pane: *const panes.Pane) bool { return switch (kind) { @@ -53,6 +57,9 @@ pub const PaneKind = enum { .pdf => pane.hasPdf(), .image => pane.image != null, .picture => pane.image != null or pane.isTerminal(), + .program_colors => pane.isTerminal() or (pane.file != null and pane.file.?.pager), + .diff => if (pane.file) |f| pane.colorAlgo() == .diff or + (f.output != null and std.meta.eql(f.output.?.from, panes.Output.Origin{ .cmd = .Diff })) else false, }; } @@ -62,6 +69,8 @@ pub const PaneKind = enum { .pdf => "a PDF", .image => "an image", .picture => "an image or a terminal", + .program_colors => "a terminal or a +Pager", + .diff => "a diff or a +Diff", }; } }; @@ -1336,14 +1345,28 @@ pub const Del = struct { } }; -/// Recolour a terminal's program colours to the theme, or show them as sent, flipping between them. +/// Recolour a terminal's or a +Pager's program colours to the theme, or show them as sent, flipping between them. pub const Filter = struct { - pub const needs: PaneKind = .terminal; + pub const needs: PaneKind = .program_colors; pub fn run(c: Ctx) void { c.pane.tty_filter = !c.pane.tty_filter; } }; +/// Stack a diff's hunks as a diff viewer shows them, each under its place and the declarations around it, in a +Diff; on a +Diff, show the diff itself as text. +pub const Diff = struct { + pub const needs: PaneKind = .diff; + pub const output: OutputTraits = .{ .name = config.diff_buffer, .steps = true, .locations = true }; + pub fn run(c: Ctx) void { + const f = &c.pane.file.?; + if (panes.Output.diffSource(c.p, f)) |source| return panes.Output.showDiffText(c.p, c.id, source); + _ = panes.Output.openDiff(c.p, c.id, f.path, f.content) catch |err| switch (err) { + error.NoHunks => c.p.reportFailure(c.id, "Diff: no hunk in it"), + else => c.p.reportError(c.id, "hunks", err), + }; + } +}; + /// Cycle the pane's input modes: terminals add raw tty mode to normal/insert. pub const Mode = struct { pub fn run(c: Ctx) void { @@ -1851,6 +1874,28 @@ pub const Jumplist = struct { // ---- the language group ---- +/// Go to the definition of the symbol under the cursor; with an argument +/// (a 2-1 chord's selection), of that symbol, where it is nearest. +pub const Def = struct { + pub const takes_arg = true; + /// Its answer says what it found, a jump or a list or why not; its + /// name would only stack above it, as gd never did. + pub const quiet = true; + pub fn run(c: Ctx) void { + c.p.lspRequest(c.id, .definition, std.mem.trim(u8, c.arg orelse "", " \t\r\n")); + } +}; + +/// List the references to the symbol under the cursor; with an argument +/// (a 2-1 chord's selection), to that symbol, where it is nearest. +pub const Refs = struct { + pub const takes_arg = true; + pub const quiet = true; // as Def + pub fn run(c: Ctx) void { + c.p.lspRequest(c.id, .references, std.mem.trim(u8, c.arg orelse "", " \t\r\n")); + } +}; + /// Ask the language server about the symbol under the cursor. pub const Hover = struct { pub fn run(c: Ctx) void { -- cgit v1.3