feat: add vim mode keybindings for setting integer argument

This commit is contained in:
CJ van den Berg 2025-04-08 18:23:40 +02:00
parent ec483d34d5
commit ae815043d9
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 20 additions and 2 deletions

View file

@ -41,7 +41,6 @@
["n", "goto_next_match"],
["N", "goto_prev_match"],
["0", "move_begin"],
["^", "smart_move_begin"],
["$", "move_end"],
[":", "open_command_palette"],
@ -90,7 +89,18 @@
["f", "move_to_char", "move_to_char_right"],
["<C-CR>", ["move_down"], ["move_begin"]],
["<CR>", ["move_down"], ["move_begin"]]
["<CR>", ["move_down"], ["move_begin"]],
["0", "move_begin_or_add_integer_argument_zero"],
["1", "add_integer_argument_digit", 1],
["2", "add_integer_argument_digit", 2],
["3", "add_integer_argument_digit", 3],
["4", "add_integer_argument_digit", 4],
["5", "add_integer_argument_digit", 5],
["6", "add_integer_argument_digit", 6],
["7", "add_integer_argument_digit", 7],
["8", "add_integer_argument_digit", 8],
["9", "add_integer_argument_digit", 9]
]
},
"visual": {

View file

@ -46,6 +46,14 @@ const cmds_ = struct {
}
pub const @"wq!_meta": Meta = .{ .description = "wq! (write file and quit without saving)" };
pub fn move_begin_or_add_integer_argument_zero(_: *void, _: Ctx) Result {
return if (@import("keybind").current_integer_argument()) |_|
command.executeName("add_integer_argument_digit", command.fmt(.{0}))
else
command.executeName("move_begin", .{});
}
pub const move_begin_or_add_integer_argument_zero_meta: Meta = .{ .description = "Move cursor to beginning of line (vim)" };
pub fn enter_mode_at_next_char(self: *void, ctx: Ctx) Result {
_ = self; // autofix
_ = ctx; // autofix