Add first-class job rail profiles
This commit is contained in:
@@ -15,6 +15,7 @@ pub const Feature = enum {
|
||||
panel_close,
|
||||
lsp,
|
||||
diagnostics,
|
||||
jobs,
|
||||
};
|
||||
|
||||
pub const Action = union(enum) {
|
||||
@@ -33,6 +34,14 @@ pub const Action = union(enum) {
|
||||
diagnostics_next,
|
||||
diagnostics_previous,
|
||||
diagnostics_filter,
|
||||
job_lint_file,
|
||||
job_lint_project,
|
||||
job_build,
|
||||
job_test,
|
||||
job_check,
|
||||
job_cancel,
|
||||
job_jump,
|
||||
job_yank,
|
||||
repeat_rail,
|
||||
restore_last,
|
||||
not_built: Feature,
|
||||
@@ -52,6 +61,7 @@ const Mode = enum {
|
||||
search_rail,
|
||||
language_rail,
|
||||
diagnostic_rail,
|
||||
tool_rail,
|
||||
open_prompt,
|
||||
};
|
||||
|
||||
@@ -78,6 +88,7 @@ pub const Leader = struct {
|
||||
.search_rail => return self.handleSearchRail(event),
|
||||
.language_rail => return self.handleLanguageRail(event),
|
||||
.diagnostic_rail => return self.handleDiagnosticRail(event),
|
||||
.tool_rail => return self.handleToolRail(event),
|
||||
.open_prompt => return self.handleOpenPrompt(event),
|
||||
}
|
||||
}
|
||||
@@ -91,6 +102,7 @@ pub const Leader = struct {
|
||||
.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",
|
||||
.tool_rail => "tools: l lint-file L lint-project b build t test c check x cancel j jump y yank",
|
||||
.open_prompt => "open: type path, Enter opens, Esc cancels",
|
||||
};
|
||||
}
|
||||
@@ -143,6 +155,10 @@ pub const Leader = struct {
|
||||
self.mode = .diagnostic_rail;
|
||||
return .diagnostics_open;
|
||||
}
|
||||
if (std.mem.eql(u8, text, "t")) {
|
||||
self.mode = .tool_rail;
|
||||
return .none;
|
||||
}
|
||||
if (std.mem.eql(u8, text, "q")) {
|
||||
self.mode = .idle;
|
||||
return .quit;
|
||||
@@ -272,6 +288,42 @@ pub const Leader = struct {
|
||||
}
|
||||
}
|
||||
|
||||
fn handleToolRail(self: *Leader, event: input.Event) Action {
|
||||
self.message = null;
|
||||
switch (event) {
|
||||
.text => |text| {
|
||||
self.mode = .idle;
|
||||
if (std.mem.eql(u8, text, "l")) return .job_lint_file;
|
||||
if (std.mem.eql(u8, text, "L")) return .job_lint_project;
|
||||
if (std.mem.eql(u8, text, "b")) return .job_build;
|
||||
if (std.mem.eql(u8, text, "t")) return .job_test;
|
||||
if (std.mem.eql(u8, text, "c")) return .job_check;
|
||||
if (std.mem.eql(u8, text, "x")) return .job_cancel;
|
||||
if (std.mem.eql(u8, text, "j")) return .job_jump;
|
||||
if (std.mem.eql(u8, text, "y")) return .job_yank;
|
||||
self.message = "unknown tool key";
|
||||
return .none;
|
||||
},
|
||||
.key => |key| switch (key) {
|
||||
.escape, .backspace => {
|
||||
self.mode = .idle;
|
||||
self.message = "tools cancelled";
|
||||
return .none;
|
||||
},
|
||||
else => {
|
||||
self.mode = .idle;
|
||||
self.message = "unknown tool key";
|
||||
return .none;
|
||||
},
|
||||
},
|
||||
.unknown => {
|
||||
self.mode = .idle;
|
||||
self.message = "unknown tool key";
|
||||
return .none;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn handleSearchRail(self: *Leader, event: input.Event) Action {
|
||||
self.message = null;
|
||||
switch (event) {
|
||||
|
||||
Reference in New Issue
Block a user