aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/keymap.rs
Commit message (Collapse)AuthorAge
* keymap: Test backslash escaping in commandsds-cbo2023-01-25
|
* refactor: don't deserialize &str from tomlPascal Kuthe2023-01-24
| | | | | | The new version of the `toml` crate is based on `toml_edit` and does not support zero copy deserialization anymore. So we need to deserialize `String` instead of `&str` in the keympa
* Fix nightly clippy lints (#4954)Tshepang Mbambo2022-12-01
|
* Improve keymap errors from command typos (#3931)Michael Davis2022-09-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Improve keymap errors from command typos Currently, opening helix with a config containing a bad command mapping fails with a cryptic error. For example, say we have a config (bad.toml) with a command name that doesn't exist: [keys.normal] b = "buffer_close" # should be ":buffer-close" When we `hx -c bad.toml`, we get... > Bad config: data did not match any variant of untagged enum KeyTrie for key `keys.normal` at line 1 column 1 > Press <ENTER> to continue with default config This is because of the way that Serde tries to deserialize untagged enums such as `helix_term::keymap::KeyTrie`. From the Serde docs[^1]: > Serde will try to match the data against each variant in order and the > first one that deserializes successfully is the one returned. `MappableCommand::deserialize` fails (returns an Err variant) when a command does not exist. Serde interprets this as the `KeyTrie::Leaf` variant failing to match and declares that the input data doesn't "match any variant of untagged enum KeyTrie." Luckily the variants of KeyTrie are orthogonal in structure: we can tell them apart by the type hints from a `serde::de::Visitor`. This change uses a custom Deserialize implementation along with a Visitor that discerns which variant of the KeyTrie applies. With this change, the above failure becomes: > Bad config: No command named 'buffer_close' for key `keys.normal.b` at line 2 column 5 > Press <ENTER> to continue with default config We also provide more explicit information about the expectations on the field. A config with an unexpected type produces a message with that information and the expectation: [keys.normal] b = 1 > Bad config: invalid type: integer `1`, expected a command, list of commands, or sub-keymap for key `keys.normal.b` at line 2 column 5 > Press <ENTER> to continue with default config [^1]: https://serde.rs/enum-representations.html#untagged * Update helix-term/src/keymap.rs Co-authored-by: Ivan Tham <pickfire@riseup.net> Co-authored-by: Ivan Tham <pickfire@riseup.net>
* Reuse menu::Item trait in picker (#2814)Gokul Soumya2022-07-02
| | | | | | | | | | | | | | | | | | | | | | | | | | * Refactor menu::Item to accomodate external state Will be useful for storing editor state when reused by pickers. * Add some type aliases for readability * Reuse menu::Item trait in picker This opens the way for merging the menu and picker code in the future, since a picker is essentially a menu + prompt. More excitingly, this change will also allow aligning items in the picker, which would be useful (for example) in the command palette for aligning the descriptions to the left and the keybinds to the right in two separate columns. The item formatting of each picker has been kept as is, even though there is room for improvement now that we can format the data into columns, since that is better tackled in a separate PR. * Rename menu::Item::EditorData to Data * Call and inline filter_text() in sort_text() completion * Rename diagnostic picker's Item::Data
* Improve Readability (#2639)Ryan Russell2022-06-01
|
* Add refresh-config and open-config command (#1803)Joe2022-03-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add refresh-config and open-config command * clippy * Use dynamic dispatch for editor config * Refactor Result::Ok to Ok * Remove unused import * cargo fmt * Modify config error handling * cargo xtask docgen * impl display for ConfigLoadError * cargo fmt * Put keymaps behind dyn access, refactor config.load() * Update command names * Update helix-term/src/application.rs Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> * Switch to unbounded_channel * Remove --edit-config command * Update configuration docs * Revert "Put keymaps behind dyn access", too hard This reverts commit 06bad8cf492b9331d0a2d1e9242f3ad4e2c1cf79. * Add refresh for keys * Refactor default_keymaps, fix config default, add test * swap -> store, remove unneeded clone * cargo fmt * Rename default_keymaps to default Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* No need for KeymapResult anymore since we can query .sticky()Blaž Hrastnik2022-03-20
|
* keymap: Store pending/sticky on the root levelBlaž Hrastnik2022-03-20
|
* Add horizontal and vertical split scratch buffers (#1763)Joe2022-03-14
| | | | | | | Make subcommand name more descriptive Fix vsplit completer Run cargo xtask docgen
* Add arrow key mappings for tree-sitter parent/child/sibling nav (#1724)Daniel S Poulin2022-03-08
| | | | | | | | | * Add arrow key mappings for tree-sitter parent/child/sibling nav This helps my use case, where I use a non-qwerty layout with a programmable mechanical keyboard, and use a layer switching key (think fn) to send left down up right from the traditional hjkl positions. * Add new bindings to docs
* Change parameter object keybind from `p` to `a` (#1708)Gokul Soumya2022-03-07
| | | | This is largely to avoid a collision with the soon to be merged paragraph object which takes up the p key.
* Add comment textobject for surround selection and navigation (#1605)Daniel S Poulin2022-03-06
|
* feat(commands): command palette (#1400)Matouš Dzivjak2022-02-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * feat(commands): command palette Add new command to display command pallete that can be used to discover and execute available commands. Fixes: https://github.com/helix-editor/helix/issues/559 * Make picker take the whole context, not just editor * Bind command pallete * Typable commands also in the palette * Show key bindings for commands * Fix tests, small refactor * Refactor keymap mapping, fix typo * Ignore sequence key bindings for now * Apply suggestions * Fix lint issues in tests * Fix after rebase Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Add tree-sitter based function, class navigationGokul Soumya2022-02-15
|
* Mark DAP as experimentalBlaž Hrastnik2022-02-13
|
* Merge remote-tracking branch 'origin/master' into debugBlaž Hrastnik2022-02-13
|\
| * Show infobox with register contentsGokul Soumya2022-02-10
| |
| * add select_next_sibling and select_prev_sibling commands (#1495)Michael Davis2022-01-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * add select_next_sibling and select_prev_sibling commands * refactor objects to use higher order functions * address clippy feedback * move selection cloning into commands * add default keybindings under left/right brackets * use [+t,]+t for selecting sibling syntax nodes * setup Alt-{j,k,h,l} default keymaps for syntax selection commands * reduce boilerplate of select_next/prev_sibling in commands * import tree-sitter Node type in commands
| * Update to rust 1.58, fix a bunch of optional lintsBlaž Hrastnik2022-01-16
| |
| * Add alt-backspace, alt-<, alt->, ctrl-j to insert mode (#1441)WindSoilder2022-01-16
| | | | | | | | | | | | | | | | | | * add alt-backspace keymap to delete word backward * add more useful keymap * map to correct command * add C-j to insert_newline
| * feat(commands): shrink_selection (#1340)Matouš Dzivjak2022-01-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * feat(commands): shrink_selection Add `shrink_selection` command that can be used to shrink previously expanded selection. To make `shrink_selection` work it was necessary to add selection history to the Document since we want to shrink the selection towards the syntax tree node that was initially selected. Selection history is cleared any time the user changes selection other way than by `expand_selection`. This ensures that we don't get some funky edge cases when user calls `shrink_selection`. Related: https://github.com/helix-editor/helix/discussions/1328 * Refactor shrink_selection, move history to view * Remove useless comment * Add default key mapping for extend&shrink selection * Rework contains_selection method * Shrink selection without expand selects first child
| * feat(commands): ensure_selections_forward (#1393)Matouš Dzivjak2021-12-29
| | | | | | | | | | | | | | | | | | | | | | | | | | * feat(commands): ensure_selections_forward Add command that ensures that selections are in forward direction. Fixes: https://github.com/helix-editor/helix/issues/1332 * Add keybinding for ensure_selections_forward Add `A-:` keybinding for the ensure_selections_forward command. * Re-use range.flip for flip_selections command
| * Rename play macro to replay macroIvan Tham2021-12-27
| | | | | | | | | | Macro needs to be defined first before playing so replay is more accurate. Also, replay have the same length as record which makes it looks nice.
| * Switch macro Q and qIvan Tham2021-12-27
| |
| * Macros (#1234)Omnikar2021-12-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Macros WIP `helix_term::compositor::Callback` changed to take a `&mut Context` as a parameter for use by `play_macro` * Default to `@` register for macros * Import `KeyEvent` * Special-case shift-tab -> backtab in `KeyEvent` conversion * Move key recording to the compositor * Add comment * Add persistent display of macro recording status When macro recording is active, the pending keys display will be shifted 3 characters left, and the register being recorded to will be displayed between brackets — e.g., `[@]` — right of the pending keys display. * Fix/add documentation
| * Add `save_selection` command (#1247)Omnikar2021-12-10
| |
| * Assert in release mode too on duplicate keys (#1228)ath32021-12-05
| |
| * feat: Make it possible to keybind `TypableCommands` (#1169)Oskar Nehlin2021-12-04
| | | | | | | | | | | | | | * Make TypableCommands mappable * Fix pr comments * Update PartialEq implementation
| * Add last modified file (gm) (#1093)Ivan Tham2021-12-02
| |
* | Merge remote-tracking branch 'origin/master' into debugBlaž Hrastnik2021-11-30
|\|
| * gf as goto_file (#1102)Bob2021-11-29
| | | | | | | | | | | | | | | | | | | | | | | | | | * goto_file * support goto_file under current cursor * add C-w f/F * sync space w with window mode * Update helix-term/src/commands.rs Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
| * Implement no-yank delete/change (#1099)ath32021-11-24
| |
| * Align selections via & (#1101)Bob2021-11-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * align lines * remove log statement * use selections to align * fix a clippy issue * only accept 1,2,3 as user count * Update helix-term/src/commands.rs Co-authored-by: Ivan Tham <pickfire@riseup.net> * return if user count is not correct * add doc Co-authored-by: Ivan Tham <pickfire@riseup.net>
* | Merge remote-tracking branch 'origin/master' into debugBlaž Hrastnik2021-11-21
|\|
| * Add command to inc/dec number under cursor (#1027)Jason Hansen2021-11-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add command to inc/dec number under cursor With the cursor over a number in normal mode, Ctrl + A will increment the number and Ctrl + X will decrement the number. It works with binary, octal, decimal, and hexidecimal numbers. Here are some examples. 0b01110100 0o1734 -24234 0x1F245 If the number isn't over a number it will try to find a number after the cursor on the same line. * Move several functions to helix-core * Change to work based on word under selection * It no longer finds the next number if the cursor isn't already over a number. * It only matches numbers that are part of words with other characters like "foo123bar". * It now works with multiple selections. * Add some unit tests * Fix for clippy * Simplify some things * Keep previous selection after incrementing * Use short word instead of long word This change requires us to manually handle minus sign. * Don't pad decimal numbers if no leading zeros * Handle numbers with `_` separators * Refactor and add tests * Move most of the code into core * Add tests for the incremented output * Use correct range * Formatting * Rename increment functions * Make docs more specific * This is easier to read * This is clearer * Type can be inferred
| * Readline style insert mode (#1039)Bob2021-11-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * readline style insert mode * update keymap.md * don't save change history in insert mode * Revert "don't save change history in insert mode" This reverts commit cb47f946d7fb62ceda68e7d1692a3914d0be7762. * don't affect register and history in insert mode * add insert_register * don't call exit_select_mode in insert mode * avoid set_selection * avoid duplicated current!
| * Add movement shortcut for history (#1088)Ivan Tham2021-11-14
| | | | | | alt-u and alt-U
| * Add trim_selections command (#1092)ath32021-11-14
| |
| * Added workspace_symbol_picker (#1041)Ebbe Steenhoudt2021-11-14
| | | | | | | | | | | | | | * Added workspace_symbol_picker * Moved truncation of the symbol pickers to the end. * Fixed typo
| * Implement "Goto last modification" command (#1067)ath32021-11-14
| |
| * fix: shift-tab mappings broken after efc2b4c7Blaž Hrastnik2021-11-12
| |
| * Add arrow keys to view mode (#987)NexiNov2021-11-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add arrow keys to view mode * Drop C-up and C-down * Update docs for #987 * Format correctly * Drop other keymaps * Correct keymap.md * Add arrow keys to view mode Drop C-up and C-down Update docs for #987 Format correctly Drop other keymaps Correct keymap.md Rebase Co-authored-by: Rust & Python <nexinov@localhost.gud-o15> Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
| * Add `remove_selections` command (#1065)Omnikar2021-11-12
| | | | | | | | | | | | | | | | | | * Add `remove_selections` command * Document `remove_selections` * Update helix-term/src/keymap.rs Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
| * Allow keys to be mapped to sequences of commands (#589)Omnikar2021-11-11
| | | | | | | | | | | | | | | | | | * Allow keys to be mapped to sequences of commands * Handle `Sequence` at the start of `Keymap::get` * Use `"[Multiple commands]"` as command sequence doc * Add command sequence example to `remapping.md`
| * add wonly -- window only (#1057)Bob2021-11-11
| | | | | | | | | | | | | | | | | | | | | | | | | | * add wonly * Update book/src/keymap.md Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> * add `wonly` to space w mode too * remove the TODO Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
| * Refactor keyevent handling using key, ctrl macros (#1058)Gokul Soumya2021-11-10
| | | | | | | | | | | | Adds ctrl! and alt! macros (which existed before the big keymap refactor) and uses them in event handling of Components. Note that this converts crossterm's KeyEvent to our own KeyEvent on each invocation of handle_event in Components.
| * Ensure that identical keymaps stay in sync (#1056)Gokul Soumya2021-11-10
| | | | | | | | | | | | | | Space mode and view mode are duplicated on two different keybinds, and they tend to get out of sync by contributers forgetting to update both of them. This commit adds a test that explicitly checks that they are identical. Prevents issues like #1050.
| * Check for duplicate keys in default keymapGokul Soumya2021-11-10
| |
| * Change page keybinds in view modeGokul Soumya2021-11-10
| | | | | | | | | | | | | | b which was assigned to page_up conflicts with align to bottom, so this commit replaces page up, down, etc keybinds to use normal mode keybinds (C-f, C-b, etc) in view mode too.