refactor: simplify match mode
This commit is contained in:
parent
124cbcbe5f
commit
0b80ae50db
2 changed files with 16 additions and 48 deletions
|
|
@ -169,7 +169,12 @@
|
||||||
[";", "collapse_selections"],
|
[";", "collapse_selections"],
|
||||||
["x", "extend_line_below"],
|
["x", "extend_line_below"],
|
||||||
|
|
||||||
["m", "match"],
|
["m m", "match_brackets"],
|
||||||
|
["m a", "match", "select_textobject_around"],
|
||||||
|
["m i", "match", "select_textobject_inner"],
|
||||||
|
["m d", "match", "surround_delete"],
|
||||||
|
["m r", "match", "surround_replace"],
|
||||||
|
["m s", "match", "surround_add"],
|
||||||
|
|
||||||
["[ D", "goto_first_diag"],
|
["[ D", "goto_first_diag"],
|
||||||
["[ G", "goto_first_change"],
|
["[ G", "goto_first_change"],
|
||||||
|
|
@ -459,11 +464,11 @@
|
||||||
["x", "extend_line_below"],
|
["x", "extend_line_below"],
|
||||||
|
|
||||||
["m m", "match_brackets", "helix_sel_mode"],
|
["m m", "match_brackets", "helix_sel_mode"],
|
||||||
["m s", "surround_add"],
|
["m a", "match", "select_textobject_around"],
|
||||||
["m r", "surround_replace"],
|
["m i", "match", "select_textobject_inner"],
|
||||||
["m d", "surround_delete"],
|
["m d", "match", "surround_delete"],
|
||||||
["m a", "select_textobject_around"],
|
["m r", "match", "surround_replace"],
|
||||||
["m i", "select_textobject_inner"],
|
["m s", "match", "surround_add"],
|
||||||
|
|
||||||
["[ D", "goto_first_diag"],
|
["[ D", "goto_first_diag"],
|
||||||
["[ G", "goto_first_change"],
|
["[ G", "goto_first_change"],
|
||||||
|
|
|
||||||
|
|
@ -18,48 +18,11 @@ pub fn name(self: *Type) []const u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_egc(self: *Type, egc: []const u8) command.Result {
|
pub fn process_egc(self: *Type, egc: []const u8) command.Result {
|
||||||
var prev: []const u8 = "";
|
var action: []const u8 = "";
|
||||||
if ((self.ctx.args.match(.{tp.extract(&prev)}) catch false)) {
|
if ((self.ctx.args.match(.{tp.extract(&action)}) catch false)) {
|
||||||
if (std.mem.eql(u8, prev, "mi")) {
|
try command.executeName(action, command.fmt(.{egc}));
|
||||||
command.executeName("select_textobject_inner", command.fmt(.{egc})) catch {
|
|
||||||
try command.executeName("exit_mini_mode", .{});
|
|
||||||
};
|
|
||||||
} else if (std.mem.eql(u8, prev, "ma")) {
|
|
||||||
command.executeName("select_textobject_around", command.fmt(.{egc})) catch {
|
|
||||||
try command.executeName("exit_mini_mode", .{});
|
|
||||||
};
|
|
||||||
} else if (std.mem.eql(u8, prev, "md")) {
|
|
||||||
command.executeName("surround_delete", command.fmt(.{egc})) catch {
|
|
||||||
try command.executeName("exit_mini_mode", .{});
|
|
||||||
};
|
|
||||||
} else if (std.mem.eql(u8, prev, "mr")) {
|
|
||||||
command.executeName("surround_replace", command.fmt(.{egc})) catch {
|
|
||||||
try command.executeName("exit_mini_mode", .{});
|
|
||||||
};
|
|
||||||
} else if (std.mem.eql(u8, prev, "ms")) {
|
|
||||||
command.executeName("surround_add", command.fmt(.{egc})) catch {
|
|
||||||
try command.executeName("exit_mini_mode", .{});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
try command.executeName("exit_mini_mode", .{});
|
|
||||||
} else {
|
|
||||||
if (std.mem.eql(u8, egc, "i")) {
|
|
||||||
try command.executeName("match", command.fmt(.{"mi"}));
|
|
||||||
} else if (std.mem.eql(u8, egc, "a")) {
|
|
||||||
try command.executeName("match", command.fmt(.{"ma"}));
|
|
||||||
} else if (std.mem.eql(u8, egc, "d")) {
|
|
||||||
try command.executeName("match", command.fmt(.{"md"}));
|
|
||||||
} else if (std.mem.eql(u8, egc, "r")) {
|
|
||||||
try command.executeName("match", command.fmt(.{"mr"}));
|
|
||||||
} else if (std.mem.eql(u8, egc, "s")) {
|
|
||||||
try command.executeName("match", command.fmt(.{"ms"}));
|
|
||||||
} else if (std.mem.eql(u8, egc, "m")) {
|
|
||||||
command.executeName("match_brackets", .{}) catch {
|
|
||||||
try command.executeName("exit_mini_mode", .{});
|
|
||||||
};
|
|
||||||
try command.executeName("exit_mini_mode", .{});
|
|
||||||
} else {
|
} else {
|
||||||
|
try command.executeName("match_brackets", .{});
|
||||||
|
}
|
||||||
try command.executeName("exit_mini_mode", .{});
|
try command.executeName("exit_mini_mode", .{});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue