diff --git a/src/keybind/builtin/vim.json b/src/keybind/builtin/vim.json index 3b00be5..81ddd04 100644 --- a/src/keybind/builtin/vim.json +++ b/src/keybind/builtin/vim.json @@ -35,8 +35,8 @@ ["o", ["enter_mode", "insert"], ["smart_insert_line_after"]], ["O", ["enter_mode", "insert"], ["smart_insert_line_before"]], - ["", "indent"], - ["", "unindent"], + ["", "indent"], + ["", "unindent"], ["v", "enter_mode", "visual"], ["V", ["enter_mode", "visual line"], ["select_line_vim"]], diff --git a/src/keybind/parse_vim.zig b/src/keybind/parse_vim.zig index 455cb4a..e05b585 100644 --- a/src/keybind/parse_vim.zig +++ b/src/keybind/parse_vim.zig @@ -15,6 +15,7 @@ pub const ParseError = error{ InvalidStartOfControlBinding, InvalidStartOfShiftBinding, InvalidStartOfDelBinding, + InvalidStartOfLeftBinding, InvalidStartOfEscBinding, InvalidStartOfHomeBinding, InvalidCRBinding, @@ -74,6 +75,8 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ParseErro end, insert, bs, + less_than, + greater_than, }; var state: State = .base; var function_key_number: u8 = 0; @@ -150,11 +153,22 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ParseErro state = .up; }, 'L' => { - state = .left; + state = switch (try peek(str, i)) { + 'e' => .left, + 'T' => .less_than, + else => return parse_error( + error.InvalidStartOfLeftBinding, + "str: {s}, i: {} c: {c}", + .{ str, i, str[i] }, + ), + }; }, 'R' => { state = .right; }, + 'G' => { + state = .greater_than; + }, 'I' => { state = .insert; }, @@ -304,6 +318,22 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ParseErro i += 5; } else return parse_error(error.InvalidRightBinding, "str: {s}, i: {} c: {c}", .{ str, i, str[i] }); }, + .less_than => { + if (std.mem.indexOf(u8, str[i..], "LT") == 0) { + try result.append(from_key_mods('<', modifiers)); + modifiers = 0; + state = .escape_sequence_end; + i += 2; + } else return parse_error(error.InvalidLeftBinding, "str: {s}, i: {} c: {c}", .{ str, i, str[i] }); + }, + .greater_than => { + if (std.mem.indexOf(u8, str[i..], "GT") == 0) { + try result.append(from_key_mods('>', modifiers)); + modifiers = 0; + state = .escape_sequence_end; + i += 2; + } else return parse_error(error.InvalidLeftBinding, "str: {s}, i: {} c: {c}", .{ str, i, str[i] }); + }, .function_key => { switch (str[i]) { '0'...'9' => {