-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add always-on modal actions mode for Vim action keybindings #41268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: 0xGlace <[email protected]>
|
Nice! Thanks for this. Do we need passive mode, or can we just enable vim mode always without loading the keymap? There are a few actions that we override (e.g. Line 403 in cdc2736
Some vim actions require an additional argument that is currently required to be passed by a keystroke (like Happy to pair with you on this if you want: https://cal.com/conradirwin/pairing |
…he vim mode setting now toggles whether its keymap is loaded and the behavior of Vim mode.
|
I removed the passive mode and went after the keymap itself, with the last changes, Vim mode is always on and the setting only toggles its keymap and changes some behavior similar to the previous passive mode.
That's now handled: I also changed the tests, one of them tests for this exact case. I think this is much better than the previous approach, that one also had an issue where the mode indicator didn't update properly and I spent most of the time trying to figure out, not having experience with GPUI also made it more tricky but this removes the need for things like that.
Thank you! and I wish I could but I'm not in a place where I can at the moment |
|
I just realized another thing new approach allows for I think is having the conditional keybind context which passive mode didn't allow for |
|
I added a keybind context |
This PR enables using Vim operators and text objects via keybindings without entering full modal editing mode. When enabled, Vim is activated but doesn't observe keystrokes, change cursor shape and keeps editor input enabled.
This is most useful when one wants to slowly transition into full modal editing, or just needs some of the functionality and doesn't want to keep switching between modes.
With this, Vim actions can be used in any normal keybind:
{ "context": "Editor", "bindings": { "cmd-shift-g": "vim::HelixGotoLastModification", "cmd-'": [ "action::Sequence", [ "vim::SwitchToVisualMode", ["vim::PushObject", { "around": false }], "vim::AnyQuotes" ] ] } }Added a description with a few examples to the Vim mode documentation.
Added toggle option for "Always-on Modal Actions" in Keymap settings:
This feature has a few accompanying tests:
test_passive_mode_typing_worksEnsure editor input works in passive mode.
test_passive_mode_delete_inside_quotesTest a keybind for deleting inside of quotes.
test_passive_mode_selection_preservingEnsure the selection is preserved after the action has been executed.
test_passive_mode_goto_last_modificationTest
HelixGotoLastModificationworking in passive mode to ensure Vim is getting editor updates.Original feature idea and motive from Adam Wathan's post.
This implementation is basically the same thing mentioned by [at]ConradIrwin under the same post.
Release Notes: