Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feature(vimscript-mappings): add support to extend base keymaps with vimscript#146

Open
christphralden wants to merge 9 commits into
ZenNotes:main from
christphralden:al/feature/vim-mappings
Open

feature(vimscript-mappings): add support to extend base keymaps with vimscript #146
christphralden wants to merge 9 commits into
ZenNotes:main from
christphralden:al/feature/vim-mappings

Conversation

@christphralden

@christphralden christphralden commented Jun 13, 2026
edited
Loading

Copy link
Copy Markdown

Issue #143

Goal

Vimscript support to enable flexible remapping

Design desicion

Currently codebase has contracts for keymaps with different scopes of KeymapScope. What this PR aims to do is not do a full refactor of existing architecture, but to allow flexibility for users to define their own keymap

User defined vimscript will be referred as user-mappings for this context

user-mappings are treated as a different entity from KeymapDefinition. Why?

  1. To eliminate complexity early on from managed keys and user's preferences
  2. Allows complete flexibility to users as long as they know what they are doing (which if you use this app, you probably used vim before)

user-mappings interact directly with codemirror's api

user-mappings are defined inside settings > keymaps > Vimrc opposed as to source it using the file system to give reactive feedback like conflicting keymaps and errors. This is also because we could not possibly support every syntax for example setting a variable.

Going with this direction, to improve UX, conflicting keymaps should be surfaced as warnings for users to manage

Summary

  • Add Vimscript support for custom key mappings in the Editor settings, surfaced as a textarea in the Keymaps panel
  • Introduce diagnostics for user-mappings and flag unknown commands, missing RHS, and conflicts with existing app keymaps inline below the textarea
    Supported syntax are as such
export type VimMode = 'normal' | 'visual' | 'insert'
export type VimMapCmd =
 | 'noremap'
 | 'map'
 | 'nnoremap'
 | 'nmap'
 | 'vnoremap'
 | 'vmap'
 | 'xnoremap'
 | 'xmap'
 | 'inoremap'
 | 'imap'
export type VimUnmapCmd = 'unmap' | 'nunmap' | 'vunmap' | 'xunmap' | 'iunmap'
  • Detect keymap collisions which is a plus feature

Notes

There are noisy diffs from differences in linter, if you could specify a .prettierrc it would be great :)


image

...ettings UI; move toVimSequence to vim-mappings, import findConflictingKeymaps and diagnoseVimMappings to flag per-row conflicts in the shortcut editor with count badge, inline vimrc warnings, and vimrc-overridden chips on affected keymaps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adibhanna adibhanna Awaiting requested review from adibhanna adibhanna is a code owner

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /