Conversation
|
whoa. helix mode sounds cool. thanks. this will be interesting to play around with. |
|
the ci needs to be green to proceed. i think these are just formatting |
|
The manual test sequence is helpful for those who don't use helix. However, on my mac, it doesn't work precisely as you've laid out in those bullets. I'm not sure if they're just wrong or if it's a bug. |
|
I'll check it out! I've def been testing on windows layout so it's likely something I missed. That documentation there also might have gotten out of sequence in editing too. Good reminder to make sure the keyboard layout is consistent either way |
|
@fdncred if you want to kick off CI again, i was able to fix a few bugs and think it's working pretty smoothly, ran cargo test and cargo fmt --all locally, hopefully it will pass this time, not sure how the spell checker works though |
|
This is getting pretty close to complete w/comprehensive tests for the commands listed, but i'm gonna mark this as draft temporarily since i want to try to reconcile upstream Helix's architecture a little more closely with reedline's interface... hopefully it will reduce the footprint of this PR. |
|
Are you planning on moving forward with this at all? I'd be willing to help, although my rust knowledge is very limited. |
|
Hi, I am although I haven't had too much free time for open source lately. If youd like to pick it up I think right now it would just be helpful to try the demo and double check feature parity. I'm a total rust noob too so any refactoring that's more rust-idiomatic or reduces the size of the PR would definitely be welcome. Let me know if there's anything else I can help with, I'm gonna try to use some of the holiday season to catch up on things |
|
I've just tested it. Things that work/don't:
Thank you for working on this. Looking forward to having helix mode on nushell some day :-). I too always wish I would spend more time to work on open source. |
|
Hey there, I have been dreaming of a helix mode in nushell for a long time now. There is the possibility to use ctrl-o to open helix and edit the prompt, but it does not feel natural. |
|
@kronberger-droid |
|
I have some time to revisit this. I will see what to-dos are left before this might be merge ready and will let the thread know if I find areas to help! |
|
OK, i've made significantly more process but i feel like i'm running in circles with the w/b logic. The abstraction logic is a little odd in terms of where the word/whitespace boundaries are defined, e.g. the i believe theres some underspecified and overabstracted definitions here; What we need to do is settle on/reconcile definitions of the selection and cursor indices. helix defines its model with indexes for an "anchor" and a "cursor" with the selection being defined as the characters between these indexes. I'm running into limitations here both in terms of how vi handles these boundaries and my Rust knowledge in terms of what an appropriate abstraction might look like (e.g. passing "select" as a bool to these methods seems a little out of place here). After we resolve this i think this should be ready to merge. If anyone wants to propose a way forward that would be great! The cleaner the better, if we can brute force a solution without changing the abstrations thats fine; but i need to take a break after trying that approach for a bit. If someone can propose (and we can agree on) a good abstraction model that reconciles the two modes I think that's the ideal path forward. edit: a good entrypoint to the issue would be the cursor position for "w" when there are multiple space between words. I tried mapping this to EditCommand::MoveWordRight after trying EditCommand::MoveWordRightStart incorrectly placed the cursor at the beginning of the next word instead of the space right before it (latter is correct behavior for Helix, presumably not for vi) |
|
I've been looking into this a little bit. The It would mean new I am thinking about adding two commands:
This would give Helix its own motion path with no dependency on |
|
In my perfect world we'd find a crate the implements well known emacs, vim, and kakoune/helix keybindings and implement that crate and let it do the heavy lifting. Anyone know of such a crate or even multiple crates? I know about modalkit for vim. |
|
@fdncred I know we've talked about using modalkit for this feature before. i think now that the work is a little more scoped it's probably a good idea to revisit. I believe ratatui uses crossterm for this kind of stuff, think it could work? my initial thought is that it might be more designed for a terminal app than a shell app but initially it seems like it has at least a superset of the functionality we want. i'd probably lean towards modalkit for that reason edit: interestingly, there's a ratatui-modalkit project that combines the approaches; seems liike modalkit might be the way to go |
|
I could be wrong because I haven't studied it deeply but I thought modalkit was only for vim. Do you think it could work for helix as well? Ratatui definitely can use crossterm as a backend, we use it in nushell commands like |
|
modalkit has built-in configurations for vim and emacs but its main modules are the lower level primitives we want. maybe at some point we can even push a custom helix configuration upstream |
|
What is the plan now? I figure the semantic changes I suggested are something we can work on in the future since it is quite overkill for only solving the w/W motions. Since we could solve the problem just by keeping the semantics the same and adding two entries to
Am I seeing this right that I also found a small bug which happens for Otherwise it feels like there are enough stable features to start maybe going over the code to look if we can find some things which might be able to be refactored like @schlich mentioned before. |
|
Excellent suggestions. Perhaps the new plan could just be to essentially start from a fresh branch of main and do small red/green/refactor cycles for review, that way we can get this feature out and accomplish the refactoring in parallel |
|
Should we try to fix the last bugs on here, or go forward with your plan? @schlich |
|
If you can submit a patch to get things to work go for it! I can work on tidying things up before review. Should have time in the next few days. |
dd0ef3a to
445eaac
Compare
|
alrighty, i just pushed up a total rework focused on a 100% implementation of helix mode based on modalkit's primitives. it took me a while to figure out some patterns and i still dont think i'm all the way there, but this feels a lot more sustainable and workable, with the bonus that it's not going to rely on any vi/emacs code so we can fully gate it on the feature flag. It's regressed on some of the implementation technically but i'm gonna try to get at least the common normal/visual mode and mode switching actions done before i take a break. This has been a great project for learning me some Rust! |
|
I would love to test this, but I'm not sure how to enable the helix mode when building (I'm not very familiar with Cargo). Any advice? |
|
I'd like to test it too. You'd have to compile with |
|
I'm working on a demo, but as-is it's gonna require a patch to the w/b logic to be any use, even with modalkits the logic is still proving tricky. Should be able to get a demo up this afternoon though |
|
I can handle the word motions, I have been fighting with it for a bit and I feel like I could help there. Is there now some semantic comparable to Helix's Range { anchor: usize, head: usize }? Which encodes direction. And do we have a CharType Enum? If we have it, I should be fine. |
|
@kronberger-droid best place to start would probably be in the prelude section |
|
gonna wait on adding this to this PR because it still has kinks and i want to look more into rusts module/export system BUT here is WIP on the tutorial example if anyone is picking up on this; need to log off for today https://github.com/schlich/reedline/tree/schlich/helix-example |
|
I just want to mention that I had to do some tweaking in the apply_motion calls for word motions to work. Since there is no real solution for them using only modalkits primitives alone. For testing I adapted Helix's cursor notation to make it easier to reason about test cases:
And scraped some of the test cases from helix's source. |
that was fun. i love the tutorial mode. very helpful for those who don't quite know the helix motions. it does remind me that our selection foreground and background are just terrible without any way to change the color. maybe someday we can fix that too. ugh.
I think having some of helix's own test cases is a great idea. So, I'm supportive of having them in whichever branch we think is best. |
|
Its now a descendant of the schlich/helix-example branch But all the motions are still only defined in terms of the TestBuf since i was not sure how to bridge the gap to reedline. But it is a step in the right direction i think. Tests at the end of hx/mod.rs should be easy to validate if you are using hx as editor since i have placed the raw strings above the case. |
|
I still don't really understand how we will bridge the gap from modalkit to reedline. Modalkit works on the premise that you have access to the buffer. Since we have to always go through reedline events we always land on the same problem that we will have to extend EditCommands anyways. Or am I just not understanding something? @schlich |
|
I haven't looked too much into that aspect of it yet, good questions. It might leverage the fact that they both use cross term under the hood (modalkit re-exports it) but that's just a hunch, I haven't looked into specifics. Very well may need to add to EditCommand idk. Unfortunately I've been I'll today but will jump back into this asap |
|
PS feel free to add commits to this PR as long as they include tests/ leave things in a working state! |
perhaps we could adjust Reedline.run_edit_commands to pass buffer context along with the commands? that seems like the easiest entrypoint if we need buffer context. What do you think? |
|
All good, take your time to get well. I will look into it and try to test some possible solutions. I think making a more isolated selection abstraction inside Reedline's current architecture, will make it pretty easy to implement all of the proposed helix motions, and more if we get the selection abstraction versatile enough to handle multi cursors etc. But I am very open for modalkit if we find a nice solution, but right now I can't seem to find one. |
|
The more I look into it the more i tend to agree even though i'm a little fuzzy on where the mismatch is, precisely. i've pushed up the branch w/earlier iteration of this PR that contained my reedline-only code but it's a bit AI slop-ish. it should be helpful but as we mentioned before we might want to iterate on changes from a fresh branch off of main. https://github.com/schlich/reedline/tree/hx-reedline |
|
I'm up for gutting how reedline handles all the keystroke related stuff in favor of modalkit or some other crate that standardizes a way to use keystrokes for emacs, vim, and helix (and works with well-known vim/helix/emacs standards). However, we need to figure out a way to do that in a somewhat non-breaking change way. What I'm thinking is feature-gating the changes so the default is close to what it is today, and the feature is the gutted version that may work very different on the inside but to the end user, it just works (tm) just better. The thing that makes major code surgery difficult is we don't have enough test cases to ensure non-breaking changes plus it's extremely difficult to review huge PRs. If it's in a feature, we could ship close-to-working stuff that isn't ready for prime-time (but compiles), piece-by-piece without the fear of it breaking every user who uses reedline whether in nushell or just as a crate in their cool app. Thoughts? |
|
You mean the missmatch between vi and hx or the missmatch between modalkit and reedline? I think it makes sense to use modalkit as a backend and make it feature gated. But right now it feels like we would have to do major changes in the Editor, i am not sure if it can be easily feature gated without a lot of code dublication. But it is definitely the best option. I will now work on a clean branch and implement a feature gated helix mode, since i have now identified a possible minimal implementation, based on some new EditorCommands and a new Selection struct in the Editor. |
yeah, between modalkit and reedline. i spent some time reading the architecture on deepwiki but am having a bit of trouble mapping concepts. I understand the bit about "modalkit assumes we have access to the linebuffer" but i'm trying to figure out what these architecture differences look like at a higher level, why they were designed the way they were, etc. I would want to have a deeper understanding of what reedline's mechanisms would look like if it were more fully integrated with modalkit before advocating for an overhaul here are some diagrams that i think are helpful to ground the conversation: |
Edit 2/17/2026: PR in progress!!! See comments below