Skip to content

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

Open
christphralden wants to merge 9 commits into
ZenNotes:mainfrom
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:mainfrom
christphralden:al/feature/vim-mappings

Conversation

@christphralden

@christphralden christphralden commented Jun 13, 2026

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

@Tornado300

Copy link
Copy Markdown

i would love a way of adding my vim config into zennotes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants