From cd1f6e82396c3999813e2bfac98b5e15c43516d2 Mon Sep 17 00:00:00 2001 From: David Crespo Date: Thu, 5 Dec 2024 11:13:00 -0600 Subject: [PATCH] Add static commands to documentation (#11950) Co-authored-by: Adam Perkowski --- book/src/commands.md | 13 +- book/src/generated/static-cmd.md | 294 +++++++++++++++++++++++++++++++ xtask/src/docgen.rs | 68 +++++++ xtask/src/main.rs | 7 +- 4 files changed, 379 insertions(+), 3 deletions(-) create mode 100644 book/src/generated/static-cmd.md diff --git a/book/src/commands.md b/book/src/commands.md index 047a30a91c83..ee507276b51f 100644 --- a/book/src/commands.md +++ b/book/src/commands.md @@ -1,5 +1,16 @@ # Commands -Command mode can be activated by pressing `:`. The built-in commands are: +- [Typable commands](#typable-commands) +- [Static commands](#static-commands) + +## Typable commands + +Typable commands are used from command mode and may take arguments. Command mode can be activated by pressing `:`. The built-in typable commands are: {{#include ./generated/typable-cmd.md}} + +## Static Commands + +Static commands take no arguments and can be bound to keys. Static commands can also be executed from the command picker (`?`). The built-in static commands are: + +{{#include ./generated/static-cmd.md}} diff --git a/book/src/generated/static-cmd.md b/book/src/generated/static-cmd.md new file mode 100644 index 000000000000..4d838a10999d --- /dev/null +++ b/book/src/generated/static-cmd.md @@ -0,0 +1,294 @@ +| Name | Description | Default keybinds | +| --- | --- | --- | +| `no_op` | Do nothing | | +| `move_char_left` | Move left | normal: `` h ``, `` ``, insert: `` `` | +| `move_char_right` | Move right | normal: `` l ``, `` ``, insert: `` `` | +| `move_line_up` | Move up | normal: `` gk `` | +| `move_line_down` | Move down | normal: `` gj `` | +| `move_visual_line_up` | Move up | normal: `` k ``, `` ``, insert: `` `` | +| `move_visual_line_down` | Move down | normal: `` j ``, `` ``, insert: `` `` | +| `extend_char_left` | Extend left | select: `` h ``, `` `` | +| `extend_char_right` | Extend right | select: `` l ``, `` `` | +| `extend_line_up` | Extend up | select: `` gk `` | +| `extend_line_down` | Extend down | select: `` gj `` | +| `extend_visual_line_up` | Extend up | select: `` k ``, `` `` | +| `extend_visual_line_down` | Extend down | select: `` j ``, `` `` | +| `copy_selection_on_next_line` | Copy selection on next line | normal: `` C ``, select: `` C `` | +| `copy_selection_on_prev_line` | Copy selection on previous line | normal: `` ``, select: `` `` | +| `move_next_word_start` | Move to start of next word | normal: `` w `` | +| `move_prev_word_start` | Move to start of previous word | normal: `` b `` | +| `move_next_word_end` | Move to end of next word | normal: `` e `` | +| `move_prev_word_end` | Move to end of previous word | | +| `move_next_long_word_start` | Move to start of next long word | normal: `` W `` | +| `move_prev_long_word_start` | Move to start of previous long word | normal: `` B `` | +| `move_next_long_word_end` | Move to end of next long word | normal: `` E `` | +| `move_prev_long_word_end` | Move to end of previous long word | | +| `move_next_sub_word_start` | Move to start of next sub word | | +| `move_prev_sub_word_start` | Move to start of previous sub word | | +| `move_next_sub_word_end` | Move to end of next sub word | | +| `move_prev_sub_word_end` | Move to end of previous sub word | | +| `move_parent_node_end` | Move to end of the parent node | normal: `` `` | +| `move_parent_node_start` | Move to beginning of the parent node | normal: `` `` | +| `extend_next_word_start` | Extend to start of next word | select: `` w `` | +| `extend_prev_word_start` | Extend to start of previous word | select: `` b `` | +| `extend_next_word_end` | Extend to end of next word | select: `` e `` | +| `extend_prev_word_end` | Extend to end of previous word | | +| `extend_next_long_word_start` | Extend to start of next long word | select: `` W `` | +| `extend_prev_long_word_start` | Extend to start of previous long word | select: `` B `` | +| `extend_next_long_word_end` | Extend to end of next long word | select: `` E `` | +| `extend_prev_long_word_end` | Extend to end of prev long word | | +| `extend_next_sub_word_start` | Extend to start of next sub word | | +| `extend_prev_sub_word_start` | Extend to start of previous sub word | | +| `extend_next_sub_word_end` | Extend to end of next sub word | | +| `extend_prev_sub_word_end` | Extend to end of prev sub word | | +| `extend_parent_node_end` | Extend to end of the parent node | select: `` `` | +| `extend_parent_node_start` | Extend to beginning of the parent node | select: `` `` | +| `find_till_char` | Move till next occurrence of char | normal: `` t `` | +| `find_next_char` | Move to next occurrence of char | normal: `` f `` | +| `extend_till_char` | Extend till next occurrence of char | select: `` t `` | +| `extend_next_char` | Extend to next occurrence of char | select: `` f `` | +| `till_prev_char` | Move till previous occurrence of char | normal: `` T `` | +| `find_prev_char` | Move to previous occurrence of char | normal: `` F `` | +| `extend_till_prev_char` | Extend till previous occurrence of char | select: `` T `` | +| `extend_prev_char` | Extend to previous occurrence of char | select: `` F `` | +| `repeat_last_motion` | Repeat last motion | normal: `` ``, select: `` `` | +| `replace` | Replace with new char | normal: `` r ``, select: `` r `` | +| `switch_case` | Switch (toggle) case | normal: `` ~ ``, select: `` ~ `` | +| `switch_to_uppercase` | Switch to uppercase | normal: `` ``, select: `` `` | +| `switch_to_lowercase` | Switch to lowercase | normal: `` ` ``, select: `` ` `` | +| `page_up` | Move page up | normal: `` ``, `` Z ``, `` z ``, `` ``, `` Z ``, `` z ``, select: `` ``, `` Z ``, `` z ``, `` ``, `` Z ``, `` z ``, insert: `` `` | +| `page_down` | Move page down | normal: `` ``, `` Z ``, `` z ``, `` ``, `` Z ``, `` z ``, select: `` ``, `` Z ``, `` z ``, `` ``, `` Z ``, `` z ``, insert: `` `` | +| `half_page_up` | Move half page up | | +| `half_page_down` | Move half page down | | +| `page_cursor_up` | Move page and cursor up | | +| `page_cursor_down` | Move page and cursor down | | +| `page_cursor_half_up` | Move page and cursor half up | normal: `` ``, `` Z ``, `` z ``, `` Z ``, `` z ``, select: `` ``, `` Z ``, `` z ``, `` Z ``, `` z `` | +| `page_cursor_half_down` | Move page and cursor half down | normal: `` ``, `` Z ``, `` z ``, `` Z ``, `` z ``, select: `` ``, `` Z ``, `` z ``, `` Z ``, `` z `` | +| `select_all` | Select whole document | normal: `` % ``, select: `` % `` | +| `select_regex` | Select all regex matches inside selections | normal: `` s ``, select: `` s `` | +| `split_selection` | Split selections on regex matches | normal: `` S ``, select: `` S `` | +| `split_selection_on_newline` | Split selection on newlines | normal: `` ``, select: `` `` | +| `merge_selections` | Merge selections | normal: `` ``, select: `` `` | +| `merge_consecutive_selections` | Merge consecutive selections | normal: `` ``, select: `` `` | +| `search` | Search for regex pattern | normal: `` / ``, `` Z/ ``, `` z/ ``, select: `` / ``, `` Z/ ``, `` z/ `` | +| `rsearch` | Reverse search for regex pattern | normal: `` ? ``, `` Z? ``, `` z? ``, select: `` ? ``, `` Z? ``, `` z? `` | +| `search_next` | Select next search match | normal: `` n ``, `` Zn ``, `` zn ``, select: `` Zn ``, `` zn `` | +| `search_prev` | Select previous search match | normal: `` N ``, `` ZN ``, `` zN ``, select: `` ZN ``, `` zN `` | +| `extend_search_next` | Add next search match to selection | select: `` n `` | +| `extend_search_prev` | Add previous search match to selection | select: `` N `` | +| `search_selection` | Use current selection as search pattern | normal: `` ``, select: `` `` | +| `search_selection_detect_word_boundaries` | Use current selection as the search pattern, automatically wrapping with `\b` on word boundaries | normal: `` * ``, select: `` * `` | +| `make_search_word_bounded` | Modify current search to make it word bounded | | +| `global_search` | Global search in workspace folder | normal: `` / ``, select: `` / `` | +| `extend_line` | Select current line, if already selected, extend to another line based on the anchor | | +| `extend_line_below` | Select current line, if already selected, extend to next line | normal: `` x ``, select: `` x `` | +| `extend_line_above` | Select current line, if already selected, extend to previous line | | +| `select_line_above` | Select current line, if already selected, extend or shrink line above based on the anchor | | +| `select_line_below` | Select current line, if already selected, extend or shrink line below based on the anchor | | +| `extend_to_line_bounds` | Extend selection to line bounds | normal: `` X ``, select: `` X `` | +| `shrink_to_line_bounds` | Shrink selection to line bounds | normal: `` ``, select: `` `` | +| `delete_selection` | Delete selection | normal: `` d ``, select: `` d `` | +| `delete_selection_noyank` | Delete selection without yanking | normal: `` ``, select: `` `` | +| `change_selection` | Change selection | normal: `` c ``, select: `` c `` | +| `change_selection_noyank` | Change selection without yanking | normal: `` ``, select: `` `` | +| `collapse_selection` | Collapse selection into single cursor | normal: `` ; ``, select: `` ; `` | +| `flip_selections` | Flip selection cursor and anchor | normal: `` ``, select: `` `` | +| `ensure_selections_forward` | Ensure all selections face forward | normal: `` ``, select: `` `` | +| `insert_mode` | Insert before selection | normal: `` i ``, select: `` i `` | +| `append_mode` | Append after selection | normal: `` a ``, select: `` a `` | +| `command_mode` | Enter command mode | normal: `` : ``, select: `` : `` | +| `file_picker` | Open file picker | normal: `` f ``, select: `` f `` | +| `file_picker_in_current_buffer_directory` | Open file picker at current buffer's directory | | +| `file_picker_in_current_directory` | Open file picker at current working directory | normal: `` F ``, select: `` F `` | +| `code_action` | Perform code action | normal: `` a ``, select: `` a `` | +| `buffer_picker` | Open buffer picker | normal: `` b ``, select: `` b `` | +| `jumplist_picker` | Open jumplist picker | normal: `` j ``, select: `` j `` | +| `symbol_picker` | Open symbol picker | normal: `` s ``, select: `` s `` | +| `changed_file_picker` | Open changed file picker | normal: `` g ``, select: `` g `` | +| `select_references_to_symbol_under_cursor` | Select symbol references | normal: `` h ``, select: `` h `` | +| `workspace_symbol_picker` | Open workspace symbol picker | normal: `` S ``, select: `` S `` | +| `diagnostics_picker` | Open diagnostic picker | normal: `` d ``, select: `` d `` | +| `workspace_diagnostics_picker` | Open workspace diagnostic picker | normal: `` D ``, select: `` D `` | +| `last_picker` | Open last picker | normal: `` ' ``, select: `` ' `` | +| `insert_at_line_start` | Insert at start of line | normal: `` I ``, select: `` I `` | +| `insert_at_line_end` | Insert at end of line | normal: `` A ``, select: `` A `` | +| `open_below` | Open new line below selection | normal: `` o ``, select: `` o `` | +| `open_above` | Open new line above selection | normal: `` O ``, select: `` O `` | +| `normal_mode` | Enter normal mode | normal: `` ``, select: `` v ``, insert: `` `` | +| `select_mode` | Enter selection extend mode | normal: `` v `` | +| `exit_select_mode` | Exit selection mode | select: `` `` | +| `goto_definition` | Goto definition | normal: `` gd ``, select: `` gd `` | +| `goto_declaration` | Goto declaration | normal: `` gD ``, select: `` gD `` | +| `add_newline_above` | Add newline above | normal: `` [ ``, select: `` [ `` | +| `add_newline_below` | Add newline below | normal: `` ] ``, select: `` ] `` | +| `goto_type_definition` | Goto type definition | normal: `` gy ``, select: `` gy `` | +| `goto_implementation` | Goto implementation | normal: `` gi ``, select: `` gi `` | +| `goto_file_start` | Goto line number else file start | normal: `` gg ``, select: `` gg `` | +| `goto_file_end` | Goto file end | | +| `goto_file` | Goto files/URLs in selections | normal: `` gf ``, select: `` gf `` | +| `goto_file_hsplit` | Goto files in selections (hsplit) | normal: `` f ``, `` wf ``, select: `` f ``, `` wf `` | +| `goto_file_vsplit` | Goto files in selections (vsplit) | normal: `` F ``, `` wF ``, select: `` F ``, `` wF `` | +| `goto_reference` | Goto references | normal: `` gr ``, select: `` gr `` | +| `goto_window_top` | Goto window top | normal: `` gt ``, select: `` gt `` | +| `goto_window_center` | Goto window center | normal: `` gc ``, select: `` gc `` | +| `goto_window_bottom` | Goto window bottom | normal: `` gb ``, select: `` gb `` | +| `goto_last_accessed_file` | Goto last accessed file | normal: `` ga ``, select: `` ga `` | +| `goto_last_modified_file` | Goto last modified file | normal: `` gm ``, select: `` gm `` | +| `goto_last_modification` | Goto last modification | normal: `` g. ``, select: `` g. `` | +| `goto_line` | Goto line | normal: `` G ``, select: `` G `` | +| `goto_last_line` | Goto last line | normal: `` ge ``, select: `` ge `` | +| `goto_first_diag` | Goto first diagnostic | normal: `` [D ``, select: `` [D `` | +| `goto_last_diag` | Goto last diagnostic | normal: `` ]D ``, select: `` ]D `` | +| `goto_next_diag` | Goto next diagnostic | normal: `` ]d ``, select: `` ]d `` | +| `goto_prev_diag` | Goto previous diagnostic | normal: `` [d ``, select: `` [d `` | +| `goto_next_change` | Goto next change | normal: `` ]g ``, select: `` ]g `` | +| `goto_prev_change` | Goto previous change | normal: `` [g ``, select: `` [g `` | +| `goto_first_change` | Goto first change | normal: `` [G ``, select: `` [G `` | +| `goto_last_change` | Goto last change | normal: `` ]G ``, select: `` ]G `` | +| `goto_line_start` | Goto line start | normal: `` gh ``, `` ``, select: `` gh ``, insert: `` `` | +| `goto_line_end` | Goto line end | normal: `` gl ``, `` ``, select: `` gl `` | +| `goto_next_buffer` | Goto next buffer | normal: `` gn ``, select: `` gn `` | +| `goto_previous_buffer` | Goto previous buffer | normal: `` gp ``, select: `` gp `` | +| `goto_line_end_newline` | Goto newline at line end | insert: `` `` | +| `goto_first_nonwhitespace` | Goto first non-blank in line | normal: `` gs ``, select: `` gs `` | +| `trim_selections` | Trim whitespace from selections | normal: `` _ ``, select: `` _ `` | +| `extend_to_line_start` | Extend to line start | select: `` `` | +| `extend_to_first_nonwhitespace` | Extend to first non-blank in line | | +| `extend_to_line_end` | Extend to line end | select: `` `` | +| `extend_to_line_end_newline` | Extend to line end | | +| `signature_help` | Show signature help | | +| `smart_tab` | Insert tab if all cursors have all whitespace to their left; otherwise, run a separate command. | insert: `` `` | +| `insert_tab` | Insert tab char | insert: `` `` | +| `insert_newline` | Insert newline char | insert: `` ``, `` `` | +| `delete_char_backward` | Delete previous char | insert: `` ``, `` ``, `` `` | +| `delete_char_forward` | Delete next char | insert: `` ``, `` `` | +| `delete_word_backward` | Delete previous word | insert: `` ``, `` `` | +| `delete_word_forward` | Delete next word | insert: `` ``, `` `` | +| `kill_to_line_start` | Delete till start of line | insert: `` `` | +| `kill_to_line_end` | Delete till end of line | insert: `` `` | +| `undo` | Undo change | normal: `` u ``, select: `` u `` | +| `redo` | Redo change | normal: `` U ``, select: `` U `` | +| `earlier` | Move backward in history | normal: `` ``, select: `` `` | +| `later` | Move forward in history | normal: `` ``, select: `` `` | +| `commit_undo_checkpoint` | Commit changes to new checkpoint | insert: `` `` | +| `yank` | Yank selection | normal: `` y ``, select: `` y `` | +| `yank_to_clipboard` | Yank selections to clipboard | normal: `` y ``, select: `` y `` | +| `yank_to_primary_clipboard` | Yank selections to primary clipboard | | +| `yank_joined` | Join and yank selections | | +| `yank_joined_to_clipboard` | Join and yank selections to clipboard | | +| `yank_main_selection_to_clipboard` | Yank main selection to clipboard | normal: `` Y ``, select: `` Y `` | +| `yank_joined_to_primary_clipboard` | Join and yank selections to primary clipboard | | +| `yank_main_selection_to_primary_clipboard` | Yank main selection to primary clipboard | | +| `replace_with_yanked` | Replace with yanked text | normal: `` R ``, select: `` R `` | +| `replace_selections_with_clipboard` | Replace selections by clipboard content | normal: `` R ``, select: `` R `` | +| `replace_selections_with_primary_clipboard` | Replace selections by primary clipboard | | +| `paste_after` | Paste after selection | normal: `` p ``, select: `` p `` | +| `paste_before` | Paste before selection | normal: `` P ``, select: `` P `` | +| `paste_clipboard_after` | Paste clipboard after selections | normal: `` p ``, select: `` p `` | +| `paste_clipboard_before` | Paste clipboard before selections | normal: `` P ``, select: `` P `` | +| `paste_primary_clipboard_after` | Paste primary clipboard after selections | | +| `paste_primary_clipboard_before` | Paste primary clipboard before selections | | +| `indent` | Indent selection | normal: `` ``, select: `` `` | +| `unindent` | Unindent selection | normal: `` ``, select: `` `` | +| `format_selections` | Format selection | normal: `` = ``, select: `` = `` | +| `join_selections` | Join lines inside selection | normal: `` J ``, select: `` J `` | +| `join_selections_space` | Join lines inside selection and select spaces | normal: `` ``, select: `` `` | +| `keep_selections` | Keep selections matching regex | normal: `` K ``, select: `` K `` | +| `remove_selections` | Remove selections matching regex | normal: `` ``, select: `` `` | +| `align_selections` | Align selections in column | normal: `` & ``, select: `` & `` | +| `keep_primary_selection` | Keep primary selection | normal: `` , ``, select: `` , `` | +| `remove_primary_selection` | Remove primary selection | normal: `` ``, select: `` `` | +| `completion` | Invoke completion popup | insert: `` `` | +| `hover` | Show docs for item under cursor | normal: `` k ``, select: `` k `` | +| `toggle_comments` | Comment/uncomment selections | normal: `` ``, `` c ``, select: `` ``, `` c `` | +| `toggle_line_comments` | Line comment/uncomment selections | normal: `` ``, select: `` `` | +| `toggle_block_comments` | Block comment/uncomment selections | normal: `` C ``, select: `` C `` | +| `rotate_selections_forward` | Rotate selections forward | normal: `` ) ``, select: `` ) `` | +| `rotate_selections_backward` | Rotate selections backward | normal: `` ( ``, select: `` ( `` | +| `rotate_selection_contents_forward` | Rotate selection contents forward | normal: `` ``, select: `` `` | +| `rotate_selection_contents_backward` | Rotate selections contents backward | normal: `` ``, select: `` `` | +| `reverse_selection_contents` | Reverse selections contents | | +| `expand_selection` | Expand selection to parent syntax node | normal: `` ``, `` ``, select: `` ``, `` `` | +| `shrink_selection` | Shrink selection to previously expanded syntax node | normal: `` ``, `` ``, select: `` ``, `` `` | +| `select_next_sibling` | Select next sibling in the syntax tree | normal: `` ``, `` ``, select: `` ``, `` `` | +| `select_prev_sibling` | Select previous sibling the in syntax tree | normal: `` ``, `` ``, select: `` ``, `` `` | +| `select_all_siblings` | Select all siblings of the current node | normal: `` ``, select: `` `` | +| `select_all_children` | Select all children of the current node | normal: `` ``, `` ``, select: `` ``, `` `` | +| `jump_forward` | Jump forward on jumplist | normal: `` ``, `` ``, select: `` ``, `` `` | +| `jump_backward` | Jump backward on jumplist | normal: `` ``, select: `` `` | +| `save_selection` | Save current selection to jumplist | normal: `` ``, select: `` `` | +| `jump_view_right` | Jump to right split | normal: `` l ``, `` wl ``, `` ``, `` ``, `` w ``, `` w ``, select: `` l ``, `` wl ``, `` ``, `` ``, `` w ``, `` w `` | +| `jump_view_left` | Jump to left split | normal: `` h ``, `` wh ``, `` ``, `` ``, `` w ``, `` w ``, select: `` h ``, `` wh ``, `` ``, `` ``, `` w ``, `` w `` | +| `jump_view_up` | Jump to split above | normal: `` k ``, `` ``, `` wk ``, `` ``, `` w ``, `` w ``, select: `` k ``, `` ``, `` wk ``, `` ``, `` w ``, `` w `` | +| `jump_view_down` | Jump to split below | normal: `` j ``, `` wj ``, `` ``, `` ``, `` w ``, `` w ``, select: `` j ``, `` wj ``, `` ``, `` ``, `` w ``, `` w `` | +| `swap_view_right` | Swap with right split | normal: `` L ``, `` wL ``, select: `` L ``, `` wL `` | +| `swap_view_left` | Swap with left split | normal: `` H ``, `` wH ``, select: `` H ``, `` wH `` | +| `swap_view_up` | Swap with split above | normal: `` K ``, `` wK ``, select: `` K ``, `` wK `` | +| `swap_view_down` | Swap with split below | normal: `` J ``, `` wJ ``, select: `` J ``, `` wJ `` | +| `transpose_view` | Transpose splits | normal: `` t ``, `` wt ``, `` ``, `` w ``, select: `` t ``, `` wt ``, `` ``, `` w `` | +| `rotate_view` | Goto next window | normal: `` w ``, `` ww ``, `` ``, `` w ``, select: `` w ``, `` ww ``, `` ``, `` w `` | +| `rotate_view_reverse` | Goto previous window | | +| `hsplit` | Horizontal bottom split | normal: `` s ``, `` ws ``, `` ``, `` w ``, select: `` s ``, `` ws ``, `` ``, `` w `` | +| `hsplit_new` | Horizontal bottom split scratch buffer | normal: `` ns ``, `` wns ``, `` n ``, `` wn ``, select: `` ns ``, `` wns ``, `` n ``, `` wn `` | +| `vsplit` | Vertical right split | normal: `` v ``, `` wv ``, `` ``, `` w ``, select: `` v ``, `` wv ``, `` ``, `` w `` | +| `vsplit_new` | Vertical right split scratch buffer | normal: `` nv ``, `` wnv ``, `` n ``, `` wn ``, select: `` nv ``, `` wnv ``, `` n ``, `` wn `` | +| `wclose` | Close window | normal: `` q ``, `` wq ``, `` ``, `` w ``, select: `` q ``, `` wq ``, `` ``, `` w `` | +| `wonly` | Close windows except current | normal: `` o ``, `` wo ``, `` ``, `` w ``, select: `` o ``, `` wo ``, `` ``, `` w `` | +| `select_register` | Select register | normal: `` " ``, select: `` " `` | +| `insert_register` | Insert register | insert: `` `` | +| `align_view_middle` | Align view middle | normal: `` Zm ``, `` zm ``, select: `` Zm ``, `` zm `` | +| `align_view_top` | Align view top | normal: `` Zt ``, `` zt ``, select: `` Zt ``, `` zt `` | +| `align_view_center` | Align view center | normal: `` Zc ``, `` Zz ``, `` zc ``, `` zz ``, select: `` Zc ``, `` Zz ``, `` zc ``, `` zz `` | +| `align_view_bottom` | Align view bottom | normal: `` Zb ``, `` zb ``, select: `` Zb ``, `` zb `` | +| `scroll_up` | Scroll view up | normal: `` Zk ``, `` zk ``, `` Z ``, `` z ``, select: `` Zk ``, `` zk ``, `` Z ``, `` z `` | +| `scroll_down` | Scroll view down | normal: `` Zj ``, `` zj ``, `` Z ``, `` z ``, select: `` Zj ``, `` zj ``, `` Z ``, `` z `` | +| `match_brackets` | Goto matching bracket | normal: `` mm ``, select: `` mm `` | +| `surround_add` | Surround add | normal: `` ms ``, select: `` ms `` | +| `surround_replace` | Surround replace | normal: `` mr ``, select: `` mr `` | +| `surround_delete` | Surround delete | normal: `` md ``, select: `` md `` | +| `select_textobject_around` | Select around object | normal: `` ma ``, select: `` ma `` | +| `select_textobject_inner` | Select inside object | normal: `` mi ``, select: `` mi `` | +| `goto_next_function` | Goto next function | normal: `` ]f ``, select: `` ]f `` | +| `goto_prev_function` | Goto previous function | normal: `` [f ``, select: `` [f `` | +| `goto_next_class` | Goto next type definition | normal: `` ]t ``, select: `` ]t `` | +| `goto_prev_class` | Goto previous type definition | normal: `` [t ``, select: `` [t `` | +| `goto_next_parameter` | Goto next parameter | normal: `` ]a ``, select: `` ]a `` | +| `goto_prev_parameter` | Goto previous parameter | normal: `` [a ``, select: `` [a `` | +| `goto_next_comment` | Goto next comment | normal: `` ]c ``, select: `` ]c `` | +| `goto_prev_comment` | Goto previous comment | normal: `` [c ``, select: `` [c `` | +| `goto_next_test` | Goto next test | normal: `` ]T ``, select: `` ]T `` | +| `goto_prev_test` | Goto previous test | normal: `` [T ``, select: `` [T `` | +| `goto_next_entry` | Goto next pairing | normal: `` ]e ``, select: `` ]e `` | +| `goto_prev_entry` | Goto previous pairing | normal: `` [e ``, select: `` [e `` | +| `goto_next_paragraph` | Goto next paragraph | normal: `` ]p ``, select: `` ]p `` | +| `goto_prev_paragraph` | Goto previous paragraph | normal: `` [p ``, select: `` [p `` | +| `dap_launch` | Launch debug target | normal: `` Gl ``, select: `` Gl `` | +| `dap_restart` | Restart debugging session | normal: `` Gr ``, select: `` Gr `` | +| `dap_toggle_breakpoint` | Toggle breakpoint | normal: `` Gb ``, select: `` Gb `` | +| `dap_continue` | Continue program execution | normal: `` Gc ``, select: `` Gc `` | +| `dap_pause` | Pause program execution | normal: `` Gh ``, select: `` Gh `` | +| `dap_step_in` | Step in | normal: `` Gi ``, select: `` Gi `` | +| `dap_step_out` | Step out | normal: `` Go ``, select: `` Go `` | +| `dap_next` | Step to next | normal: `` Gn ``, select: `` Gn `` | +| `dap_variables` | List variables | normal: `` Gv ``, select: `` Gv `` | +| `dap_terminate` | End debug session | normal: `` Gt ``, select: `` Gt `` | +| `dap_edit_condition` | Edit breakpoint condition on current line | normal: `` G ``, select: `` G `` | +| `dap_edit_log` | Edit breakpoint log message on current line | normal: `` G ``, select: `` G `` | +| `dap_switch_thread` | Switch current thread | normal: `` Gst ``, select: `` Gst `` | +| `dap_switch_stack_frame` | Switch stack frame | normal: `` Gsf ``, select: `` Gsf `` | +| `dap_enable_exceptions` | Enable exception breakpoints | normal: `` Ge ``, select: `` Ge `` | +| `dap_disable_exceptions` | Disable exception breakpoints | normal: `` GE ``, select: `` GE `` | +| `shell_pipe` | Pipe selections through shell command | normal: `` \| ``, select: `` \| `` | +| `shell_pipe_to` | Pipe selections into shell command ignoring output | normal: `` ``, select: `` `` | +| `shell_insert_output` | Insert shell command output before selections | normal: `` ! ``, select: `` ! `` | +| `shell_append_output` | Append shell command output after selections | normal: `` ``, select: `` `` | +| `shell_keep_pipe` | Filter selections with shell predicate | normal: `` $ ``, select: `` $ `` | +| `suspend` | Suspend and return to shell | normal: `` ``, select: `` `` | +| `rename_symbol` | Rename symbol | normal: `` r ``, select: `` r `` | +| `increment` | Increment item under cursor | normal: `` ``, select: `` `` | +| `decrement` | Decrement item under cursor | normal: `` ``, select: `` `` | +| `record_macro` | Record macro | normal: `` Q ``, select: `` Q `` | +| `replay_macro` | Replay macro | normal: `` q ``, select: `` q `` | +| `command_palette` | Open command palette | normal: `` ? ``, select: `` ? `` | +| `goto_word` | Jump to a two-character label | normal: `` gw `` | +| `extend_to_word` | Extend to a two-character label | select: `` gw `` | diff --git a/xtask/src/docgen.rs b/xtask/src/docgen.rs index 6658e876b127..6b9ebfa3d269 100644 --- a/xtask/src/docgen.rs +++ b/xtask/src/docgen.rs @@ -1,12 +1,18 @@ use crate::helpers; use crate::path; use crate::DynError; + +use helix_term::commands::MappableCommand; use helix_term::commands::TYPABLE_COMMAND_LIST; use helix_term::health::TsFeature; +use helix_term::ui::EditorView; +use helix_view::document::Mode; + use std::collections::HashSet; use std::fs; pub const TYPABLE_COMMANDS_MD_OUTPUT: &str = "typable-cmd.md"; +pub const STATIC_COMMANDS_MD_OUTPUT: &str = "static-cmd.md"; pub const LANG_SUPPORT_MD_OUTPUT: &str = "lang-support.md"; fn md_table_heading(cols: &[String]) -> String { @@ -48,6 +54,68 @@ pub fn typable_commands() -> Result { Ok(md) } +pub fn static_commands() -> Result { + let mut md = String::new(); + let keymap = EditorView::default().keymaps.map(); + let keymaps = [ + ("normal", keymap[&Mode::Normal].reverse_map()), + ("select", keymap[&Mode::Select].reverse_map()), + ("insert", keymap[&Mode::Insert].reverse_map()), + ]; + + md.push_str(&md_table_heading(&[ + "Name".to_owned(), + "Description".to_owned(), + "Default keybinds".to_owned(), + ])); + + for cmd in MappableCommand::STATIC_COMMAND_LIST { + let keymap_strings: Vec<_> = keymaps + .iter() + .map(|(mode, keymap)| { + let bindings = keymap + .get(cmd.name()) + .map(|bindings| { + let mut bind_strings: Vec<_> = bindings + .iter() + .map(|bind| { + let keys = &bind + .iter() + .map(|key| key.key_sequence_format()) + .collect::() + // escape | so it doesn't get rendered as a column separator + .replace('|', "\\|"); + format!("`` {} ``", keys) + }) + .collect(); + // sort for stable output. sorting by length puts simple + // keybindings first and groups similar keys together + bind_strings.sort_by_key(|s| (s.len(), s.to_owned())); + bind_strings.join(", ") + }) + .unwrap_or_default(); + + (mode, bindings) + }) + .collect(); + + let keymap_string = keymap_strings + .iter() + .filter(|(_, bindings)| !bindings.is_empty()) + .map(|(mode, bindings)| format!("{}: {}", mode, bindings)) + .collect::>() + .join(", "); + + md.push_str(&md_table_row(&[ + md_mono(cmd.name()), + cmd.doc().to_owned(), + keymap_string, + ])); + } + + Ok(md) +} + pub fn lang_features() -> Result { let mut md = String::new(); let ts_features = TsFeature::all(); diff --git a/xtask/src/main.rs b/xtask/src/main.rs index fcb462f252d5..39de89182077 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -9,14 +9,17 @@ use std::{env, error::Error}; type DynError = Box; pub mod tasks { - use crate::docgen::{lang_features, typable_commands, write}; - use crate::docgen::{LANG_SUPPORT_MD_OUTPUT, TYPABLE_COMMANDS_MD_OUTPUT}; + use crate::docgen::{lang_features, static_commands, typable_commands, write}; + use crate::docgen::{ + LANG_SUPPORT_MD_OUTPUT, STATIC_COMMANDS_MD_OUTPUT, TYPABLE_COMMANDS_MD_OUTPUT, + }; use crate::querycheck::query_check; use crate::theme_check::theme_check; use crate::DynError; pub fn docgen() -> Result<(), DynError> { write(TYPABLE_COMMANDS_MD_OUTPUT, &typable_commands()?); + write(STATIC_COMMANDS_MD_OUTPUT, &static_commands()?); write(LANG_SUPPORT_MD_OUTPUT, &lang_features()?); Ok(()) }