get some basic vim navigation working
This commit is contained in:
parent
cf0cf7aaa6
commit
b957e53bad
2 changed files with 29 additions and 11 deletions
|
@ -134,7 +134,7 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ![]KeyEve
|
||||||
state = .escape_sequence_start;
|
state = .escape_sequence_start;
|
||||||
i += 1;
|
i += 1;
|
||||||
},
|
},
|
||||||
'a'...'z', ';', '0'...'9' => {
|
'a'...'z', '\\', '[', ']', '/', '`', '-', '=', ';', '0'...'9' => {
|
||||||
try result.append(.{ .key = str[i] });
|
try result.append(.{ .key = str[i] });
|
||||||
i += 1;
|
i += 1;
|
||||||
},
|
},
|
||||||
|
@ -608,6 +608,12 @@ const BindingSet = struct {
|
||||||
for (self.bindings.items) |binding| blk: {
|
for (self.bindings.items) |binding| blk: {
|
||||||
switch (binding.match(self.current_sequence.items)) {
|
switch (binding.match(self.current_sequence.items)) {
|
||||||
.matched => {
|
.matched => {
|
||||||
|
errdefer {
|
||||||
|
//clear current sequence if command execution fails
|
||||||
|
self.current_sequence.clearRetainingCapacity();
|
||||||
|
self.current_sequence_egc.clearRetainingCapacity();
|
||||||
|
}
|
||||||
|
|
||||||
if (!builtin.is_test) {
|
if (!builtin.is_test) {
|
||||||
self.logger.print("matched binding -> {s}", .{binding.command});
|
self.logger.print("matched binding -> {s}", .{binding.command});
|
||||||
if (!builtin.is_test) self.logger.print("execute '{s}'", .{binding.command});
|
if (!builtin.is_test) self.logger.print("execute '{s}'", .{binding.command});
|
||||||
|
|
|
@ -3,14 +3,26 @@
|
||||||
"normal": {
|
"normal": {
|
||||||
"on_match_failure": "ignore",
|
"on_match_failure": "ignore",
|
||||||
"bindings": [
|
"bindings": [
|
||||||
["j", "cursor_down"],
|
["j", "move_down"],
|
||||||
["k", "cursor_up"],
|
["k", "move_up"],
|
||||||
["h", "cursor_right_vim"],
|
["l", "move_right_vim"],
|
||||||
["l", "cursor_left_vim"],
|
["h", "move_left"],
|
||||||
["i", "change_mode", "insert"],
|
["<Space>", "move_right_vim"],
|
||||||
["o", "change_mode", "insert"],
|
|
||||||
["a", "change_mode", "insert"],
|
["i", "enter_mode", "insert"],
|
||||||
["v", "change_mode", "visual"],
|
["v", "enter_mode", "visual"],
|
||||||
|
|
||||||
|
["/", "find"],
|
||||||
|
["n", "goto_next_match"],
|
||||||
|
|
||||||
|
["0", "move_begin"],
|
||||||
|
["<S-4>", "move_end"],
|
||||||
|
|
||||||
|
[";", "open_command_palette"],
|
||||||
|
["<S-;>", "open_command_palette"],
|
||||||
|
|
||||||
|
["p", "paste"],
|
||||||
|
|
||||||
["gg", "goto_page_begin"],
|
["gg", "goto_page_begin"],
|
||||||
["<S-g>", "goto_page_end"],
|
["<S-g>", "goto_page_end"],
|
||||||
["<C-u>", "cursor_half_page_up"],
|
["<C-u>", "cursor_half_page_up"],
|
||||||
|
@ -20,8 +32,8 @@
|
||||||
"insert": {
|
"insert": {
|
||||||
"on_match_failure": "insert",
|
"on_match_failure": "insert",
|
||||||
"bindings": [
|
"bindings": [
|
||||||
["jk", "change_mode", "normal"],
|
["jk", "enter_mode", "normal"],
|
||||||
["<Esc>", "change_mode", "normal"]
|
["<Esc>", "enter_mode", "normal"]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue