summaryrefslogtreecommitdiff
path: root/src/config.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-24 11:57:26 -0300
committerGabriel Schneider <[email protected]>2026-10-24 11:57:35 -0300
commit51903dd947f90381d1a908c488a019289a1c8413 (patch)
treeab5b2574642493c60476e6e9bcd7cc0e1c5e8d9e /src/config.zig
parent18d89dcedaed1f8437799621675e88ca47d7cdc1 (diff)
downloadpardes-51903dd947f90381d1a908c488a019289a1c8413.tar.gz
pardes-51903dd947f90381d1a908c488a019289a1c8413.zip
Search converge 3/6: the query pane, line 1 the query and its first word the source, rows made live like Callstack's, the owner's places showing the set, a +Preview promoted in place, Enter freezes, Esc restores
Diffstat (limited to 'src/config.zig')
-rw-r--r--src/config.zig54
1 files changed, 53 insertions, 1 deletions
diff --git a/src/config.zig b/src/config.zig
index 06eec2d9..2fa4a55d 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -26,6 +26,26 @@ pub const leader_help: u8 = '?';
const undecided: []const u8 = "<undecided>";
+/// Leader paths that run a builtin WITH an argument (the pick prototype's):
+/// the query pane's sources that have no word of their own, `Search` and
+/// line 1. `SPC s` is the session group (Dump, Restore, Attach), so the
+/// declarations are `SPC s s`, a key from helix's.
+pub const leader_args = [_]struct { path: []const u8, cmd: Builtin, arg: []const u8 }{
+ .{ .path = "bb", .cmd = .Search, .arg = "Panes" },
+ .{ .path = "ss", .cmd = .Search, .arg = "Symbols" },
+ .{ .path = "/", .cmd = .Search, .arg = "All" },
+};
+
+comptime {
+ @setEvalBranchQuota(20_000);
+ // A path here is a leaf: no builtin's path is it or runs past it, and
+ // none of it is a builtin's whole path.
+ for (leader_args) |la| for (std.enums.values(Builtin)) |b| if (leader_path.get(b)) |path| {
+ if (std.mem.startsWith(u8, path, la.path) or std.mem.startsWith(u8, la.path, path))
+ @compileError("leader_args path collides with " ++ @tagName(b) ++ ": " ++ la.path);
+ };
+}
+
// null means word/chord-only. Every enabled builtin must explicitly choose a path.
pub const leader_path = paths: {
@setEvalBranchQuota(10_000); // a check per builtin, and they grow
@@ -94,6 +114,11 @@ pub const leader_path = paths: {
.Delcol = "cd",
.Joincol = "cj",
.Placement = "cp",
+ .SearchPlace = null,
+ .SearchPane = null,
+ .SearchRows = null,
+ .Search = null,
+ .Panes = null,
.BootShell = null,
.LookWord = null,
.DirLook = null,
@@ -517,6 +542,7 @@ pub const dump_config_buffer = "+DumpConfig";
pub const effect_code_buffer = "+EffectCode";
pub const jumps_buffer = "+Jumps";
pub const recent_buffer = "+Recent";
+pub const preview_buffer = "+Preview";
pub const unsaved_buffer = "+Unsaved";
pub const themes_buffer = "+Themes";
pub const fonts_buffer = "+Fonts";
@@ -846,6 +872,15 @@ pub const Runtime = struct {
callstack_layout: CallstackLayout = .stacked,
callstack_corners: CallstackCorners = .rounded,
callstack_depth: u8 = @import("lsp/lsp.zig").callstack_default_depth,
+ /// Where a query pane goes (Query.zig): `attached`, under the pane that
+ /// asked, out of its rows alone; `column`, in the finder column.
+ search_place: SearchPlace = .attached,
+ /// A search from a pane that has a query pane: `reuse` it (its frozen
+ /// rows back on Esc), or open a `new` one, the last left where it is.
+ search_pane: SearchPane = .reuse,
+ /// The body rows a query pane is born with under its line 1 (and its
+ /// +Preview with): it never resizes itself after.
+ search_rows: u16 = 8,
pub const ShaderAnimation = enum { off, on, always };
pub const Placement = enum { acme, pardes };
@@ -858,8 +893,10 @@ pub const Runtime = struct {
pub const JumpScope = enum { file, all };
pub const CallstackLayout = enum { @"inline", stacked };
pub const CallstackCorners = @import("lsp/lsp.zig").CallstackCorners;
+ pub const SearchPlace = enum { attached, column };
+ pub const SearchPane = enum { reuse, new };
/// A setting that is one of a few words, each an enum field of Runtime.
- pub const Choice = enum { placement, boot_shell, look_word, dir_look, diff_look, pager, term_images, jump_scope, callstack_layout, callstack_corners };
+ pub const Choice = enum { placement, boot_shell, look_word, dir_look, diff_look, pager, term_images, jump_scope, callstack_layout, callstack_corners, search_place, search_pane };
/// shadow: a soft drop shadow. rim: a light hairline along the top of
/// the focused pane's tag rows. auto: a shadow on a light page; on a
@@ -1048,6 +1085,7 @@ pub const Runtime = struct {
grip_width,
tab,
callstack_depth,
+ search_rows,
transition: animation.Transition,
scene: Scene,
/// A Shadertoy file into the post chain or out of it; `off` empties
@@ -1137,6 +1175,9 @@ pub const Runtime = struct {
.{ .word = "CallstackCorners", .action = .{ .choice = .callstack_corners }, .doc = "Callstack tree corners: rounded (the default) or square; bare, it switches styles. Applies to the next Callstack query." },
.{ .word = "CallstackDepth", .action = .callstack_depth, .doc = "Caller levels collected by Callstack, 1 through 64; default 8. Bare, it says the current limit." },
.{ .word = "Tab", .action = .tab, .doc = "A tab's width in cells, 1 through 16, in every pane; bare, it says the width." },
+ .{ .word = "SearchPlace", .action = .{ .choice = .search_place }, .doc = "Where a query pane goes: attached, under the pane that asked, out of its rows alone, or column, in the finder column." },
+ .{ .word = "SearchPane", .action = .{ .choice = .search_pane }, .doc = "A search from a pane that has a query pane: reuse it, or open a new one and leave the last where it is." },
+ .{ .word = "SearchRows", .action = .search_rows, .doc = "The rows a query pane is born with under its line 1, 1 through 100; default 8. It never resizes itself." },
};
pub fn find(name: []const u8) ?Setting {
@@ -1311,6 +1352,7 @@ pub const Runtime = struct {
.grip_width => state.grip_width = number(u16, argument, " \t\r\n%", 50, 300) orelse return false,
.callstack_depth => state.callstack_depth = number(u8, argument, " \t\r\n", 1, @import("lsp/lsp.zig").callstack_max_depth) orelse return false,
.tab => state.tab = number(u16, argument, " \t\r\n", 1, 16) orelse return false,
+ .search_rows => state.search_rows = number(u16, argument, " \t\r\n", 1, 100) orelse return false,
.theme, .font => return false,
}
return true;
@@ -1348,6 +1390,7 @@ pub const Runtime = struct {
.grip_width => "50-300 (a percentage)",
.tab => "1-16 (cells)",
.callstack_depth => "1-64 (levels)",
+ .search_rows => "1-100 (rows)",
.tagline_size => std.fmt.comptimePrint("{d}-{d} (a percentage)", .{ tagline_percent_min, tagline_percent_max }),
.message_ms => std.fmt.comptimePrint("0-{d} (milliseconds)", .{message_ms_max}),
.shell => "a path of at most 255 bytes; bare, $SHELL, else /bin/sh",
@@ -1490,6 +1533,7 @@ pub const Runtime = struct {
.inactive_dim => try out.print("{s} {d}\n", .{ setting.word, state.inactive_dim }),
.callstack_depth => try out.print("{s} {d}\n", .{ setting.word, state.callstack_depth }),
.tab => try out.print("{s} {d}\n", .{ setting.word, state.tab }),
+ .search_rows => try out.print("{s} {d}\n", .{ setting.word, state.search_rows }),
.grip_width => try out.print("{s} {d}\n", .{ setting.word, state.grip_width }),
};
if (context.locations.len > 0) try out.print("LocationsConfig {s}\n", .{context.locations});
@@ -1773,6 +1817,8 @@ pub const Runtime = struct {
.jump_scope => "all",
.callstack_layout => "inline",
.callstack_corners => "square",
+ .search_place => "column",
+ .search_pane => "new",
},
.lift => "rim",
.motion => "playful",
@@ -1780,6 +1826,7 @@ pub const Runtime = struct {
.grip_width => "200",
.callstack_depth => "16",
.tab => "8",
+ .search_rows => "12",
else => null,
};
try std.testing.expect(apply(&state, setting, argument));
@@ -1853,6 +1900,8 @@ pub const Runtime = struct {
.jump_scope => "JumpScope all\n",
.callstack_layout => "CallstackLayout inline\n",
.callstack_corners => "CallstackCorners square\n",
+ .search_place => "SearchPlace column\n",
+ .search_pane => "SearchPane new\n",
},
.lift => "Lift rim\n",
.motion => "Motion playful\n",
@@ -1860,6 +1909,7 @@ pub const Runtime = struct {
.grip_width => "GripWidth 200\n",
.callstack_depth => "CallstackDepth 16\n",
.tab => "Tab 8\n",
+ .search_rows => "SearchRows 12\n",
.theme, .font => unreachable,
};
try std.testing.expect(std.mem.indexOf(u8, report, expected) != null);
@@ -2212,6 +2262,7 @@ const doc_typ = struct {
if (n == 0) return leader.len == 1 and leader[0].cp == ' ';
for (std.enums.values(Builtin)) |b| if (leader_path.get(b)) |p|
if (std.mem.eql(u8, p, path[0..n])) return true;
+ for (leader_args) |la| if (std.mem.eql(u8, la.path, path[0..n])) return true;
return false;
}
toks.reset();
@@ -2308,6 +2359,7 @@ const doc_tutor = struct {
fn path(keys: []const u8) bool {
for (std.enums.values(Builtin)) |b| if (leader_path.get(b)) |p|
if (std.mem.startsWith(u8, p, keys)) return true;
+ for (leader_args) |la| if (std.mem.startsWith(u8, la.path, keys)) return true;
return false;
}