esm7_obsidian-vimrc-support/utils/vimApi.ts
Aly Thobani 0b1168b2ae chore: replace unnecessary CodeMirrorEditor import aliases
- CodeMirror.Editor is globally available as a type (and already used in other files), so lets just
  stick consistently to using that
2026-05-24 17:32:38 -07:00

32 lines
829 B
TypeScript

/**
* Partial representation of the CodeMirror Vim API that we use to define motions, commands, etc.
*
* References:
* https://github.com/replit/codemirror-vim/blob/master/src/vim.js
* https://libvoyant.ucr.edu/resources/codemirror/doc/manual.html
*/
import { EditorPosition } from "obsidian";
export type MotionFn = (
cm: CodeMirror.Editor,
cursorPosition: EditorPosition, // called `head` in the API
motionArgs: { repeat: number }
) => EditorPosition;
export type ActionFn = (
cm: CodeMirror.Editor,
actionArgs: { repeat: number },
) => void;
export type VimApi = {
defineMotion: (name: string, fn: MotionFn) => void;
defineAction: (name: string, fn: ActionFn) => void;
mapCommand: (
keys: string,
type: string,
name: string,
args: any,
extra: { [x: string]: any }
) => void;
};