Add compact language assistance rails

This commit is contained in:
slhx agent
2026-06-21 13:34:40 +02:00
parent 7e639dd87f
commit 264dedb47c
3 changed files with 280 additions and 11 deletions
+42
View File
@@ -13,6 +13,7 @@ test {
pub const Feature = enum {
search,
panel_close,
lsp,
};
pub const Action = union(enum) {
@@ -24,6 +25,9 @@ pub const Action = union(enum) {
file_picker,
search_file,
search_project,
hover,
signature,
expand_hover,
repeat_rail,
restore_last,
not_built: Feature,
@@ -41,6 +45,7 @@ const Mode = enum {
rail,
symbol_rail,
search_rail,
language_rail,
open_prompt,
};
@@ -65,6 +70,7 @@ pub const Leader = struct {
.rail => return self.handleRail(event),
.symbol_rail => return self.handleSymbolRail(event),
.search_rail => return self.handleSearchRail(event),
.language_rail => return self.handleLanguageRail(event),
.open_prompt => return self.handleOpenPrompt(event),
}
}
@@ -76,6 +82,7 @@ pub const Leader = struct {
.rail => "leader: w save q quit o open p symbols s search r repeat x close",
.symbol_rail => symbol_mod.rail_status,
.search_rail => "search: f current file p project s symbols",
.language_rail => "language: h hover s signature o open hover",
.open_prompt => "open: type path, Enter opens, Esc cancels",
};
}
@@ -120,6 +127,10 @@ pub const Leader = struct {
self.mode = .search_rail;
return .none;
}
if (std.mem.eql(u8, text, "l")) {
self.mode = .language_rail;
return .none;
}
if (std.mem.eql(u8, text, "q")) {
self.mode = .idle;
return .quit;
@@ -174,6 +185,37 @@ pub const Leader = struct {
}
}
fn handleLanguageRail(self: *Leader, event: input.Event) Action {
self.message = null;
switch (event) {
.text => |text| {
self.mode = .idle;
if (std.mem.eql(u8, text, "h")) return .hover;
if (std.mem.eql(u8, text, "s")) return .signature;
if (std.mem.eql(u8, text, "o")) return .expand_hover;
self.message = "language action is not built in this profile yet";
return .{ .not_built = .lsp };
},
.key => |key| switch (key) {
.escape, .backspace => {
self.mode = .idle;
self.message = "language cancelled";
return .none;
},
else => {
self.mode = .idle;
self.message = "unknown language key";
return .none;
},
},
.unknown => {
self.mode = .idle;
self.message = "unknown language key";
return .none;
},
}
}
fn handleSearchRail(self: *Leader, event: input.Event) Action {
self.message = null;
switch (event) {