/** * Vim Mode Type Definitions * * Types for vim-style navigation, modes, motions, search, and marks. * Premium feature for Plus+ tiers. * * @since v1.58.0 */ import type { Tier } from '../../core/types/auth.js'; /** * Vim mode types */ export type VimMode = 'normal' | 'insert' | 'visual' | 'command'; /** * Motion direction */ export type MotionDirection = 'up' | 'down' | 'left' | 'right'; /** * Motion type for categorizing motions */ export type MotionType = 'basic' | 'line' | 'word' | 'screen' | 'page' | 'document' | 'search' | 'mark'; /** * Search direction */ export type SearchDirection = 'forward' | 'backward'; /** * Visual mode selection type */ export type VisualType = 'char' | 'line' | 'block'; /** * Motion command definition */ export interface MotionCommand { /** Motion identifier */ id: string; /** Key sequence to trigger */ keys: string[]; /** Motion type category */ type: MotionType; /** Human-readable description */ description: string; /** Minimum tier required */ minTier: Tier; /** Whether motion supports count prefix */ supportsCount: boolean; /** Execute the motion and return new index */ execute: (context: MotionContext) => MotionResult; } /** * Context for executing a motion */ export interface MotionContext { /** Current index in the list */ currentIndex: number; /** Total number of items in the list */ totalItems: number; /** Number of visible items on screen */ visibleItems: number; /** Current scroll offset */ scrollOffset: number; /** Count prefix (e.g., 5 in "5j") */ count: number; /** Active search query */ searchQuery?: string; /** Search results indices */ searchResults?: number[]; /** Current search result index */ searchResultIndex?: number; /** Marks map */ marks?: Map; /** Previous position (for '' jump) */ previousPosition?: number; /** Items for text-based search */ items?: string[]; } /** * Result of a motion execution */ export interface MotionResult { /** New index after motion */ newIndex: number; /** New scroll offset (if changed) */ newScrollOffset?: number; /** Whether to enter visual mode */ enterVisual?: boolean; /** Whether to exit visual mode */ exitVisual?: boolean; /** Mark to set */ setMark?: string; /** Position to save as previous */ savePreviousPosition?: boolean; /** Error message when motion is invalid (e.g., jump to unset mark) */ error?: string; } /** * Vim state machine state */ export interface VimState { /** Current mode */ mode: VimMode; /** Pending count prefix (e.g., "5" before "j") */ pendingCount: string; /** Pending operator (for operator-pending mode) */ pendingOperator?: string; /** Visual mode start index */ visualStart?: number; /** Visual mode type */ visualType?: VisualType; /** Command line input (for : mode) */ commandInput: string; /** Whether vim mode is enabled */ enabled: boolean; } /** * Vim mode transition */ export interface VimTransition { from: VimMode; to: VimMode; trigger: string; } /** * Search state */ export interface SearchState { /** Current search query */ query: string; /** Search direction */ direction: SearchDirection; /** Whether search is active */ active: boolean; /** All matching indices */ results: number[]; /** Current result index */ currentResultIndex: number; /** Whether search is case sensitive */ caseSensitive: boolean; /** Whether to use regex */ useRegex: boolean; } /** * Mark state */ export interface MarkState { /** Named marks (a-z) */ marks: Map; /** Previous position (for '' and `` ) */ previousPosition: number | null; /** Jump list for Ctrl+o/Ctrl+i */ jumpList: number[]; /** Current position in jump list */ jumpListIndex: number; } /** * Vim configuration */ export interface VimConfig { /** Enable vim mode */ enabled: boolean; /** Minimum tier required for full vim mode */ minTier: Tier; /** Start in normal mode (vs insert) */ startInNormalMode: boolean; /** Show mode in status bar */ showModeIndicator: boolean; /** Timeout for key sequences (ms) */ keyTimeout: number; /** Case-insensitive search by default */ ignoreCase: boolean; /** Smart case (ignore case unless uppercase in query) */ smartCase: boolean; /** Highlight search matches */ highlightSearch: boolean; /** Incremental search (search as you type) */ incrementalSearch: boolean; /** Number of items to scroll with Ctrl+u/d */ scrollAmount: number; } /** * Default vim configuration */ export declare const DEFAULT_VIM_CONFIG: VimConfig; /** * Key event for vim processing */ export interface VimKeyEvent { /** Key pressed */ key: string; /** Whether Ctrl was held */ ctrl: boolean; /** Whether Alt was held */ alt: boolean; /** Whether Shift was held */ shift: boolean; /** Whether Meta was held */ meta: boolean; } /** * Vim action result */ export interface VimActionResult { /** Whether the key was consumed */ consumed: boolean; /** New vim state */ newState?: Partial; /** Motion result if a motion was executed */ motionResult?: MotionResult; /** Search result if search was performed */ searchResult?: SearchState; /** Command to execute (from command mode) */ command?: string; /** Error message if action failed */ error?: string; } /** * Mode indicator display */ export interface ModeIndicator { mode: VimMode; label: string; color: string; } /** * Mode indicator configurations */ export declare const MODE_INDICATORS: Record; /** * Vim mode tier requirements */ export declare const VIM_TIER_REQUIREMENTS: Record; /** * Check if a feature is available for a tier */ export declare function isVimFeatureAvailable(feature: string, userTier: Tier): boolean; /** * Parse a key sequence string into individual keys */ export declare function parseKeySequence(sequence: string): string[]; /** * Serialize a VimKeyEvent to a string */ export declare function serializeKeyEvent(event: VimKeyEvent): string; /** * Parse a key string to VimKeyEvent */ export declare function parseKeyEvent(keyStr: string): VimKeyEvent; //# sourceMappingURL=vim-types.d.ts.map