Add provider-aware diagnostics rail

This commit is contained in:
slhx agent
2026-06-21 13:56:46 +02:00
parent 264dedb47c
commit 5224fe4c6a
3 changed files with 432 additions and 1 deletions
+56
View File
@@ -14,6 +14,7 @@ pub const Feature = enum {
search,
panel_close,
lsp,
diagnostics,
};
pub const Action = union(enum) {
@@ -28,6 +29,10 @@ pub const Action = union(enum) {
hover,
signature,
expand_hover,
diagnostics_open,
diagnostics_next,
diagnostics_previous,
diagnostics_filter,
repeat_rail,
restore_last,
not_built: Feature,
@@ -46,6 +51,7 @@ const Mode = enum {
symbol_rail,
search_rail,
language_rail,
diagnostic_rail,
open_prompt,
};
@@ -71,6 +77,7 @@ pub const Leader = struct {
.symbol_rail => return self.handleSymbolRail(event),
.search_rail => return self.handleSearchRail(event),
.language_rail => return self.handleLanguageRail(event),
.diagnostic_rail => return self.handleDiagnosticRail(event),
.open_prompt => return self.handleOpenPrompt(event),
}
}
@@ -83,6 +90,7 @@ pub const Leader = struct {
.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",
.diagnostic_rail => "diagnostics: d/open n next p previous f filter-source",
.open_prompt => "open: type path, Enter opens, Esc cancels",
};
}
@@ -131,6 +139,10 @@ pub const Leader = struct {
self.mode = .language_rail;
return .none;
}
if (std.mem.eql(u8, text, "d")) {
self.mode = .diagnostic_rail;
return .diagnostics_open;
}
if (std.mem.eql(u8, text, "q")) {
self.mode = .idle;
return .quit;
@@ -216,6 +228,50 @@ pub const Leader = struct {
}
}
fn handleDiagnosticRail(self: *Leader, event: input.Event) Action {
self.message = null;
switch (event) {
.text => |text| {
if (std.mem.eql(u8, text, "d")) {
self.mode = .idle;
return .diagnostics_open;
}
if (std.mem.eql(u8, text, "n")) {
self.mode = .idle;
return .diagnostics_next;
}
if (std.mem.eql(u8, text, "p")) {
self.mode = .idle;
return .diagnostics_previous;
}
if (std.mem.eql(u8, text, "f")) {
self.mode = .idle;
return .diagnostics_filter;
}
self.mode = .idle;
self.message = "unknown diagnostics key";
return .none;
},
.key => |key| switch (key) {
.escape, .backspace => {
self.mode = .idle;
self.message = "diagnostics cancelled";
return .none;
},
else => {
self.mode = .idle;
self.message = "unknown diagnostics key";
return .none;
},
},
.unknown => {
self.mode = .idle;
self.message = "unknown diagnostics key";
return .none;
},
}
}
fn handleSearchRail(self: *Leader, event: input.Event) Action {
self.message = null;
switch (event) {