feat: separate binding key seqences with space instead of '>'

This commit is contained in:
CJ van den Berg 2025-01-07 16:13:02 +01:00
parent b73975328b
commit 9ace78e3a9
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
4 changed files with 220 additions and 219 deletions

View file

@ -25,12 +25,12 @@
["ctrl+d", "delete_forward"], ["ctrl+d", "delete_forward"],
["alt+d", ["select_word_right"], ["cut"]], ["alt+d", ["select_word_right"], ["cut"]],
["ctrl+y", "system_paste"], ["ctrl+y", "system_paste"],
["ctrl+x>ctrl+f", "open_file"], ["ctrl+x ctrl+f", "open_file"],
["ctrl+x>k", "close_file"], ["ctrl+x k", "close_file"],
["ctrl+x>ctrl+c", "quit"], ["ctrl+x ctrl+c", "quit"],
["ctrl+x>ctrl+s", "save_file"], ["ctrl+x ctrl+s", "save_file"],
["ctrl+x>ctrl+c", "quit"], ["ctrl+x ctrl+c", "quit"],
["ctrl+x>b", "open_recent"], ["ctrl+x b", "open_recent"],
["alt+x", "open_command_palette"], ["alt+x", "open_command_palette"],
["ctrl+space", "enter_mode", "select"] ["ctrl+space", "enter_mode", "select"]
] ]
@ -72,10 +72,10 @@
"home": { "home": {
"on_match_failure": "ignore", "on_match_failure": "ignore",
"press": [ "press": [
["ctrl+h>ctrl+a", "open_help"], ["ctrl+h ctrl+a", "open_help"],
["ctrl+x>ctrl+f", "open_recent"], ["ctrl+x ctrl+f", "open_recent"],
["alt+x", "open_command_palette"], ["alt+x", "open_command_palette"],
["ctrl+x>ctrl+c", "quit"] ["ctrl+x ctrl+c", "quit"]
] ]
} }
} }

View file

@ -19,12 +19,12 @@
["ctrl+c", "copy"], ["ctrl+c", "copy"],
["ctrl+v", "system_paste"], ["ctrl+v", "system_paste"],
["ctrl+u", "pop_cursor"], ["ctrl+u", "pop_cursor"],
["ctrl+k>m", "change_file_type"], ["ctrl+k m", "change_file_type"],
["ctrl+k>ctrl+u", "delete_to_begin"], ["ctrl+k ctrl+u", "delete_to_begin"],
["ctrl+k>ctrl+k", "delete_to_end"], ["ctrl+k ctrl+k", "delete_to_end"],
["ctrl+k>ctrl+d", "move_cursor_next_match"], ["ctrl+k ctrl+d", "move_cursor_next_match"],
["ctrl+k>ctrl+t", "change_theme"], ["ctrl+k ctrl+t", "change_theme"],
["ctrl+k>ctrl+i", "hover"], ["ctrl+k ctrl+i", "hover"],
["ctrl+f", "find"], ["ctrl+f", "find"],
["ctrl+g", "goto"], ["ctrl+g", "goto"],
["ctrl+d", "add_cursor_next_match"], ["ctrl+d", "add_cursor_next_match"],
@ -194,7 +194,7 @@
["t", "change_theme"], ["t", "change_theme"],
["q", "quit"], ["q", "quit"],
["ctrl+\\", "add_split"], ["ctrl+\\", "add_split"],
["ctrl+f>ctrl+f>ctrl+f>ctrl+f>ctrl+f", "home_sheeran"], ["ctrl+f ctrl+f ctrl+f ctrl+f ctrl+f", "home_sheeran"],
["ctrl+j", "toggle_panel"], ["ctrl+j", "toggle_panel"],
["ctrl+q", "quit"], ["ctrl+q", "quit"],
["ctrl+w", "quit"], ["ctrl+w", "quit"],
@ -202,7 +202,7 @@
["ctrl+e", "open_recent"], ["ctrl+e", "open_recent"],
["ctrl+r", "open_recent_project"], ["ctrl+r", "open_recent_project"],
["ctrl+p", "open_command_palette"], ["ctrl+p", "open_command_palette"],
["ctrl+k>ctrl+t", "change_theme"], ["ctrl+k ctrl+t", "change_theme"],
["ctrl+shift+p", "open_command_palette"], ["ctrl+shift+p", "open_command_palette"],
["ctrl+shift+q", "quit_without_saving"], ["ctrl+shift+q", "quit_without_saving"],
["ctrl+shift+r", "restart"], ["ctrl+shift+r", "restart"],

View file

@ -119,27 +119,27 @@
["v", "enter_mode", "select"], ["v", "enter_mode", "select"],
["g>g", "move_buffer_begin"], ["g g", "move_buffer_begin"],
["g>e", "move_buffer_end"], ["g e", "move_buffer_end"],
["g>f", "goto_file"], ["g f", "goto_file"],
["g>h", "move_begin"], ["g h", "move_begin"],
["g>l", "move_end"], ["g l", "move_end"],
["g>s", "smart_move_begin"], ["g s", "smart_move_begin"],
["g>d", "goto_definition"], ["g d", "goto_definition"],
["g>y", "goto_type_definition"], ["g y", "goto_type_definition"],
["g>r", "goto_reference"], ["g r", "goto_reference"],
["g>i", "goto_implementation"], ["g i", "goto_implementation"],
["g>t", "goto_window_top"], ["g t", "goto_window_top"],
["g>c", "goto_window_center"], ["g c", "goto_window_center"],
["g>b", "goto_window_bottom"], ["g b", "goto_window_bottom"],
["g>a", "goto_last_accessed_file"], ["g a", "goto_last_accessed_file"],
["g>m", "goto_last_modified_file"], ["g m", "goto_last_modified_file"],
["g>n", "goto_next_buffer"], ["g n", "goto_next_buffer"],
["g>p", "goto_previous_buffer"], ["g p", "goto_previous_buffer"],
["g>k", "goto_previous_buffer"], ["g k", "goto_previous_buffer"],
["g>.", "goto_last_modification"], ["g .", "goto_last_modification"],
["g>w", "goto_word"], ["g w", "goto_word"],
["g>shift+d", "goto_declaration"], ["g shift+d", "goto_declaration"],
["i", "enter_mode", "insert"], ["i", "enter_mode", "insert"],
["a", ["move_right"], ["enter_mode", "insert"]], ["a", ["move_right"], ["enter_mode", "insert"]],
@ -152,38 +152,38 @@
[";", "collapse_selections"], [";", "collapse_selections"],
["x", "extend_line_below"], ["x", "extend_line_below"],
["m>m", "match_brackets"], ["m m", "match_brackets"],
["m>s", "surround_add"], ["m s", "surround_add"],
["m>r", "surround_replace"], ["m r", "surround_replace"],
["m>d", "surround_delete"], ["m d", "surround_delete"],
["m>a", "select_textobject_around"], ["m a", "select_textobject_around"],
["m>i", "select_textobject_inner"], ["m i", "select_textobject_inner"],
["[>shift+d", "goto_first_diag"], ["[ shift+d", "goto_first_diag"],
["[>shift+g", "goto_first_change"], ["[ shift+g", "goto_first_change"],
["[>shift+t", "goto_prev_test"], ["[ shift+t", "goto_prev_test"],
["[>d", "goto_prev_diagnostic"], ["[ d", "goto_prev_diagnostic"],
["[>g", "goto_prev_change"], ["[ g", "goto_prev_change"],
["[>f", "goto_prev_function"], ["[ f", "goto_prev_function"],
["[>t", "goto_prev_class"], ["[ t", "goto_prev_class"],
["[>a", "goto_prev_parameter"], ["[ a", "goto_prev_parameter"],
["[>c", "goto_prev_comment"], ["[ c", "goto_prev_comment"],
["[>e", "goto_prev_entry"], ["[ e", "goto_prev_entry"],
["[>p", "goto_prev_paragraph"], ["[ p", "goto_prev_paragraph"],
["[>space", "add_newline_above"], ["[ space", "add_newline_above"],
["]>shift+d", "goto_last_diag"], ["] shift+d", "goto_last_diag"],
["]>shift+g", "goto_last_change"], ["] shift+g", "goto_last_change"],
["]>shift+t", "goto_next_test"], ["] shift+t", "goto_next_test"],
["]>d", "goto_next_diagnostic"], ["] d", "goto_next_diagnostic"],
["]>g", "goto_next_change"], ["] g", "goto_next_change"],
["]>f", "goto_next_function"], ["] f", "goto_next_function"],
["]>t", "goto_next_class"], ["] t", "goto_next_class"],
["]>a", "goto_next_parameter"], ["] a", "goto_next_parameter"],
["]>c", "goto_next_comment"], ["] c", "goto_next_comment"],
["]>e", "goto_next_entry"], ["] e", "goto_next_entry"],
["]>p", "goto_next_paragraph"], ["] p", "goto_next_paragraph"],
["]>space", "add_newline_below"], ["] space", "add_newline_below"],
["/", "find"], ["/", "find"],
["n", "goto_next_match"], ["n", "goto_next_match"],
@ -203,26 +203,26 @@
["page_up", "move_scroll_page_up"], ["page_up", "move_scroll_page_up"],
["page_down", "move_scroll_page_down"], ["page_down", "move_scroll_page_down"],
["space>shift+f", "file_picker_in_current_directory"], ["space shift+f", "file_picker_in_current_directory"],
["space>shift+s", "workspace_symbol_picker"], ["space shift+s", "workspace_symbol_picker"],
["space>shift+d", "workspace_diagnostics_picker"], ["space shift+d", "workspace_diagnostics_picker"],
["space>shift+p", "system_paste"], ["space shift+p", "system_paste"],
["space>shift+r", "replace_selections_with_clipboard"], ["space shift+r", "replace_selections_with_clipboard"],
["space>shift+/", "open_command_palette"], ["space shift+/", "open_command_palette"],
["space>f", "file_picker"], ["space f", "file_picker"],
["space>b", "buffer_picker"], ["space b", "buffer_picker"],
["space>j", "jumplist_picker"], ["space j", "jumplist_picker"],
["space>s", "symbol_picker"], ["space s", "symbol_picker"],
["space>d", "diagnostics_picker"], ["space d", "diagnostics_picker"],
["space>a", "code_action"], ["space a", "code_action"],
["space>'", "last_picker"], ["space '", "last_picker"],
["space>y", "copy"], ["space y", "copy"],
["space>p", "system_paste_after"], ["space p", "system_paste_after"],
["space>/", "find_in_file"], ["space /", "find_in_file"],
["space>k", "hover"], ["space k", "hover"],
["space>r", "rename_symbol"], ["space r", "rename_symbol"],
["space>h", "select_references_to_symbol_under_cursor"], ["space h", "select_references_to_symbol_under_cursor"],
["space>c", "toggle_comment"], ["space c", "toggle_comment"],
["1", "add_count", 1], ["1", "add_count", 1],
["2", "add_count", 2], ["2", "add_count", 2],
@ -390,27 +390,27 @@
["shift+v", "enter_mode", "normal"], ["shift+v", "enter_mode", "normal"],
["g>g", "move_buffer_begin"], ["g g", "move_buffer_begin"],
["g>e", "move_buffer_end"], ["g e", "move_buffer_end"],
["g>f", "goto_file"], ["g f", "goto_file"],
["g>h", "move_begin"], ["g h", "move_begin"],
["g>l", "move_end"], ["g l", "move_end"],
["g>s", "smart_move_begin"], ["g s", "smart_move_begin"],
["g>d", "goto_definition"], ["g d", "goto_definition"],
["g>y", "goto_type_definition"], ["g y", "goto_type_definition"],
["g>r", "goto_reference"], ["g r", "goto_reference"],
["g>i", "goto_implementation"], ["g i", "goto_implementation"],
["g>t", "goto_window_top"], ["g t", "goto_window_top"],
["g>c", "goto_window_center"], ["g c", "goto_window_center"],
["g>b", "goto_window_bottom"], ["g b", "goto_window_bottom"],
["g>a", "goto_last_accessed_file"], ["g a", "goto_last_accessed_file"],
["g>m", "goto_last_modified_file"], ["g m", "goto_last_modified_file"],
["g>n", "goto_next_buffer"], ["g n", "goto_next_buffer"],
["g>p", "goto_previous_buffer"], ["g p", "goto_previous_buffer"],
["g>k", "goto_previous_buffer"], ["g k", "goto_previous_buffer"],
["g>.", "goto_last_modification"], ["g .", "goto_last_modification"],
["g>w", "goto_word"], ["g w", "goto_word"],
["g>shift+d", "goto_declaration"], ["g shift+d", "goto_declaration"],
["i", "enter_mode", "insert"], ["i", "enter_mode", "insert"],
["a", ["move_right"], ["enter_mode", "insert"]], ["a", ["move_right"], ["enter_mode", "insert"]],
@ -424,39 +424,39 @@
["x", "extend_line_below"], ["x", "extend_line_below"],
["m>m", "match_brackets"], ["m m", "match_brackets"],
["m>s", "surround_add"], ["m s", "surround_add"],
["m>r", "surround_replace"], ["m r", "surround_replace"],
["m>d", "surround_delete"], ["m d", "surround_delete"],
["m>a", "select_textobject_around"], ["m a", "select_textobject_around"],
["m>i", "select_textobject_inner"], ["m i", "select_textobject_inner"],
["[>shift+d", "goto_first_diag"], ["[ shift+d", "goto_first_diag"],
["[>shift+g", "goto_first_change"], ["[ shift+g", "goto_first_change"],
["[>shift+t", "goto_prev_test"], ["[ shift+t", "goto_prev_test"],
["[>d", "goto_prev_diagnostic"], ["[ d", "goto_prev_diagnostic"],
["[>g", "goto_prev_change"], ["[ g", "goto_prev_change"],
["[>f", "goto_prev_function"], ["[ f", "goto_prev_function"],
["[>t", "goto_prev_class"], ["[ t", "goto_prev_class"],
["[>a", "goto_prev_parameter"], ["[ a", "goto_prev_parameter"],
["[>c", "goto_prev_comment"], ["[ c", "goto_prev_comment"],
["[>e", "goto_prev_entry"], ["[ e", "goto_prev_entry"],
["[>p", "goto_prev_paragraph"], ["[ p", "goto_prev_paragraph"],
["[>space", "add_newline_above"], ["[ space", "add_newline_above"],
["]>d", "goto_last_diag"], ["] d", "goto_last_diag"],
["]>g", "goto_last_change"], ["] g", "goto_last_change"],
["]>t", "goto_next_test"], ["] t", "goto_next_test"],
["]>d", "goto_next_diagnostic"], ["] d", "goto_next_diagnostic"],
["]>g", "goto_next_change"], ["] g", "goto_next_change"],
["]>f", "goto_next_function"], ["] f", "goto_next_function"],
["]>t", "goto_next_class"], ["] t", "goto_next_class"],
["]>a", "goto_next_parameter"], ["] a", "goto_next_parameter"],
["]>c", "goto_next_comment"], ["] c", "goto_next_comment"],
["]>e", "goto_next_entry"], ["] e", "goto_next_entry"],
["]>p", "goto_next_paragraph"], ["] p", "goto_next_paragraph"],
["]>space", "add_newline_below"], ["] space", "add_newline_below"],
["/", "find"], ["/", "find"],
["n", "goto_next_match"], ["n", "goto_next_match"],
@ -473,27 +473,27 @@
["escape", "enter_mode", "normal"], ["escape", "enter_mode", "normal"],
["space>shift+f", "file_picker_in_current_directory"], ["space shift+f", "file_picker_in_current_directory"],
["space>shift+s", "workspace_symbol_picker"], ["space shift+s", "workspace_symbol_picker"],
["space>shift+d", "workspace_diagnostics_picker"], ["space shift+d", "workspace_diagnostics_picker"],
["space>shift+p", "system_paste"], ["space shift+p", "system_paste"],
["space>shift+r", "replace_selections_with_clipboard"], ["space shift+r", "replace_selections_with_clipboard"],
["space>shift+/", "open_command_palette"], ["space shift+/", "open_command_palette"],
["space>f", "file_picker"], ["space f", "file_picker"],
["space>b", "buffer_picker"], ["space b", "buffer_picker"],
["space>j", "jumplist_picker"], ["space j", "jumplist_picker"],
["space>s", "symbol_picker"], ["space s", "symbol_picker"],
["space>d", "diagnostics_picker"], ["space d", "diagnostics_picker"],
["space>a", "code_action"], ["space a", "code_action"],
["space>'", "last_picker"], ["space '", "last_picker"],
["space>y", "copy"], ["space y", "copy"],
["space>p", "system_paste_after"], ["space p", "system_paste_after"],
["space>/", "find_in_file"], ["space /", "find_in_file"],
["space>k", "hover"], ["space k", "hover"],
["space>r", "rename_symbol"], ["space r", "rename_symbol"],
["space>h", "select_references_to_symbol_under_cursor"], ["space h", "select_references_to_symbol_under_cursor"],
["space>c", "toggle_comment"], ["space c", "toggle_comment"],
["1", "add_count", 1], ["1", "add_count", 1],
["2", "add_count", 2], ["2", "add_count", 2],

View file

@ -22,7 +22,7 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ParseErro
parse_error_reset(); parse_error_reset();
if (str.len == 0) return parse_error("empty", .{}); if (str.len == 0) return parse_error("empty", .{});
var result_events = std.ArrayList(input.KeyEvent).init(allocator); var result_events = std.ArrayList(input.KeyEvent).init(allocator);
var iter_sequence = std.mem.tokenizeScalar(u8, str, '>'); var iter_sequence = std.mem.tokenizeScalar(u8, str, ' ');
while (iter_sequence.next()) |item| { while (iter_sequence.next()) |item| {
var key: ?input.Key = null; var key: ?input.Key = null;
var mods = input.ModSet{}; var mods = input.ModSet{};
@ -80,6 +80,7 @@ pub const name_map = blk: {
.{ "escape", input.key.escape }, .{ "escape", input.key.escape },
.{ "space", input.key.space }, .{ "space", input.key.space },
.{ "backspace", input.key.backspace }, .{ "backspace", input.key.backspace },
.{ "lt", '<' },
.{ "gt", '>' }, .{ "gt", '>' },
}); });
}; };