vim-sim 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,32 +11,32 @@ A complete, production-ready Vim editor simulation engine for Node.js. Implement
11
11
  ## Features
12
12
 
13
13
  ### Core Editing
14
- -**All Basic Motions**: `h`, `j`, `k`, `l`, `w`, `b`, `e`, `W`, `B`, `E`, `0`, `$`, `^`, `gg`, `G`, `{`, `}`, `(`, `)`, `%`
15
- -**Find & Till**: `f`, `F`, `t`, `T`, `;`, `,`
16
- -**Operators**: `d`, `c`, `y`, `>`, `<`, `=`, `g~`, `gu`, `gU`
17
- -**Visual Mode**: Character (`v`), Line (`V`), and Block (`<C-v>`) with all operators
18
- -**Text Objects**: `iw`, `aw`, `i"`, `a"`, `i'`, `a'`, `i(`, `a(`, `i{`, `a{`, `i[`, `a[`, `it`, `at`, `ip`, `ap`, `is`, `as`
19
- -**Insert Mode**: `i`, `I`, `a`, `A`, `o`, `O`, `s`, `S`, `c` commands
20
- -**Replace & Change**: `r`, `R`, `~`, `J`, `gJ`
14
+ - **All Basic Motions**: `h`, `j`, `k`, `l`, `w`, `b`, `e`, `W`, `B`, `E`, `0`, `$`, `^`, `gg`, `G`, `{`, `}`, `(`, `)`, `%`
15
+ - **Find & Till**: `f`, `F`, `t`, `T`, `;`, `,`
16
+ - **Operators**: `d`, `c`, `y`, `>`, `<`, `=`, `g~`, `gu`, `gU`
17
+ - **Visual Mode**: Character (`v`), Line (`V`), and Block (`<C-v>`) with all operators
18
+ - **Text Objects**: `iw`, `aw`, `i"`, `a"`, `i'`, `a'`, `i(`, `a(`, `i{`, `a{`, `i[`, `a[`, `it`, `at`, `ip`, `ap`, `is`, `as`
19
+ - **Insert Mode**: `i`, `I`, `a`, `A`, `o`, `O`, `s`, `S`, `c` commands
20
+ - **Replace & Change**: `r`, `R`, `~`, `J`, `gJ`
21
21
 
22
22
  ### Advanced Features
23
- -**Undo/Redo Tree**: Full vim-style undo tree with branches (`u`, `<C-r>`, `g-`, `g+`)
24
- -**Macros**: Record (`q`) and playback (`@`) with count support
25
- -**Marks**: Local and global marks (`m`, `'`, `` ` ``)
26
- -**Jump List**: `<C-o>`, `<C-i>` navigation
27
- -**Registers**: Named, numbered, and special registers
28
- -**Spell Checking**: Real-time with custom dictionaries
29
- -**Completion**: Keyword, line, file, and omni completion
30
- -**Folds**: Code folding support
31
- -**Multiple Windows**: Split, navigate, and resize
32
- -**Multiple Buffers**: File management and buffer navigation
23
+ - **Undo/Redo Tree**: Full vim-style undo tree with branches (`u`, `<C-r>`, `g-`, `g+`)
24
+ - **Macros**: Record (`q`) and playback (`@`) with count support
25
+ - **Marks**: Local and global marks (`m`, `'`, `` ` ``)
26
+ - **Jump List**: `<C-o>`, `<C-i>` navigation
27
+ - **Registers**: Named, numbered, and special registers
28
+ - **Spell Checking**: Real-time with custom dictionaries
29
+ - **Completion**: Keyword, line, file, and omni completion
30
+ - **Folds**: Code folding support
31
+ - **Multiple Windows**: Split, navigate, and resize
32
+ - **Multiple Buffers**: File management and buffer navigation
33
33
 
34
34
  ### Text Formatting
35
- -**Auto-indentation**: Smart indentation based on braces
36
- -**Text Wrapping**: Format text with `gq`, `gw`
37
- -**Alignment**: Column alignment support
38
- -**Comment Toggling**: Smart comment handling
39
- -**Digraphs**: 150+ special characters
35
+ - **Auto-indentation**: Smart indentation based on braces
36
+ - **Text Wrapping**: Format text with `gq`, `gw`
37
+ - **Alignment**: Column alignment support
38
+ - **Comment Toggling**: Smart comment handling
39
+ - **Digraphs**: 150+ special characters
40
40
 
41
41
  ## Installation
42
42
 
@@ -478,14 +478,14 @@ const session = new Session();
478
478
 
479
479
  | Feature | vim-sim | CodeMirror Vim | Monaco Vim |
480
480
  |---------|---------|----------------|------------|
481
- | Standalone || ❌ (requires CodeMirror) | ❌ (requires Monaco) |
482
- | Node.js API || ❌ | ❌ |
483
- | Undo Tree || ❌ | ❌ |
484
- | Full Text Objects || Partial | Partial |
485
- | Macros ||| ❌ |
486
- | Marks & Jumps || Partial | Partial |
487
- | Spell Checking || ❌ | ❌ |
488
- | TypeScript || Partial ||
481
+ | Standalone | | ❌ (requires CodeMirror) | ❌ (requires Monaco) |
482
+ | Node.js API | | ❌ | ❌ |
483
+ | Undo Tree | | ❌ | ❌ |
484
+ | Full Text Objects | | Partial | Partial |
485
+ | Macros | | | ❌ |
486
+ | Marks & Jumps | | Partial | Partial |
487
+ | Spell Checking | | ❌ | ❌ |
488
+ | TypeScript | | Partial | |
489
489
 
490
490
  ## Contributing
491
491
 
package/dist/index.d.ts CHANGED
@@ -785,6 +785,112 @@ declare class UndoTree {
785
785
  };
786
786
  }
787
787
 
788
+ /**
789
+ * Vim configuration options
790
+ */
791
+ interface VimConfig {
792
+ number: boolean;
793
+ relativenumber: boolean;
794
+ wrap: boolean;
795
+ cursorline: boolean;
796
+ tabstop: number;
797
+ shiftwidth: number;
798
+ expandtab: boolean;
799
+ autoindent: boolean;
800
+ smartindent: boolean;
801
+ ignorecase: boolean;
802
+ smartcase: boolean;
803
+ hlsearch: boolean;
804
+ incsearch: boolean;
805
+ wrapscan: boolean;
806
+ whichwrap: string;
807
+ startofline: boolean;
808
+ virtualedit: string;
809
+ undolevels: number;
810
+ clipboard: 'unnamed' | 'unnamedplus' | '';
811
+ }
812
+ type VimConfigKey = keyof VimConfig;
813
+ /**
814
+ * Metadata about a config option
815
+ */
816
+ interface VimConfigMetadata {
817
+ description: string;
818
+ vimDefault: string | number | boolean;
819
+ vimSimDefault: string | number | boolean;
820
+ category: 'display' | 'indentation' | 'search' | 'motion' | 'editing';
821
+ type: 'boolean' | 'number' | 'string';
822
+ differsFromVim: boolean;
823
+ validValues?: string[];
824
+ }
825
+ /**
826
+ * Manages Vim configuration options
827
+ */
828
+ declare class ConfigManager {
829
+ private config;
830
+ private listeners;
831
+ constructor(initialConfig?: Partial<VimConfig>);
832
+ /**
833
+ * Get a config value
834
+ */
835
+ get<K extends VimConfigKey>(key: K): VimConfig[K];
836
+ /**
837
+ * Set a config value
838
+ */
839
+ set<K extends VimConfigKey>(key: K, value: VimConfig[K]): void;
840
+ /**
841
+ * Set multiple config values at once
842
+ */
843
+ setMultiple(updates: Partial<VimConfig>): void;
844
+ /**
845
+ * Get all config values
846
+ */
847
+ getAll(): Readonly<VimConfig>;
848
+ /**
849
+ * Reset to default configuration
850
+ */
851
+ reset(): void;
852
+ /**
853
+ * Toggle a boolean config option
854
+ */
855
+ toggle(key: VimConfigKey): void;
856
+ /**
857
+ * Subscribe to config changes
858
+ * @param key - Config key to watch, or '*' for all changes
859
+ * @param callback - Function to call when config changes
860
+ * @returns Unsubscribe function
861
+ */
862
+ onChange(key: VimConfigKey | '*', callback: (key: VimConfigKey, value: unknown) => void): () => void;
863
+ /**
864
+ * Notify all listeners of a config change
865
+ */
866
+ private notifyListeners;
867
+ /**
868
+ * Parse a Vim set command string (e.g., "number", "nonumber", "tabstop=4")
869
+ */
870
+ parseSetCommand(command: string): boolean;
871
+ /**
872
+ * Get a formatted string representation of a config value
873
+ */
874
+ formatValue(key: VimConfigKey): string;
875
+ /**
876
+ * Get metadata about a config option
877
+ */
878
+ getMetadata(key: VimConfigKey): VimConfigMetadata;
879
+ /**
880
+ * Get all options that differ from vanilla Vim
881
+ */
882
+ getDifferencesFromVim(): VimConfigKey[];
883
+ /**
884
+ * Get options by category
885
+ */
886
+ getByCategory(category: VimConfigMetadata['category']): VimConfigKey[];
887
+ }
888
+ /**
889
+ * Metadata for all config options
890
+ * Documents behavior, defaults, and differences from vanilla Vim
891
+ */
892
+ declare const CONFIG_METADATA: Record<VimConfigKey, VimConfigMetadata>;
893
+
788
894
  interface LastVisualSelection {
789
895
  range: Range;
790
896
  mode: Mode.VISUAL | Mode.VISUAL_LINE | Mode.VISUAL_BLOCK;
@@ -820,7 +926,8 @@ declare class State {
820
926
  completionManager: CompletionManager;
821
927
  undoTree: UndoTree | null;
822
928
  lastCommand: LastCommand | null;
823
- constructor(buffer: Buffer, cursor: Cursor, selection: Range | null, mode: Mode, commandLine?: string, desiredColumn?: number | null, viewport?: VimViewport, visualAnchor?: Cursor | null, lastVisualSelection?: LastVisualSelection | null, recordingRegister?: string | null, lastMacroRegister?: string | null, foldManager?: FoldManager, markManager?: MarkManager, jumpListManager?: JumpListManager, fileSystem?: FileSystemManager, windowManager?: WindowManager, lastSearch?: SearchState | null, spellChecker?: SpellChecker, completionManager?: CompletionManager, undoTree?: UndoTree | null, lastCommand?: LastCommand | null);
929
+ configManager: ConfigManager | null;
930
+ constructor(buffer: Buffer, cursor: Cursor, selection: Range | null, mode: Mode, commandLine?: string, desiredColumn?: number | null, viewport?: VimViewport, visualAnchor?: Cursor | null, lastVisualSelection?: LastVisualSelection | null, recordingRegister?: string | null, lastMacroRegister?: string | null, foldManager?: FoldManager, markManager?: MarkManager, jumpListManager?: JumpListManager, fileSystem?: FileSystemManager, windowManager?: WindowManager, lastSearch?: SearchState | null, spellChecker?: SpellChecker, completionManager?: CompletionManager, undoTree?: UndoTree | null, lastCommand?: LastCommand | null, configManager?: ConfigManager | null);
824
931
  }
825
932
 
826
933
  declare abstract class TextObject {
@@ -957,79 +1064,6 @@ declare class UndoStack {
957
1064
  getCurrentIndex(): number;
958
1065
  }
959
1066
 
960
- /**
961
- * Vim configuration options
962
- */
963
- interface VimConfig {
964
- number: boolean;
965
- relativenumber: boolean;
966
- wrap: boolean;
967
- cursorline: boolean;
968
- tabstop: number;
969
- shiftwidth: number;
970
- expandtab: boolean;
971
- autoindent: boolean;
972
- smartindent: boolean;
973
- ignorecase: boolean;
974
- smartcase: boolean;
975
- hlsearch: boolean;
976
- incsearch: boolean;
977
- undolevels: number;
978
- clipboard: 'unnamed' | 'unnamedplus' | '';
979
- }
980
- type VimConfigKey = keyof VimConfig;
981
- /**
982
- * Manages Vim configuration options
983
- */
984
- declare class ConfigManager {
985
- private config;
986
- private listeners;
987
- constructor(initialConfig?: Partial<VimConfig>);
988
- /**
989
- * Get a config value
990
- */
991
- get<K extends VimConfigKey>(key: K): VimConfig[K];
992
- /**
993
- * Set a config value
994
- */
995
- set<K extends VimConfigKey>(key: K, value: VimConfig[K]): void;
996
- /**
997
- * Set multiple config values at once
998
- */
999
- setMultiple(updates: Partial<VimConfig>): void;
1000
- /**
1001
- * Get all config values
1002
- */
1003
- getAll(): Readonly<VimConfig>;
1004
- /**
1005
- * Reset to default configuration
1006
- */
1007
- reset(): void;
1008
- /**
1009
- * Toggle a boolean config option
1010
- */
1011
- toggle(key: VimConfigKey): void;
1012
- /**
1013
- * Subscribe to config changes
1014
- * @param key - Config key to watch, or '*' for all changes
1015
- * @param callback - Function to call when config changes
1016
- * @returns Unsubscribe function
1017
- */
1018
- onChange(key: VimConfigKey | '*', callback: (key: VimConfigKey, value: unknown) => void): () => void;
1019
- /**
1020
- * Notify all listeners of a config change
1021
- */
1022
- private notifyListeners;
1023
- /**
1024
- * Parse a Vim set command string (e.g., "number", "nonumber", "tabstop=4")
1025
- */
1026
- parseSetCommand(command: string): boolean;
1027
- /**
1028
- * Get a formatted string representation of a config value
1029
- */
1030
- formatValue(key: VimConfigKey): string;
1031
- }
1032
-
1033
1067
  interface CommandHistoryEntry {
1034
1068
  keys: string;
1035
1069
  timestamp: number;
@@ -1377,4 +1411,4 @@ declare function withContentAndCursor(state: State, content: string, cursor: Cur
1377
1411
  */
1378
1412
  declare function deleteRangeWithRegister(state: State, range: Range, context: CommandContext, isLinewise?: boolean): State;
1379
1413
 
1380
- export { Buffer, Change, type CharClassifier, Command, type CommandContext, type CommandHistoryEntry, ConfigManager, Cursor, type IndentConfig, IndentationManager, Mode, ModeTransition, Motion, Operator, PatternRegistry, type Range, Register, RegisterManager, Session, State, TextObject, UndoStack, type VimConfig, type VimConfigKey, VimViewport, clampCursor, clampCursorNormalMode, clampCursorVerticalMotion, currentLine, deleteLine, deleteLines, deleteRange, deleteRangeWithRegister, expandRangeOuter, findFirstNonBlank, findLineEnd, findLineStart, findNext, findNextWORDEnd, findNextWORDStart, findNextWordEnd, findNextWordStart, findPrev, findPrevWORDEnd, findPrevWORDStart, findPrevWordEnd, findPrevWordStart, getCharAt, getCharAtOffset, getCount, getLine, getLines, getTextInRange, isAtBufferEnd, isAtBufferStart, isAtLineEnd, isAtLineStart, isInRange, isNewline, isOnChar, isOnPunctuation, isOnWhitespace, isOnWord, isPunctuation, isWhitespace, isWordChar, lastLine, lineCount, moveCursorBy, moveDown, moveLeft, moveRight, moveUp, normalizeRange, repeatCursorMotion, replaceRange, resolveOperatorRange, skipUntil, skipWhile, skipWhitespace, updateVisualSelection, withBufferContent, withContentAndCursor, withCursor, withCursorAndViewport, withCursorHorizontal, withCursorVertical, withViewport };
1414
+ export { Buffer, CONFIG_METADATA, Change, type CharClassifier, Command, type CommandContext, type CommandHistoryEntry, ConfigManager, Cursor, type IndentConfig, IndentationManager, Mode, ModeTransition, Motion, Operator, PatternRegistry, type Range, Register, RegisterManager, Session, State, TextObject, UndoStack, type VimConfig, type VimConfigKey, type VimConfigMetadata, VimViewport, clampCursor, clampCursorNormalMode, clampCursorVerticalMotion, currentLine, deleteLine, deleteLines, deleteRange, deleteRangeWithRegister, expandRangeOuter, findFirstNonBlank, findLineEnd, findLineStart, findNext, findNextWORDEnd, findNextWORDStart, findNextWordEnd, findNextWordStart, findPrev, findPrevWORDEnd, findPrevWORDStart, findPrevWordEnd, findPrevWordStart, getCharAt, getCharAtOffset, getCount, getLine, getLines, getTextInRange, isAtBufferEnd, isAtBufferStart, isAtLineEnd, isAtLineStart, isInRange, isNewline, isOnChar, isOnPunctuation, isOnWhitespace, isOnWord, isPunctuation, isWhitespace, isWordChar, lastLine, lineCount, moveCursorBy, moveDown, moveLeft, moveRight, moveUp, normalizeRange, repeatCursorMotion, replaceRange, resolveOperatorRange, skipUntil, skipWhile, skipWhitespace, updateVisualSelection, withBufferContent, withContentAndCursor, withCursor, withCursorAndViewport, withCursorHorizontal, withCursorVertical, withViewport };