Conversation
|
My assumption was that these bite-sized PRs would (eventually) be implementing modalkit as a standard way to do helix keybinds and then eventually move modalkit into emacs and vim keybindings replacing the existing system. If I'm wrong, let me know. The size of this PR is fine because it's easy to view the changes and the tests supporting them. They could be a bit bigger if needed but small is ok too. As far as matching, whatever we think is the cleanest looking and easiest to understand is probably the way to go. |
|
great -- i will incorporate modalkit logic into this PR and we can see how it looks. stand by! |
|
One thing to keep tabs on -- modalkit would require a bump in MSRV if we want to implement directly. I could upgrade on this PR but i would imagine it would block, alternatively i can try to mimic modalkit's API with some stub interfaces and see where that gets us just as far as getting an idea of the shape of the code, and we can defer the upgrade until we have a better idea of the impact |
|
Our msrv now is 1.63 i think, that's quite old (Aug-2022). I'm not super worried about bumping that a bit if we have good reason. The idea of modalkit is to keep from reinventing the wheel in regards to vim, and hopefully other, keybindings. If modalkit is not right, i'm down with whatever is better too. Let me put it like this, for years we've had nit-picky problems with our vim keybindings. I hear so much complaining like, "This is why I'm not using nushell" and it comes down to some vim nuance. I was hoping modalkit would be a standard and correct way to do vim bindings. I really don't know for sure though. So, when we started talking about helix motions I immediately was hoping for a better system where all these errors go away for vim, emacs, and helix. Maybe I'm naive but that's what I'm hoping for. |
2b7fe51 to
26b376b
Compare
26b376b to
79f17af
Compare
|
Updated the PR description; this is ready for review |
fdncred
left a comment
There was a problem hiding this comment.
I looked this over and tested the examples. The only problem I found was the crossterm version.
|
I pushed a commit onto this pr to try and avoid downgrading crossterm. We need to get modalkit to upgrade and then fix these dependencies but at least this won't hold us up. @schlich you should feel free to delete my commit if you have a better idea. Just trying to help out. |
|
Will take a look! Is it conventional for rust projects to pin dependencies to specific versions? It's pretty faux pas in python land to not just specify lower bounds |
|
it's pretty typical to pin deps if you have a reason to. no harm done. it's a good way to keep cargo from trying to update deps when you build without compiling with --locked. |
|
pushed up some changes with 'a' key normal -> insert mode ("append"), a bunch of small refactors for ergonomics, and an example of a property-based test for insert-key fallback behavior. do we want to try to merge this before it gets much larger? are we ok with the crossterm resolution as a stopgap until modalkit upgrades? |
|
Yes, let's not make this PR any larger. It's large enough already. Yes, I'm ok with the modalkit stopgap. We need to convince modalkit to upgrade somehow, quickly hopefully. The only thing in this PR that I object to is there are way too many changes to the Cargo.lock file. It looks like someone ran cargo update. We don't need to do that. We just need to update the specific crates. We also need to ensure that all the helix changes are behind the helix feature. |
|
i dont recall running cargo update, just def will double check all the feature markers |
This reverts commit e842ad0.
|
ok, so i reverted the installation of proptest but we are still upgrading the lockfile when we add modalkit, aren't we? and don't forget we are changing the MSRV too. we could try to go back to the lockfile state before the PR and do |
|
another reminder, upgrading MSRV gave us some new clippy errors. we will need to explicitly ignore them if we want to completely avoid touching existing code, or I can open a PR just focusing on that bump so we can separate things out? |
|
ok, understood. yes, i realize we're updating things and i'm fine with that but i'm not fine with doing a cargo update. Glad you didn't do that. Sometimes updating dependencies globally can cause instability. I've seen it time and time again on nushell. We try to be very careful with the lock file. We've also seen that cargo is stupid sometimes and upgrades or downgrades dep versions when it's not needed. Just to be clear, I'm good with whatever updates to the lock file are required for our deps and msrv. I'm not good with globally updating everything with cargo update. I'm fine with proptest being added too. From my perspective, the more tests we can have the more stable things will get. I think all clippy issues should be fixed in the PR that introduces them. We prefer to have a clean build with PRs. |
|
What's the status here? Are we just waiting on a review or are there more changes incoming? |
|
Sent the maintainer an email :) |
I assume you mean modalkit and not me. I saw they landed the PR to bump crossterm. This PR could be updated to use the latest version. |
|
ok, based on @ulyssa 's suggestions i've updated the dependencies/imports to utilize the |
|
ok, keybindings clever. I didn't consider that and didn't see the comment. I think I'm ready here too but we need to wait for the reedline/nushell release this weekend. I don't like to include anything in the nushell release that hasn't be tested, even if it's feature gated. |
Summary:
This PR replaces the ad hoc Helix mode matcher with a small modalkit-backed modal machine and wires that into the experimental Helix edit mode. It adds basic insert/normal mode switching, minimal cursor movement, and insert-mode character handling, while also bringing in the dependency and MSRV changes needed to exercise modalkit in-tree.
Motivation
This is part of #960 and a follow-up to #1033. The main goal is not just to add a couple more Helix bindings, but to validate whether modalkit is the right abstraction for modal editing in reedline before more Helix behavior lands and before similar logic spreads further across modal editors.
Change overview:
keybindingsas a dependency.Helix { mode }plus(mode, modifiers, key)matchinparse_eventwith aModalMachine<TerminalKey, HelixStep>-based implementation.HelixModefor insert/normal stateHelixActionfor high-level actionsHelixBindingsfor the binding tableHelixStep = (Option<HelixAction>, Option<HelixMode>)for action + mode transitionsEscswitches insert -> normaliswitches normal -> insertInsertCharh/left andl/right map to cursor movement in normal modeTryFrom<ReedlineRawEvent> for KeyEventhelper (feature-gated) to make the Helix event path cleaner.Tests/Example:
Helix { mode }Helix { machine }(mode, modifiers, key)matchinparse_eventModalMachine<TerminalKey, HelixStep>self.mode = ...transitionsOption<HelixMode>inHelixStepReedlineEventreturns for each caseHelixAction -> ReedlineEventmappingModeKeys::unmappedfor insert mode