feat(editor): add opt-in vim mode#149
Conversation
Add Obsidian/Zed-style modal editing to the CodeMirror editor via @replit/codemirror-vim, disabled by default and toggleable in settings. - vimModeEnabled and vimRelativeLineNumbers settings (persisted per vault) - vim and line-number compartments wired into the editor with live reconfigure - mode status bar (NORMAL/INSERT/VISUAL) and themed :command input - :w/:wq/:q/:x ex-commands mapped to existing save/close actions - relative line numbers in code mode - fix block cursor visibility on live-preview list lines and the black :command input on the dark theme
|
let me review what fail :) |
npm install on macOS/arm64 pruned the cross-platform optional @emnapi transitive deps, breaking npm ci on CI runners. Restore them so the lockfile only adds @replit/codemirror-vim over upstream.
|
Hey, no worries haha, the fix was super easy and I was about to fix it! Im sorry, I did a lot of changes today in main. |
|
I found two behavior issues that are worth fixing before merging:
Result: Vim can remain disabled in a restored tab after enabling it, or remain enabled after disabling it. A good fix would be to either reconfigure the relevant compartments on restored states, or recreate cached states when global editor settings such as
This likely needs an explicit invalidation path on One product question: Vim mode is currently stored per vault through the existing settings persistence. I wonder if it would be better as a global preference instead. Modal editing is usually a user-level editing habit rather than a vault-specific behavior, so making it global might better match user expectations. Focused tests and lint passed locally:
Full |
|
Also I audited the The strict I don’t see this PR introducing a payload without I also reran the app locally and could not reproduce the error. So this does not look like a blocker for the PR. If it appears again, we should capture the failing backend |
Reconfigure the vim and line-number compartments after restoring a cached EditorState so toggling vim mode (or relative numbers) applies to tabs whose state was stashed under the old configuration. Build the relative line-number gutter directly with a lineMarkerChange that fires on selectionSet, so relative numbers recompute as the cursor moves instead of going stale until an unrelated repaint. Closes jsgrrchg#148
|
hello, I just updated the codebase can you review it again, thanks |
|
I will also give it a try |
|
A quick test shows that it works great! Very seamless and feels like my MacVim. All relevant commands work. |
|
@Abdulkader-Safi I’ve been playing around with it, you did an awesome job! I’m really enjoying it. |
|
I pushed a very small fix for the TypeScript build issue introduced by the relative line-number marker ( One question for you guys, @spamsch and @Abdulkader-Safi before merging, does it make more sense for Vim mode to be a global setting instead of per-vault? My instinct is that Vim users will usually want this enabled across all their vaults, not separately per vault. If that makes sense to you both, I can add one more commit to make this setting global and then we can close/merge the PR. This is my only remaining blocker. Happy to hear your thoughts. |
|
Good point! Per vault does not make sense at all. Did not realize it was. I want to have it active in every vault. |
|
Thanks @spamsch , I agree, it doesn't make sense to me either, in my opinion is more clean as a global setting, I'll add now a commit to change that and wrap this up 😊. |
|
LGTM, merging when checks go green, thank you guys, very happy to see this land in main, thanks @Abdulkader-Safi you really cooked 👨🏻🍳. |
Add Obsidian/Zed-style modal editing to the CodeMirror editor via @replit/codemirror-vim, disabled by default and toggleable in settings.