vim-sim 1.0.2 → 1.0.4

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
@@ -634,6 +634,7 @@ declare class CompletionManager {
634
634
  lineCompletion(buffer: string, cursorLine: number, cursorCol: number): CompletionMatch[];
635
635
  /**
636
636
  * Start filename completion
637
+ * Note: This is a stub in browser environments. File system access requires Node.js.
637
638
  */
638
639
  fileNameCompletion(buffer: string, cursorLine: number, cursorCol: number, currentDir?: string): Promise<CompletionMatch[]>;
639
640
  /**
@@ -655,6 +656,7 @@ declare class CompletionManager {
655
656
  private extractKeywords;
656
657
  /**
657
658
  * Get file type information
659
+ * Note: Stub implementation for browser compatibility
658
660
  */
659
661
  private getFileTypeInfo;
660
662
  /**
@@ -785,6 +787,112 @@ declare class UndoTree {
785
787
  };
786
788
  }
787
789
 
790
+ /**
791
+ * Vim configuration options
792
+ */
793
+ interface VimConfig {
794
+ number: boolean;
795
+ relativenumber: boolean;
796
+ wrap: boolean;
797
+ cursorline: boolean;
798
+ tabstop: number;
799
+ shiftwidth: number;
800
+ expandtab: boolean;
801
+ autoindent: boolean;
802
+ smartindent: boolean;
803
+ ignorecase: boolean;
804
+ smartcase: boolean;
805
+ hlsearch: boolean;
806
+ incsearch: boolean;
807
+ wrapscan: boolean;
808
+ whichwrap: string;
809
+ startofline: boolean;
810
+ virtualedit: string;
811
+ undolevels: number;
812
+ clipboard: 'unnamed' | 'unnamedplus' | '';
813
+ }
814
+ type VimConfigKey = keyof VimConfig;
815
+ /**
816
+ * Metadata about a config option
817
+ */
818
+ interface VimConfigMetadata {
819
+ description: string;
820
+ vimDefault: string | number | boolean;
821
+ vimSimDefault: string | number | boolean;
822
+ category: 'display' | 'indentation' | 'search' | 'motion' | 'editing';
823
+ type: 'boolean' | 'number' | 'string';
824
+ differsFromVim: boolean;
825
+ validValues?: string[];
826
+ }
827
+ /**
828
+ * Manages Vim configuration options
829
+ */
830
+ declare class ConfigManager {
831
+ private config;
832
+ private listeners;
833
+ constructor(initialConfig?: Partial<VimConfig>);
834
+ /**
835
+ * Get a config value
836
+ */
837
+ get<K extends VimConfigKey>(key: K): VimConfig[K];
838
+ /**
839
+ * Set a config value
840
+ */
841
+ set<K extends VimConfigKey>(key: K, value: VimConfig[K]): void;
842
+ /**
843
+ * Set multiple config values at once
844
+ */
845
+ setMultiple(updates: Partial<VimConfig>): void;
846
+ /**
847
+ * Get all config values
848
+ */
849
+ getAll(): Readonly<VimConfig>;
850
+ /**
851
+ * Reset to default configuration
852
+ */
853
+ reset(): void;
854
+ /**
855
+ * Toggle a boolean config option
856
+ */
857
+ toggle(key: VimConfigKey): void;
858
+ /**
859
+ * Subscribe to config changes
860
+ * @param key - Config key to watch, or '*' for all changes
861
+ * @param callback - Function to call when config changes
862
+ * @returns Unsubscribe function
863
+ */
864
+ onChange(key: VimConfigKey | '*', callback: (key: VimConfigKey, value: unknown) => void): () => void;
865
+ /**
866
+ * Notify all listeners of a config change
867
+ */
868
+ private notifyListeners;
869
+ /**
870
+ * Parse a Vim set command string (e.g., "number", "nonumber", "tabstop=4")
871
+ */
872
+ parseSetCommand(command: string): boolean;
873
+ /**
874
+ * Get a formatted string representation of a config value
875
+ */
876
+ formatValue(key: VimConfigKey): string;
877
+ /**
878
+ * Get metadata about a config option
879
+ */
880
+ getMetadata(key: VimConfigKey): VimConfigMetadata;
881
+ /**
882
+ * Get all options that differ from vanilla Vim
883
+ */
884
+ getDifferencesFromVim(): VimConfigKey[];
885
+ /**
886
+ * Get options by category
887
+ */
888
+ getByCategory(category: VimConfigMetadata['category']): VimConfigKey[];
889
+ }
890
+ /**
891
+ * Metadata for all config options
892
+ * Documents behavior, defaults, and differences from vanilla Vim
893
+ */
894
+ declare const CONFIG_METADATA: Record<VimConfigKey, VimConfigMetadata>;
895
+
788
896
  interface LastVisualSelection {
789
897
  range: Range;
790
898
  mode: Mode.VISUAL | Mode.VISUAL_LINE | Mode.VISUAL_BLOCK;
@@ -820,7 +928,8 @@ declare class State {
820
928
  completionManager: CompletionManager;
821
929
  undoTree: UndoTree | null;
822
930
  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);
931
+ configManager: ConfigManager | null;
932
+ 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
933
  }
825
934
 
826
935
  declare abstract class TextObject {
@@ -957,79 +1066,6 @@ declare class UndoStack {
957
1066
  getCurrentIndex(): number;
958
1067
  }
959
1068
 
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
1069
  interface CommandHistoryEntry {
1034
1070
  keys: string;
1035
1071
  timestamp: number;
@@ -1377,4 +1413,4 @@ declare function withContentAndCursor(state: State, content: string, cursor: Cur
1377
1413
  */
1378
1414
  declare function deleteRangeWithRegister(state: State, range: Range, context: CommandContext, isLinewise?: boolean): State;
1379
1415
 
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 };
1416
+ 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 };