summaryrefslogtreecommitdiff
path: root/src/config.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.zig')
-rw-r--r--src/config.zig46
1 files changed, 44 insertions, 2 deletions
diff --git a/src/config.zig b/src/config.zig
index fb34b746..50009660 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -43,6 +43,7 @@ pub const leader_path = paths: {
.WsDiagnostics = "lD",
.Lspinfo = "li",
.Lspwhy = "lw",
+ .Callstack = "lb",
.Callers = "lc",
.Callees = "lC",
.Supertypes = "lt",
@@ -67,6 +68,9 @@ pub const leader_path = paths: {
.Putall = null,
.Incl = null,
.Tab = null,
+ .CallstackDepth = null,
+ .CallstackLayout = null,
+ .CallstackCorners = null,
.Zerox = null,
.ClipYank = "y",
.ClipYankMain = "Y",
@@ -580,7 +584,8 @@ pub const goto_line_down: []const Chord = &.{.{ .cp = 'j' }};
pub const goto_line_up: []const Chord = &.{.{ .cp = 'k' }};
pub const goto_column: []const Chord = &.{.{ .cp = '|' }};
pub const goto_view_top: []const Chord = &.{.{ .cp = 't' }};
-pub const goto_view_center: []const Chord = &.{.{ .cp = 'c' }};
+// gc opens Callstack; it no longer moves the cursor to the viewport center.
+pub const goto_view_center: []const Chord = &.{};
pub const goto_view_bottom: []const Chord = &.{.{ .cp = 'b' }};
pub const goto_last_modification: []const Chord = &.{.{ .cp = '.' }};
pub const goto_word: []const Chord = &.{.{ .cp = 'w' }};
@@ -591,6 +596,7 @@ pub const goto_declaration: []const Chord = &.{.{ .cp = 'D' }};
pub const goto_type_definition: []const Chord = &.{.{ .cp = 'y' }};
pub const goto_implementation: []const Chord = &.{.{ .cp = 'i' }};
pub const goto_references: []const Chord = &.{.{ .cp = 'r' }};
+pub const goto_callstack: []const Chord = &.{.{ .cp = 'c' }};
pub const match_bracket: []const Chord = &.{.{ .cp = 'm' }};
pub const match_inside = 'i';
@@ -835,6 +841,9 @@ pub const Runtime = struct {
/// acme's Tab: a tab's width in cells, in every pane (config.tab_now
/// is what the drawing and the column arithmetic read).
tab: u16 = tab_width,
+ callstack_layout: CallstackLayout = .stacked,
+ callstack_corners: CallstackCorners = .rounded,
+ callstack_depth: u8 = @import("lsp/lsp.zig").callstack_default_depth,
pub const ShaderAnimation = enum { off, on, always };
pub const Placement = enum { acme, pardes };
@@ -845,8 +854,10 @@ pub const Runtime = struct {
pub const Pager = enum { pardes, off };
pub const TermImages = enum { real, petscii };
pub const JumpScope = enum { file, all };
+ pub const CallstackLayout = enum { @"inline", stacked };
+ pub const CallstackCorners = @import("lsp/lsp.zig").CallstackCorners;
/// 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 };
+ pub const Choice = enum { placement, boot_shell, look_word, dir_look, diff_look, pager, term_images, jump_scope, callstack_layout, callstack_corners };
/// 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
@@ -1034,6 +1045,7 @@ pub const Runtime = struct {
inactive_dim,
grip_width,
tab,
+ callstack_depth,
transition: animation.Transition,
scene: Scene,
/// A Shadertoy file into the post chain or out of it; `off` empties
@@ -1118,6 +1130,9 @@ pub const Runtime = struct {
.{ .word = "PagerColor", .action = .{ .toggle = .pager_color }, .doc = "A +Pager keeps its program's colours, on or off; for the next text paged." },
.{ .word = "TermImages", .action = .{ .choice = .term_images }, .doc = "How a new terminal draws its program's kitty graphics: real, as pixels where it can, or petscii, as glyph art." },
.{ .word = "JumpScope", .action = .{ .choice = .jump_scope }, .doc = "What Back and Forward keep to: file, the focused pane's file until it runs out that way, or all, every place in order." },
+ .{ .word = "CallstackLayout", .action = .{ .choice = .callstack_layout }, .doc = "Callstack snippets below their locations (stacked, the default) or beside them (inline); bare, it switches layouts. Applies to the next Callstack query." },
+ .{ .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." },
};
@@ -1319,6 +1334,12 @@ pub const Runtime = struct {
if (percent < 50 or percent > 300) return false;
state.grip_width = percent;
},
+ .callstack_depth => {
+ const text = std.mem.trim(u8, argument orelse return false, " \t\r\n");
+ const depth = std.fmt.parseInt(u8, text, 10) catch return false;
+ if (depth < 1 or depth > @import("lsp/lsp.zig").callstack_max_depth) return false;
+ state.callstack_depth = depth;
+ },
.tab => {
const text = std.mem.trim(u8, argument orelse return false, " \t\r\n");
const width = std.fmt.parseInt(u16, text, 10) catch return false;
@@ -1361,6 +1382,7 @@ pub const Runtime = struct {
.inactive_dim, .window_opacity, .window_blur => "0-100 (a percentage)",
.grip_width => "50-300 (a percentage)",
.tab => "1-16 (cells)",
+ .callstack_depth => "1-64 (levels)",
.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",
@@ -1523,6 +1545,7 @@ pub const Runtime = struct {
try out.print("# {s} unsupported\n", .{setting.word}),
.motion => try out.print("{s} {s}\n", .{ setting.word, @tagName(state.motion) }),
.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 }),
.grip_width => if (setting.enabled(context.capabilities))
try out.print("{s} {d}\n", .{ setting.word, state.grip_width })
@@ -1816,11 +1839,14 @@ pub const Runtime = struct {
.pager => "off",
.term_images => "petscii",
.jump_scope => "all",
+ .callstack_layout => "inline",
+ .callstack_corners => "square",
},
.lift => "rim",
.motion => "playful",
.inactive_dim => "35",
.grip_width => "200",
+ .callstack_depth => "16",
.tab => "8",
else => null,
};
@@ -1892,11 +1918,14 @@ pub const Runtime = struct {
.pager => "Pager off\n",
.term_images => "TermImages petscii\n",
.jump_scope => "JumpScope all\n",
+ .callstack_layout => "CallstackLayout inline\n",
+ .callstack_corners => "CallstackCorners square\n",
},
.lift => "Lift rim\n",
.motion => "Motion playful\n",
.inactive_dim => "InactiveDim 35\n",
.grip_width => "GripWidth 200\n",
+ .callstack_depth => "CallstackDepth 16\n",
.tab => "Tab 8\n",
.theme, .font => unreachable,
};
@@ -2474,3 +2503,16 @@ test "reference.typ's #fstree is the tree the session serves, file for file" {
};
if (drift) return error.FsTreeDrift;
}
+
+test "CallstackDepth is bounded and keeps the last valid runtime limit" {
+ var state: Runtime = .{};
+ try std.testing.expectEqual(@as(u8, 8), state.callstack_depth);
+ for ([_][]const u8{ "1", "8", "16", "64" }) |value| {
+ try std.testing.expect(Runtime.apply(&state, Runtime.find("CallstackDepth").?, value));
+ try std.testing.expectEqual(try std.fmt.parseInt(u8, value, 10), state.callstack_depth);
+ }
+ for ([_][]const u8{ "0", "65", "256", "-1", "eight", "" }) |value| {
+ try std.testing.expect(!Runtime.apply(&state, Runtime.find("CallstackDepth").?, value));
+ try std.testing.expectEqual(@as(u8, 64), state.callstack_depth);
+ }
+}