vim-sim 1.0.2
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/LICENSE +21 -0
- package/README.md +507 -0
- package/dist/index.d.ts +1380 -0
- package/dist/index.js +6928 -0
- package/dist/index.js.map +1 -0
- package/docs/ADVANCED-FEATURES-COMPLETE.md +547 -0
- package/docs/ADVANCED-FEATURES.md +460 -0
- package/docs/DEPLOYMENT-READY.md +194 -0
- package/docs/FINAL-SUMMARY.md +318 -0
- package/docs/IMPLEMENTATION-SUMMARY.md +298 -0
- package/docs/PARAGRAPH-MOTIONS-FIX.md +238 -0
- package/docs/QUICK-FIXES-SUMMARY.md +184 -0
- package/docs/QUICK-START-ADVANCED.md +260 -0
- package/docs/TEST-ANALYSIS-SUMMARY.md +213 -0
- package/docs/TEST-FAILURES-ANALYSIS.md +373 -0
- package/docs/TODO-COMPLETION-SUMMARY.md +326 -0
- package/package.json +79 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1380 @@
|
|
|
1
|
+
declare enum Mode {
|
|
2
|
+
NORMAL = 0,
|
|
3
|
+
INSERT = 1,
|
|
4
|
+
VISUAL = 2,
|
|
5
|
+
VISUAL_LINE = 3,
|
|
6
|
+
VISUAL_BLOCK = 4,
|
|
7
|
+
REPLACE = 5,
|
|
8
|
+
COMMAND = 6
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare class Buffer {
|
|
12
|
+
content: string;
|
|
13
|
+
constructor(content: string);
|
|
14
|
+
getLineCount(): number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare class Cursor {
|
|
18
|
+
line: number;
|
|
19
|
+
column: number;
|
|
20
|
+
constructor(line: number, column: number);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface Range {
|
|
24
|
+
start: Cursor;
|
|
25
|
+
end: Cursor;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare class VimViewport {
|
|
29
|
+
topLine: number;
|
|
30
|
+
height: number;
|
|
31
|
+
constructor(topLine?: number, height?: number);
|
|
32
|
+
scrollToLine(line: number): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Fold type definitions
|
|
37
|
+
*/
|
|
38
|
+
interface Fold {
|
|
39
|
+
/** Starting line of the fold (inclusive, 0-indexed) */
|
|
40
|
+
startLine: number;
|
|
41
|
+
/** Ending line of the fold (inclusive, 0-indexed) */
|
|
42
|
+
endLine: number;
|
|
43
|
+
/** Whether the fold is currently closed */
|
|
44
|
+
isClosed: boolean;
|
|
45
|
+
/** Nesting level (0 = top level) */
|
|
46
|
+
level: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Manager for tracking and manipulating folds in a buffer
|
|
50
|
+
*/
|
|
51
|
+
declare class FoldManager {
|
|
52
|
+
/** Array of folds, sorted by startLine */
|
|
53
|
+
private folds;
|
|
54
|
+
constructor(folds?: Fold[]);
|
|
55
|
+
/**
|
|
56
|
+
* Get all folds
|
|
57
|
+
*/
|
|
58
|
+
getFolds(): Fold[];
|
|
59
|
+
/**
|
|
60
|
+
* Create a new fold
|
|
61
|
+
*/
|
|
62
|
+
createFold(startLine: number, endLine: number): FoldManager;
|
|
63
|
+
/**
|
|
64
|
+
* Find fold at a specific line
|
|
65
|
+
*/
|
|
66
|
+
findFoldAtLine(line: number): Fold | null;
|
|
67
|
+
/**
|
|
68
|
+
* Open fold at line
|
|
69
|
+
*/
|
|
70
|
+
openFold(line: number): FoldManager;
|
|
71
|
+
/**
|
|
72
|
+
* Open fold and all nested folds recursively
|
|
73
|
+
*/
|
|
74
|
+
openFoldRecursive(line: number): FoldManager;
|
|
75
|
+
/**
|
|
76
|
+
* Close fold at line
|
|
77
|
+
*/
|
|
78
|
+
closeFold(line: number): FoldManager;
|
|
79
|
+
/**
|
|
80
|
+
* Close fold and all nested folds recursively
|
|
81
|
+
*/
|
|
82
|
+
closeFoldRecursive(line: number): FoldManager;
|
|
83
|
+
/**
|
|
84
|
+
* Toggle fold at line
|
|
85
|
+
*/
|
|
86
|
+
toggleFold(line: number): FoldManager;
|
|
87
|
+
/**
|
|
88
|
+
* Toggle fold and nested folds recursively
|
|
89
|
+
*/
|
|
90
|
+
toggleFoldRecursive(line: number): FoldManager;
|
|
91
|
+
/**
|
|
92
|
+
* Delete fold at line
|
|
93
|
+
*/
|
|
94
|
+
deleteFold(line: number): FoldManager;
|
|
95
|
+
/**
|
|
96
|
+
* Delete fold and all nested folds recursively
|
|
97
|
+
*/
|
|
98
|
+
deleteFoldRecursive(line: number): FoldManager;
|
|
99
|
+
/**
|
|
100
|
+
* Open all folds
|
|
101
|
+
*/
|
|
102
|
+
openAllFolds(): FoldManager;
|
|
103
|
+
/**
|
|
104
|
+
* Close all folds
|
|
105
|
+
*/
|
|
106
|
+
closeAllFolds(): FoldManager;
|
|
107
|
+
/**
|
|
108
|
+
* Open folds up to a certain level
|
|
109
|
+
*/
|
|
110
|
+
openFoldsToLevel(maxLevel: number): FoldManager;
|
|
111
|
+
/**
|
|
112
|
+
* Close folds from a certain level
|
|
113
|
+
*/
|
|
114
|
+
closeFoldsFromLevel(minLevel: number): FoldManager;
|
|
115
|
+
/**
|
|
116
|
+
* Open folds to view a specific line
|
|
117
|
+
*/
|
|
118
|
+
openToViewLine(line: number): FoldManager;
|
|
119
|
+
/**
|
|
120
|
+
* Find next fold starting after a given line
|
|
121
|
+
*/
|
|
122
|
+
findNextFold(line: number): Fold | null;
|
|
123
|
+
/**
|
|
124
|
+
* Find previous fold starting before a given line
|
|
125
|
+
*/
|
|
126
|
+
findPrevFold(line: number): Fold | null;
|
|
127
|
+
/**
|
|
128
|
+
* Check if a line is hidden (inside a closed fold)
|
|
129
|
+
*/
|
|
130
|
+
isLineHidden(line: number): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Get visible lines (accounting for closed folds)
|
|
133
|
+
* Returns array of line numbers that should be visible
|
|
134
|
+
*/
|
|
135
|
+
getVisibleLines(totalLines: number): number[];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Mark type definitions
|
|
140
|
+
*/
|
|
141
|
+
interface Mark {
|
|
142
|
+
/** The cursor position of the mark */
|
|
143
|
+
position: Cursor;
|
|
144
|
+
/** Optional buffer identifier (for global marks) */
|
|
145
|
+
bufferId?: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Manager for tracking and manipulating marks in a buffer
|
|
149
|
+
*/
|
|
150
|
+
declare class MarkManager {
|
|
151
|
+
/** Map of mark names to their positions */
|
|
152
|
+
private marks;
|
|
153
|
+
constructor(marks?: Map<string, Mark>);
|
|
154
|
+
/**
|
|
155
|
+
* Set a mark at a position
|
|
156
|
+
* @param name - Mark name (a-z for local, A-Z for global)
|
|
157
|
+
* @param position - Cursor position
|
|
158
|
+
* @param bufferId - Optional buffer ID for global marks
|
|
159
|
+
*/
|
|
160
|
+
setMark(name: string, position: Cursor, bufferId?: string): MarkManager;
|
|
161
|
+
/**
|
|
162
|
+
* Get a mark by name
|
|
163
|
+
*/
|
|
164
|
+
getMark(name: string): Mark | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* Check if a mark exists
|
|
167
|
+
*/
|
|
168
|
+
hasMark(name: string): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Delete a mark
|
|
171
|
+
*/
|
|
172
|
+
deleteMark(name: string): MarkManager;
|
|
173
|
+
/**
|
|
174
|
+
* Delete all marks
|
|
175
|
+
*/
|
|
176
|
+
deleteAllMarks(): MarkManager;
|
|
177
|
+
/**
|
|
178
|
+
* Delete all marks in a range
|
|
179
|
+
*/
|
|
180
|
+
deleteMarksInRange(startLine: number, endLine: number): MarkManager;
|
|
181
|
+
/**
|
|
182
|
+
* Get all marks
|
|
183
|
+
*/
|
|
184
|
+
getAllMarks(): Map<string, Mark>;
|
|
185
|
+
/**
|
|
186
|
+
* Get local marks (a-z)
|
|
187
|
+
*/
|
|
188
|
+
getLocalMarks(): Map<string, Mark>;
|
|
189
|
+
/**
|
|
190
|
+
* Get global marks (A-Z)
|
|
191
|
+
*/
|
|
192
|
+
getGlobalMarks(): Map<string, Mark>;
|
|
193
|
+
/**
|
|
194
|
+
* Check if a mark name is valid
|
|
195
|
+
*/
|
|
196
|
+
private isValidMarkName;
|
|
197
|
+
/**
|
|
198
|
+
* Check if a mark is a local mark (a-z)
|
|
199
|
+
*/
|
|
200
|
+
private isLocalMark;
|
|
201
|
+
/**
|
|
202
|
+
* Check if a mark is a global mark (A-Z)
|
|
203
|
+
*/
|
|
204
|
+
private isGlobalMark;
|
|
205
|
+
/**
|
|
206
|
+
* Update mark positions when lines are inserted
|
|
207
|
+
* Shifts marks after the insertion point
|
|
208
|
+
*/
|
|
209
|
+
adjustMarksAfterInsert(insertLine: number, numLines: number): MarkManager;
|
|
210
|
+
/**
|
|
211
|
+
* Update mark positions when lines are deleted
|
|
212
|
+
* Removes marks in deleted range and shifts marks after deletion
|
|
213
|
+
*/
|
|
214
|
+
adjustMarksAfterDelete(startLine: number, endLine: number): MarkManager;
|
|
215
|
+
/**
|
|
216
|
+
* Set automatic marks
|
|
217
|
+
* These are special marks that vim sets automatically
|
|
218
|
+
*/
|
|
219
|
+
setAutomaticMark(name: string, position: Cursor): MarkManager;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Jump list type definitions
|
|
224
|
+
*/
|
|
225
|
+
interface Jump {
|
|
226
|
+
/** The cursor position of the jump */
|
|
227
|
+
position: Cursor;
|
|
228
|
+
/** Optional buffer identifier */
|
|
229
|
+
bufferId?: string;
|
|
230
|
+
/** Timestamp when jump was created */
|
|
231
|
+
timestamp: number;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Manager for tracking and navigating the jump list
|
|
235
|
+
*
|
|
236
|
+
* The jump list is automatically maintained by Vim to track "jumps" -
|
|
237
|
+
* movements that cross multiple lines (like G, gg, %, searches, marks)
|
|
238
|
+
*/
|
|
239
|
+
declare class JumpListManager {
|
|
240
|
+
/** Array of jumps in chronological order */
|
|
241
|
+
private jumps;
|
|
242
|
+
/** Current position in the jump list (null if at most recent position) */
|
|
243
|
+
private currentIndex;
|
|
244
|
+
/** Maximum number of jumps to keep */
|
|
245
|
+
private readonly maxJumps;
|
|
246
|
+
constructor(jumps?: Jump[], currentIndex?: number | null);
|
|
247
|
+
/**
|
|
248
|
+
* Add a jump to the list
|
|
249
|
+
* This removes any "future" jumps if we're in the middle of the list
|
|
250
|
+
*/
|
|
251
|
+
addJump(position: Cursor, bufferId?: string): JumpListManager;
|
|
252
|
+
/**
|
|
253
|
+
* Jump backward in the list (Ctrl-o)
|
|
254
|
+
* Returns the jump position to go to, or null if can't go back
|
|
255
|
+
*/
|
|
256
|
+
jumpBackward(): {
|
|
257
|
+
manager: JumpListManager;
|
|
258
|
+
position: Cursor | null;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Jump forward in the list (Ctrl-i)
|
|
262
|
+
* Returns the jump position to go to, or null if can't go forward
|
|
263
|
+
*/
|
|
264
|
+
jumpForward(): {
|
|
265
|
+
manager: JumpListManager;
|
|
266
|
+
position: Cursor | null;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Get the current jump position (if in the middle of the list)
|
|
270
|
+
*/
|
|
271
|
+
getCurrentJump(): Jump | null;
|
|
272
|
+
/**
|
|
273
|
+
* Get all jumps
|
|
274
|
+
*/
|
|
275
|
+
getAllJumps(): Jump[];
|
|
276
|
+
/**
|
|
277
|
+
* Get current index in jump list
|
|
278
|
+
*/
|
|
279
|
+
getCurrentIndex(): number | null;
|
|
280
|
+
/**
|
|
281
|
+
* Check if we can jump backward
|
|
282
|
+
*/
|
|
283
|
+
canJumpBackward(): boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Check if we can jump forward
|
|
286
|
+
*/
|
|
287
|
+
canJumpForward(): boolean;
|
|
288
|
+
/**
|
|
289
|
+
* Update jump positions when lines are inserted
|
|
290
|
+
*/
|
|
291
|
+
adjustJumpsAfterInsert(insertLine: number, numLines: number): JumpListManager;
|
|
292
|
+
/**
|
|
293
|
+
* Update jump positions when lines are deleted
|
|
294
|
+
*/
|
|
295
|
+
adjustJumpsAfterDelete(startLine: number, endLine: number): JumpListManager;
|
|
296
|
+
/**
|
|
297
|
+
* Clear the jump list
|
|
298
|
+
*/
|
|
299
|
+
clear(): JumpListManager;
|
|
300
|
+
/**
|
|
301
|
+
* Check if a cursor movement should be considered a "jump"
|
|
302
|
+
* (movements that cross multiple lines)
|
|
303
|
+
*/
|
|
304
|
+
static isJumpMotion(fromLine: number, toLine: number, minLineDiff?: number): boolean;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Represents a file in the simulated file system
|
|
309
|
+
*/
|
|
310
|
+
interface VimFile {
|
|
311
|
+
path: string;
|
|
312
|
+
buffer: Buffer;
|
|
313
|
+
modified: boolean;
|
|
314
|
+
readonly: boolean;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Manages the simulated file system with multiple buffers
|
|
318
|
+
* Immutable operations return new FileSystemManager instances
|
|
319
|
+
*/
|
|
320
|
+
declare class FileSystemManager {
|
|
321
|
+
private files;
|
|
322
|
+
private currentFilePath;
|
|
323
|
+
constructor(files?: Map<string, VimFile>, currentFilePath?: string | null);
|
|
324
|
+
/**
|
|
325
|
+
* Create or open a file with the given path
|
|
326
|
+
*/
|
|
327
|
+
openFile(path: string, content?: string, readonly?: boolean): FileSystemManager;
|
|
328
|
+
/**
|
|
329
|
+
* Update the buffer content for the current file
|
|
330
|
+
*/
|
|
331
|
+
updateCurrentBuffer(buffer: Buffer, modified?: boolean): FileSystemManager;
|
|
332
|
+
/**
|
|
333
|
+
* Save the current file (mark as not modified)
|
|
334
|
+
*/
|
|
335
|
+
saveCurrentFile(): FileSystemManager;
|
|
336
|
+
/**
|
|
337
|
+
* Close the current file
|
|
338
|
+
*/
|
|
339
|
+
closeCurrentFile(): {
|
|
340
|
+
manager: FileSystemManager;
|
|
341
|
+
success: boolean;
|
|
342
|
+
message?: string;
|
|
343
|
+
};
|
|
344
|
+
/**
|
|
345
|
+
* Force close the current file (ignore modifications)
|
|
346
|
+
*/
|
|
347
|
+
forceCloseCurrentFile(): {
|
|
348
|
+
manager: FileSystemManager;
|
|
349
|
+
success: boolean;
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
* Switch to a specific file by path
|
|
353
|
+
*/
|
|
354
|
+
switchToFile(path: string): FileSystemManager;
|
|
355
|
+
/**
|
|
356
|
+
* Get the current file
|
|
357
|
+
*/
|
|
358
|
+
getCurrentFile(): VimFile | null;
|
|
359
|
+
/**
|
|
360
|
+
* Get current file path
|
|
361
|
+
*/
|
|
362
|
+
getCurrentPath(): string | null;
|
|
363
|
+
/**
|
|
364
|
+
* Get all file paths
|
|
365
|
+
*/
|
|
366
|
+
getAllPaths(): string[];
|
|
367
|
+
/**
|
|
368
|
+
* Get number of open files
|
|
369
|
+
*/
|
|
370
|
+
getFileCount(): number;
|
|
371
|
+
/**
|
|
372
|
+
* Check if current file is modified
|
|
373
|
+
*/
|
|
374
|
+
isCurrentModified(): boolean;
|
|
375
|
+
/**
|
|
376
|
+
* Check if current file is readonly
|
|
377
|
+
*/
|
|
378
|
+
isCurrentReadonly(): boolean;
|
|
379
|
+
/**
|
|
380
|
+
* Get next file in the list (for buffer cycling)
|
|
381
|
+
*/
|
|
382
|
+
getNextFilePath(): string | null;
|
|
383
|
+
/**
|
|
384
|
+
* Get previous file in the list (for buffer cycling)
|
|
385
|
+
*/
|
|
386
|
+
getPreviousFilePath(): string | null;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Represents the type of window split
|
|
391
|
+
*/
|
|
392
|
+
declare enum SplitType {
|
|
393
|
+
HORIZONTAL = 0,
|
|
394
|
+
VERTICAL = 1
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Represents a window in the editor
|
|
398
|
+
*/
|
|
399
|
+
interface Window {
|
|
400
|
+
id: number;
|
|
401
|
+
bufferId: string | null;
|
|
402
|
+
cursorLine: number;
|
|
403
|
+
cursorColumn: number;
|
|
404
|
+
scrollOffset: number;
|
|
405
|
+
width: number;
|
|
406
|
+
height: number;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Layout node for window tree structure
|
|
410
|
+
*/
|
|
411
|
+
interface WindowLayout {
|
|
412
|
+
type: 'leaf' | 'split';
|
|
413
|
+
splitType?: SplitType;
|
|
414
|
+
window?: Window;
|
|
415
|
+
children?: [WindowLayout, WindowLayout];
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Manages window splits and navigation
|
|
419
|
+
* Immutable operations return new WindowManager instances
|
|
420
|
+
*/
|
|
421
|
+
declare class WindowManager {
|
|
422
|
+
private windows;
|
|
423
|
+
private layout;
|
|
424
|
+
private activeWindowId;
|
|
425
|
+
private nextWindowId;
|
|
426
|
+
constructor(windows?: Map<number, Window>, layout?: WindowLayout | null, activeWindowId?: number, nextWindowId?: number);
|
|
427
|
+
/**
|
|
428
|
+
* Split the active window horizontally (above/below)
|
|
429
|
+
*/
|
|
430
|
+
splitHorizontal(): WindowManager;
|
|
431
|
+
/**
|
|
432
|
+
* Split the active window vertically (left/right)
|
|
433
|
+
*/
|
|
434
|
+
splitVertical(): WindowManager;
|
|
435
|
+
/**
|
|
436
|
+
* Close the active window
|
|
437
|
+
*/
|
|
438
|
+
closeActiveWindow(): {
|
|
439
|
+
manager: WindowManager;
|
|
440
|
+
success: boolean;
|
|
441
|
+
message?: string;
|
|
442
|
+
};
|
|
443
|
+
/**
|
|
444
|
+
* Close all windows except the active one
|
|
445
|
+
*/
|
|
446
|
+
closeOtherWindows(): WindowManager;
|
|
447
|
+
/**
|
|
448
|
+
* Navigate to the next window
|
|
449
|
+
*/
|
|
450
|
+
cycleWindow(): WindowManager;
|
|
451
|
+
/**
|
|
452
|
+
* Navigate to window in a direction (h/j/k/l)
|
|
453
|
+
*/
|
|
454
|
+
navigateWindow(direction: 'h' | 'j' | 'k' | 'l'): WindowManager;
|
|
455
|
+
/**
|
|
456
|
+
* Update the active window
|
|
457
|
+
*/
|
|
458
|
+
updateActiveWindow(updates: Partial<Window>): WindowManager;
|
|
459
|
+
/**
|
|
460
|
+
* Get the active window
|
|
461
|
+
*/
|
|
462
|
+
getActiveWindow(): Window | null;
|
|
463
|
+
/**
|
|
464
|
+
* Get all windows
|
|
465
|
+
*/
|
|
466
|
+
getAllWindows(): Window[];
|
|
467
|
+
/**
|
|
468
|
+
* Get window count
|
|
469
|
+
*/
|
|
470
|
+
getWindowCount(): number;
|
|
471
|
+
/**
|
|
472
|
+
* Get layout tree
|
|
473
|
+
*/
|
|
474
|
+
getLayout(): WindowLayout;
|
|
475
|
+
private replaceWindowInLayout;
|
|
476
|
+
private removeWindowFromLayout;
|
|
477
|
+
private updateWindowInLayout;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
interface SpellCheckResult {
|
|
481
|
+
word: string;
|
|
482
|
+
line: number;
|
|
483
|
+
column: number;
|
|
484
|
+
suggestions: string[];
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Manages spell checking functionality using nspell
|
|
488
|
+
*/
|
|
489
|
+
declare class SpellChecker {
|
|
490
|
+
private spell;
|
|
491
|
+
private enabled;
|
|
492
|
+
private goodWords;
|
|
493
|
+
private badWords;
|
|
494
|
+
private sessionGoodWords;
|
|
495
|
+
private sessionBadWords;
|
|
496
|
+
constructor();
|
|
497
|
+
private initializeSpellChecker;
|
|
498
|
+
/**
|
|
499
|
+
* Enable spell checking
|
|
500
|
+
*/
|
|
501
|
+
enable(): void;
|
|
502
|
+
/**
|
|
503
|
+
* Disable spell checking
|
|
504
|
+
*/
|
|
505
|
+
disable(): void;
|
|
506
|
+
/**
|
|
507
|
+
* Check if spell checking is enabled
|
|
508
|
+
*/
|
|
509
|
+
isEnabled(): boolean;
|
|
510
|
+
/**
|
|
511
|
+
* Check if a word is spelled correctly
|
|
512
|
+
*/
|
|
513
|
+
isCorrect(word: string): boolean;
|
|
514
|
+
/**
|
|
515
|
+
* Get spelling suggestions for a word
|
|
516
|
+
*/
|
|
517
|
+
suggest(word: string, maxSuggestions?: number): string[];
|
|
518
|
+
/**
|
|
519
|
+
* Add word to personal dictionary (persistent)
|
|
520
|
+
*/
|
|
521
|
+
addGoodWord(word: string): void;
|
|
522
|
+
/**
|
|
523
|
+
* Add word to session word list (temporary)
|
|
524
|
+
*/
|
|
525
|
+
addSessionGoodWord(word: string): void;
|
|
526
|
+
/**
|
|
527
|
+
* Mark word as bad in personal dictionary (persistent)
|
|
528
|
+
*/
|
|
529
|
+
addBadWord(word: string): void;
|
|
530
|
+
/**
|
|
531
|
+
* Mark word as bad in session list (temporary)
|
|
532
|
+
*/
|
|
533
|
+
addSessionBadWord(word: string): void;
|
|
534
|
+
/**
|
|
535
|
+
* Remove word from good word list
|
|
536
|
+
*/
|
|
537
|
+
removeGoodWord(word: string): void;
|
|
538
|
+
/**
|
|
539
|
+
* Remove word from session good word list
|
|
540
|
+
*/
|
|
541
|
+
removeSessionGoodWord(word: string): void;
|
|
542
|
+
/**
|
|
543
|
+
* Remove word from bad word list
|
|
544
|
+
*/
|
|
545
|
+
removeBadWord(word: string): void;
|
|
546
|
+
/**
|
|
547
|
+
* Remove word from session bad word list
|
|
548
|
+
*/
|
|
549
|
+
removeSessionBadWord(word: string): void;
|
|
550
|
+
/**
|
|
551
|
+
* Check all words in buffer content
|
|
552
|
+
*/
|
|
553
|
+
checkBuffer(content: string): SpellCheckResult[];
|
|
554
|
+
/**
|
|
555
|
+
* Extract words from a line with their positions
|
|
556
|
+
*/
|
|
557
|
+
private extractWords;
|
|
558
|
+
/**
|
|
559
|
+
* Find next misspelled word from cursor position
|
|
560
|
+
*/
|
|
561
|
+
findNextMisspelled(content: string, currentLine: number, currentColumn: number): SpellCheckResult | null;
|
|
562
|
+
/**
|
|
563
|
+
* Find previous misspelled word from cursor position
|
|
564
|
+
*/
|
|
565
|
+
findPrevMisspelled(content: string, currentLine: number, currentColumn: number): SpellCheckResult | null;
|
|
566
|
+
/**
|
|
567
|
+
* Get word at specific position
|
|
568
|
+
*/
|
|
569
|
+
getWordAt(content: string, line: number, column: number): string | null;
|
|
570
|
+
/**
|
|
571
|
+
* Create a copy of this spell checker
|
|
572
|
+
*/
|
|
573
|
+
clone(): SpellChecker;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
interface CompletionMatch {
|
|
577
|
+
text: string;
|
|
578
|
+
type: CompletionType;
|
|
579
|
+
info?: string;
|
|
580
|
+
}
|
|
581
|
+
declare enum CompletionType {
|
|
582
|
+
KEYWORD = "keyword",
|
|
583
|
+
LINE = "line",
|
|
584
|
+
FILENAME = "filename",
|
|
585
|
+
TAG = "tag",
|
|
586
|
+
OMNI = "omni",
|
|
587
|
+
USER = "user",
|
|
588
|
+
SPELLING = "spelling"
|
|
589
|
+
}
|
|
590
|
+
interface CompletionState {
|
|
591
|
+
matches: CompletionMatch[];
|
|
592
|
+
currentIndex: number;
|
|
593
|
+
prefix: string;
|
|
594
|
+
type: CompletionType;
|
|
595
|
+
isActive: boolean;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Manages completion functionality for insert mode
|
|
599
|
+
*/
|
|
600
|
+
declare class CompletionManager {
|
|
601
|
+
private state;
|
|
602
|
+
constructor();
|
|
603
|
+
/**
|
|
604
|
+
* Check if completion is active
|
|
605
|
+
*/
|
|
606
|
+
isActive(): boolean;
|
|
607
|
+
/**
|
|
608
|
+
* Get current completion state
|
|
609
|
+
*/
|
|
610
|
+
getState(): CompletionState | null;
|
|
611
|
+
/**
|
|
612
|
+
* Get currently selected completion match
|
|
613
|
+
*/
|
|
614
|
+
getCurrentMatch(): CompletionMatch | null;
|
|
615
|
+
/**
|
|
616
|
+
* Cancel completion
|
|
617
|
+
*/
|
|
618
|
+
cancel(): void;
|
|
619
|
+
/**
|
|
620
|
+
* Select next completion match
|
|
621
|
+
*/
|
|
622
|
+
next(): void;
|
|
623
|
+
/**
|
|
624
|
+
* Select previous completion match
|
|
625
|
+
*/
|
|
626
|
+
prev(): void;
|
|
627
|
+
/**
|
|
628
|
+
* Start keyword completion - complete from buffer words
|
|
629
|
+
*/
|
|
630
|
+
keywordCompletion(buffer: string, cursorLine: number, cursorCol: number): CompletionMatch[];
|
|
631
|
+
/**
|
|
632
|
+
* Start line completion - complete entire lines
|
|
633
|
+
*/
|
|
634
|
+
lineCompletion(buffer: string, cursorLine: number, cursorCol: number): CompletionMatch[];
|
|
635
|
+
/**
|
|
636
|
+
* Start filename completion
|
|
637
|
+
*/
|
|
638
|
+
fileNameCompletion(buffer: string, cursorLine: number, cursorCol: number, currentDir?: string): Promise<CompletionMatch[]>;
|
|
639
|
+
/**
|
|
640
|
+
* Start omni completion - context-aware completion
|
|
641
|
+
* This is a simplified version that combines keyword and line completion
|
|
642
|
+
*/
|
|
643
|
+
omniCompletion(buffer: string, cursorLine: number, cursorCol: number): CompletionMatch[];
|
|
644
|
+
/**
|
|
645
|
+
* Extract word prefix before cursor
|
|
646
|
+
*/
|
|
647
|
+
private getWordPrefix;
|
|
648
|
+
/**
|
|
649
|
+
* Extract file path prefix before cursor
|
|
650
|
+
*/
|
|
651
|
+
private getFilePathPrefix;
|
|
652
|
+
/**
|
|
653
|
+
* Extract all keywords from buffer
|
|
654
|
+
*/
|
|
655
|
+
private extractKeywords;
|
|
656
|
+
/**
|
|
657
|
+
* Get file type information
|
|
658
|
+
*/
|
|
659
|
+
private getFileTypeInfo;
|
|
660
|
+
/**
|
|
661
|
+
* Get completion text to insert (without prefix)
|
|
662
|
+
*/
|
|
663
|
+
getCompletionText(): string;
|
|
664
|
+
/**
|
|
665
|
+
* Get full completion text including prefix
|
|
666
|
+
*/
|
|
667
|
+
getFullCompletionText(): string;
|
|
668
|
+
/**
|
|
669
|
+
* Clone this completion manager
|
|
670
|
+
*/
|
|
671
|
+
clone(): CompletionManager;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Undo/Redo system with tree structure (like Vim's undo branches)
|
|
676
|
+
*/
|
|
677
|
+
|
|
678
|
+
interface UndoNode {
|
|
679
|
+
id: number;
|
|
680
|
+
state: State;
|
|
681
|
+
parent: UndoNode | null;
|
|
682
|
+
children: UndoNode[];
|
|
683
|
+
timestamp: number;
|
|
684
|
+
description?: string;
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Manages undo/redo with a tree structure
|
|
688
|
+
* Unlike linear undo, this preserves all branches of history
|
|
689
|
+
*/
|
|
690
|
+
declare class UndoTree {
|
|
691
|
+
private root;
|
|
692
|
+
private current;
|
|
693
|
+
private nextId;
|
|
694
|
+
private maxHistorySize;
|
|
695
|
+
constructor(initialState: State);
|
|
696
|
+
/**
|
|
697
|
+
* Add a new state to the undo tree
|
|
698
|
+
*/
|
|
699
|
+
addState(state: State, description?: string): void;
|
|
700
|
+
/**
|
|
701
|
+
* Undo to previous state
|
|
702
|
+
*/
|
|
703
|
+
undo(): State | null;
|
|
704
|
+
/**
|
|
705
|
+
* Redo to next state (follows most recent branch)
|
|
706
|
+
*/
|
|
707
|
+
redo(): State | null;
|
|
708
|
+
/**
|
|
709
|
+
* Get current state
|
|
710
|
+
*/
|
|
711
|
+
getCurrentState(): State;
|
|
712
|
+
/**
|
|
713
|
+
* Check if undo is available
|
|
714
|
+
*/
|
|
715
|
+
canUndo(): boolean;
|
|
716
|
+
/**
|
|
717
|
+
* Check if redo is available
|
|
718
|
+
*/
|
|
719
|
+
canRedo(): boolean;
|
|
720
|
+
/**
|
|
721
|
+
* Go to specific undo branch by ID
|
|
722
|
+
*/
|
|
723
|
+
gotoNode(nodeId: number): State | null;
|
|
724
|
+
/**
|
|
725
|
+
* Go to older text state by time
|
|
726
|
+
*/
|
|
727
|
+
gotoOlder(seconds?: number): State | null;
|
|
728
|
+
/**
|
|
729
|
+
* Go to newer text state by time
|
|
730
|
+
*/
|
|
731
|
+
gotoNewer(seconds?: number): State | null;
|
|
732
|
+
/**
|
|
733
|
+
* Get undo history for display
|
|
734
|
+
*/
|
|
735
|
+
getHistory(): Array<{
|
|
736
|
+
id: number;
|
|
737
|
+
description?: string;
|
|
738
|
+
timestamp: number;
|
|
739
|
+
isCurrent: boolean;
|
|
740
|
+
}>;
|
|
741
|
+
/**
|
|
742
|
+
* Get all available branches from current position
|
|
743
|
+
*/
|
|
744
|
+
getBranches(): UndoNode[];
|
|
745
|
+
/**
|
|
746
|
+
* Clear all undo history
|
|
747
|
+
*/
|
|
748
|
+
clear(): void;
|
|
749
|
+
/**
|
|
750
|
+
* Find node by ID (DFS)
|
|
751
|
+
*/
|
|
752
|
+
private findNode;
|
|
753
|
+
/**
|
|
754
|
+
* Find newer path in tree
|
|
755
|
+
*/
|
|
756
|
+
private findNewerPath;
|
|
757
|
+
/**
|
|
758
|
+
* Prune old history to keep memory usage reasonable
|
|
759
|
+
*/
|
|
760
|
+
private pruneHistory;
|
|
761
|
+
/**
|
|
762
|
+
* Get nodes in current branch from root to current
|
|
763
|
+
*/
|
|
764
|
+
private getCurrentBranch;
|
|
765
|
+
/**
|
|
766
|
+
* Remove a node from the tree
|
|
767
|
+
*/
|
|
768
|
+
private removeNode;
|
|
769
|
+
/**
|
|
770
|
+
* Clone this undo tree
|
|
771
|
+
*/
|
|
772
|
+
clone(): UndoTree;
|
|
773
|
+
/**
|
|
774
|
+
* Deep clone a node and its children
|
|
775
|
+
*/
|
|
776
|
+
private cloneNode;
|
|
777
|
+
/**
|
|
778
|
+
* Get statistics about the undo tree
|
|
779
|
+
*/
|
|
780
|
+
getStats(): {
|
|
781
|
+
totalNodes: number;
|
|
782
|
+
currentDepth: number;
|
|
783
|
+
maxDepth: number;
|
|
784
|
+
branchCount: number;
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
interface LastVisualSelection {
|
|
789
|
+
range: Range;
|
|
790
|
+
mode: Mode.VISUAL | Mode.VISUAL_LINE | Mode.VISUAL_BLOCK;
|
|
791
|
+
}
|
|
792
|
+
interface SearchState {
|
|
793
|
+
pattern: string;
|
|
794
|
+
isForward: boolean;
|
|
795
|
+
}
|
|
796
|
+
interface LastCommand {
|
|
797
|
+
key: string;
|
|
798
|
+
count?: number;
|
|
799
|
+
register?: string;
|
|
800
|
+
}
|
|
801
|
+
declare class State {
|
|
802
|
+
buffer: Buffer;
|
|
803
|
+
cursor: Cursor;
|
|
804
|
+
selection: Range | null;
|
|
805
|
+
mode: Mode;
|
|
806
|
+
commandLine: string;
|
|
807
|
+
desiredColumn: number | null;
|
|
808
|
+
viewport: VimViewport;
|
|
809
|
+
visualAnchor: Cursor | null;
|
|
810
|
+
lastVisualSelection: LastVisualSelection | null;
|
|
811
|
+
recordingRegister: string | null;
|
|
812
|
+
lastMacroRegister: string | null;
|
|
813
|
+
foldManager: FoldManager;
|
|
814
|
+
markManager: MarkManager;
|
|
815
|
+
jumpListManager: JumpListManager;
|
|
816
|
+
fileSystem: FileSystemManager;
|
|
817
|
+
windowManager: WindowManager;
|
|
818
|
+
lastSearch: SearchState | null;
|
|
819
|
+
spellChecker: SpellChecker;
|
|
820
|
+
completionManager: CompletionManager;
|
|
821
|
+
undoTree: UndoTree | null;
|
|
822
|
+
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);
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
declare abstract class TextObject {
|
|
827
|
+
abstract key: string;
|
|
828
|
+
abstract getRange(state: State, variant: 'inner' | 'outer'): Range | null;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
declare class Register {
|
|
832
|
+
content: string;
|
|
833
|
+
linewise: boolean;
|
|
834
|
+
constructor(content?: string, linewise?: boolean);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
declare class RegisterManager {
|
|
838
|
+
private registers;
|
|
839
|
+
get(name: string): Register | undefined;
|
|
840
|
+
set(name: string, content: string, linewise: boolean): void;
|
|
841
|
+
/**
|
|
842
|
+
* Store deleted text: writes to unnamed register `"` and shifts numbered registers 1-9.
|
|
843
|
+
*/
|
|
844
|
+
storeDelete(content: string, linewise: boolean): void;
|
|
845
|
+
/**
|
|
846
|
+
* Store yanked text: writes to register `0` and unnamed register `"`.
|
|
847
|
+
*/
|
|
848
|
+
storeYank(content: string, linewise: boolean): void;
|
|
849
|
+
/**
|
|
850
|
+
* Returns a snapshot of all non-empty registers for display.
|
|
851
|
+
*/
|
|
852
|
+
getAll(): Map<string, Register>;
|
|
853
|
+
getDefaultRegister(): Register | undefined;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
interface IndentConfig {
|
|
857
|
+
useSpaces: boolean;
|
|
858
|
+
indentSize: number;
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Manages indentation detection, calculation, and adjustment
|
|
862
|
+
*/
|
|
863
|
+
declare class IndentationManager {
|
|
864
|
+
private config;
|
|
865
|
+
constructor(config?: Partial<IndentConfig>);
|
|
866
|
+
/**
|
|
867
|
+
* Detect indentation style from buffer content
|
|
868
|
+
* Analyzes the buffer to determine if tabs or spaces are used,
|
|
869
|
+
* and what the indent size is.
|
|
870
|
+
*/
|
|
871
|
+
detectIndentation(buffer: Buffer): IndentConfig;
|
|
872
|
+
/**
|
|
873
|
+
* Update the indent configuration
|
|
874
|
+
*/
|
|
875
|
+
setConfig(config: Partial<IndentConfig>): void;
|
|
876
|
+
/**
|
|
877
|
+
* Get the current indent configuration
|
|
878
|
+
*/
|
|
879
|
+
getConfig(): IndentConfig;
|
|
880
|
+
/**
|
|
881
|
+
* Get the indent string for a given level
|
|
882
|
+
*/
|
|
883
|
+
getIndentString(level: number): string;
|
|
884
|
+
/**
|
|
885
|
+
* Get the indent of a line (leading whitespace)
|
|
886
|
+
*/
|
|
887
|
+
getLineIndent(line: string): string;
|
|
888
|
+
/**
|
|
889
|
+
* Get the indent level of a line (number of indent units)
|
|
890
|
+
*/
|
|
891
|
+
getIndentLevel(line: string): number;
|
|
892
|
+
/**
|
|
893
|
+
* Calculate indent for a new line after a given line
|
|
894
|
+
* Uses smart indentation based on the content of the previous line
|
|
895
|
+
*/
|
|
896
|
+
calculateIndentForNewLine(buffer: Buffer, afterLineIndex: number): string;
|
|
897
|
+
/**
|
|
898
|
+
* Adjust indent of content to match target indent
|
|
899
|
+
* Takes content (possibly multi-line) and adjusts its indentation
|
|
900
|
+
* to match the target indent while preserving relative indentation
|
|
901
|
+
*/
|
|
902
|
+
adjustIndent(content: string, targetIndent: string): string;
|
|
903
|
+
/**
|
|
904
|
+
* Re-indent a line to a specific level
|
|
905
|
+
*/
|
|
906
|
+
reindentLine(line: string, level: number): string;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
interface CommandContext {
|
|
910
|
+
count?: number;
|
|
911
|
+
motion?: Motion;
|
|
912
|
+
textObject?: TextObject;
|
|
913
|
+
variant?: 'inner' | 'outer';
|
|
914
|
+
register?: string;
|
|
915
|
+
char?: string;
|
|
916
|
+
registerManager?: RegisterManager;
|
|
917
|
+
indentationManager?: IndentationManager;
|
|
918
|
+
args?: string;
|
|
919
|
+
range?: Range;
|
|
920
|
+
}
|
|
921
|
+
declare abstract class Command {
|
|
922
|
+
abstract key: string;
|
|
923
|
+
acceptsMotion: boolean;
|
|
924
|
+
acceptsTextObject: boolean;
|
|
925
|
+
acceptsPrecedingCount: boolean;
|
|
926
|
+
acceptsRegister: boolean;
|
|
927
|
+
needsFollowingChar: boolean;
|
|
928
|
+
isPrefix: boolean;
|
|
929
|
+
inclusive: boolean;
|
|
930
|
+
abstract execute(state: State, context: CommandContext): State;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
declare abstract class Motion extends Command {
|
|
934
|
+
abstract key: string;
|
|
935
|
+
acceptsMotion: boolean;
|
|
936
|
+
acceptsTextObject: boolean;
|
|
937
|
+
acceptsPrecedingCount: boolean;
|
|
938
|
+
inclusive: boolean;
|
|
939
|
+
linewise: boolean;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
declare class Change {
|
|
943
|
+
stateBefore: State;
|
|
944
|
+
stateAfter: State;
|
|
945
|
+
keySequence: string;
|
|
946
|
+
timestamp: number;
|
|
947
|
+
constructor(stateBefore: State, stateAfter: State, keySequence: string, timestamp: number);
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
declare class UndoStack {
|
|
951
|
+
private entries;
|
|
952
|
+
private currentIndex;
|
|
953
|
+
push(change: Change): void;
|
|
954
|
+
undo(): State | null;
|
|
955
|
+
redo(): State | null;
|
|
956
|
+
getEntries(): Change[];
|
|
957
|
+
getCurrentIndex(): number;
|
|
958
|
+
}
|
|
959
|
+
|
|
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
|
+
interface CommandHistoryEntry {
|
|
1034
|
+
keys: string;
|
|
1035
|
+
timestamp: number;
|
|
1036
|
+
}
|
|
1037
|
+
declare class Session {
|
|
1038
|
+
private commands;
|
|
1039
|
+
private motions;
|
|
1040
|
+
private textObjects;
|
|
1041
|
+
private keyBuffer;
|
|
1042
|
+
private isPlayingMacro;
|
|
1043
|
+
state: State;
|
|
1044
|
+
registerManager: RegisterManager;
|
|
1045
|
+
undoStack: UndoStack;
|
|
1046
|
+
commandHistory: CommandHistoryEntry[];
|
|
1047
|
+
indentationManager: IndentationManager;
|
|
1048
|
+
configManager: ConfigManager;
|
|
1049
|
+
constructor();
|
|
1050
|
+
private syncIndentConfig;
|
|
1051
|
+
setState(state: State): void;
|
|
1052
|
+
getState(): State;
|
|
1053
|
+
getPendingKeys(): string;
|
|
1054
|
+
getCommandLine(): string;
|
|
1055
|
+
getRegisters(): Map<string, {
|
|
1056
|
+
content: string;
|
|
1057
|
+
linewise: boolean;
|
|
1058
|
+
}>;
|
|
1059
|
+
getUndoStack(): UndoStack;
|
|
1060
|
+
getCommandHistory(): CommandHistoryEntry[];
|
|
1061
|
+
/**
|
|
1062
|
+
* Convenience method to set cursor position directly.
|
|
1063
|
+
* Automatically clamps to valid buffer bounds.
|
|
1064
|
+
*/
|
|
1065
|
+
setCursor(line: number, column: number): void;
|
|
1066
|
+
/**
|
|
1067
|
+
* Convenience method to enter VISUAL mode with a selection.
|
|
1068
|
+
* Automatically clamps coordinates to valid buffer bounds.
|
|
1069
|
+
*/
|
|
1070
|
+
setSelection(startLine: number, startCol: number, endLine: number, endCol: number): void;
|
|
1071
|
+
/**
|
|
1072
|
+
* Convenience method to clear selection and return to NORMAL mode.
|
|
1073
|
+
*/
|
|
1074
|
+
clearSelection(): void;
|
|
1075
|
+
/**
|
|
1076
|
+
* Convenience method to set the mode.
|
|
1077
|
+
* Note: Use clearSelection() to exit VISUAL mode, or setCursor() to maintain cursor position.
|
|
1078
|
+
*/
|
|
1079
|
+
setMode(mode: Mode): void;
|
|
1080
|
+
/**
|
|
1081
|
+
* Normalize a key string to Vim format.
|
|
1082
|
+
* This is useful for testing or when you have key strings that need normalization.
|
|
1083
|
+
*
|
|
1084
|
+
* Examples:
|
|
1085
|
+
* - normalizeKey("Ctrl+f") -> "<C-f>"
|
|
1086
|
+
* - normalizeKey("Alt+x") -> "<A-x>"
|
|
1087
|
+
* - normalizeKey("Escape") -> "<Esc>"
|
|
1088
|
+
*/
|
|
1089
|
+
static normalizeKey(key: string): string;
|
|
1090
|
+
/**
|
|
1091
|
+
* Handle a raw keyboard event from the browser.
|
|
1092
|
+
* Converts browser KeyboardEvent to Vim-style key notation.
|
|
1093
|
+
*
|
|
1094
|
+
* Key format conventions:
|
|
1095
|
+
* - Single keys: 'a', 'B', '1', '$', etc.
|
|
1096
|
+
* - Ctrl combinations: '<C-f>', '<C-w>', etc.
|
|
1097
|
+
* - Alt combinations: '<A-x>', '<A-k>', etc.
|
|
1098
|
+
* - Command/Meta: '<D-s>', '<D-c>', etc.
|
|
1099
|
+
* - Special keys: '<Esc>', 'Space', 'Enter', 'Backspace', etc.
|
|
1100
|
+
* - Arrow keys: 'ArrowUp', 'ArrowDown', etc.
|
|
1101
|
+
*/
|
|
1102
|
+
handleRawKeyEvent(event: KeyboardEvent): void;
|
|
1103
|
+
handleKey(key: string): void;
|
|
1104
|
+
private handleInsertMode;
|
|
1105
|
+
private handleCommandMode;
|
|
1106
|
+
private executeCommand;
|
|
1107
|
+
private match;
|
|
1108
|
+
private tryMatch;
|
|
1109
|
+
private playMacro;
|
|
1110
|
+
addMotion(motion: Motion): void;
|
|
1111
|
+
addTextObject(textObject: TextObject): void;
|
|
1112
|
+
addCommand(mode: Mode, command: Command): void;
|
|
1113
|
+
loadStandardVimCommands(): void;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
declare abstract class Operator extends Command {
|
|
1117
|
+
acceptsPrecedingCount: boolean;
|
|
1118
|
+
acceptsMotion: boolean;
|
|
1119
|
+
acceptsTextObject: boolean;
|
|
1120
|
+
acceptsRegister: boolean;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
declare class PatternRegistry {
|
|
1124
|
+
private patterns;
|
|
1125
|
+
register(name: string, regexProvider: () => string): void;
|
|
1126
|
+
expand(pattern: string): RegExp;
|
|
1127
|
+
private escapeRegex;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
declare abstract class ModeTransition extends Command {
|
|
1131
|
+
abstract targetMode: Mode;
|
|
1132
|
+
protected beforeTransition(state: State, context: CommandContext): State;
|
|
1133
|
+
execute(state: State, context: CommandContext): State;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* Character classification utilities
|
|
1138
|
+
*/
|
|
1139
|
+
type CharClassifier = (char: string) => boolean;
|
|
1140
|
+
declare function isWordChar(char: string): boolean;
|
|
1141
|
+
declare function isWhitespace(char: string): boolean;
|
|
1142
|
+
declare function isPunctuation(char: string): boolean;
|
|
1143
|
+
declare function isNewline(char: string): boolean;
|
|
1144
|
+
/**
|
|
1145
|
+
* Character access utilities
|
|
1146
|
+
*/
|
|
1147
|
+
declare function getCharAt(buffer: Buffer, cursor: Cursor): string;
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* Cursor state checks
|
|
1151
|
+
*/
|
|
1152
|
+
declare function isOnChar(buffer: Buffer, cursor: Cursor, classifier: CharClassifier): boolean;
|
|
1153
|
+
declare function isOnWord(buffer: Buffer, cursor: Cursor): boolean;
|
|
1154
|
+
declare function isOnWhitespace(buffer: Buffer, cursor: Cursor): boolean;
|
|
1155
|
+
declare function isOnPunctuation(buffer: Buffer, cursor: Cursor): boolean;
|
|
1156
|
+
declare function isAtLineStart(cursor: Cursor): boolean;
|
|
1157
|
+
declare function isAtLineEnd(buffer: Buffer, cursor: Cursor): boolean;
|
|
1158
|
+
declare function isAtBufferStart(cursor: Cursor): boolean;
|
|
1159
|
+
declare function isAtBufferEnd(buffer: Buffer, cursor: Cursor): boolean;
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* Move cursor by a given character offset.
|
|
1163
|
+
* Handles moving across line boundaries.
|
|
1164
|
+
*/
|
|
1165
|
+
declare function moveCursorBy(buffer: Buffer, cursor: Cursor, offset: number): Cursor;
|
|
1166
|
+
declare function moveRight(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1167
|
+
declare function moveLeft(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1168
|
+
declare function moveDown(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1169
|
+
declare function moveUp(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1170
|
+
/**
|
|
1171
|
+
* Character access by offset
|
|
1172
|
+
*/
|
|
1173
|
+
declare function getCharAtOffset(buffer: Buffer, cursor: Cursor, offset: number): string;
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* Generic search functions
|
|
1177
|
+
*/
|
|
1178
|
+
declare function findNext(buffer: Buffer, cursor: Cursor, classifier: CharClassifier, inclusive?: boolean): Cursor;
|
|
1179
|
+
declare function findPrev(buffer: Buffer, cursor: Cursor, classifier: CharClassifier, inclusive?: boolean): Cursor;
|
|
1180
|
+
/**
|
|
1181
|
+
* Skip while character matches classifier
|
|
1182
|
+
*/
|
|
1183
|
+
declare function skipWhile(buffer: Buffer, cursor: Cursor, classifier: CharClassifier, forward?: boolean): Cursor;
|
|
1184
|
+
/**
|
|
1185
|
+
* Skip until character matches classifier
|
|
1186
|
+
*/
|
|
1187
|
+
declare function skipUntil(buffer: Buffer, cursor: Cursor, classifier: CharClassifier, forward?: boolean): Cursor;
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* Word boundary navigation (built on atomic functions)
|
|
1191
|
+
*/
|
|
1192
|
+
/**
|
|
1193
|
+
* Find the start of the next word (w motion)
|
|
1194
|
+
*/
|
|
1195
|
+
declare function findNextWordStart(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1196
|
+
/**
|
|
1197
|
+
* Find the start of the previous word (b motion)
|
|
1198
|
+
*/
|
|
1199
|
+
declare function findPrevWordStart(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1200
|
+
declare function findNextWordEnd(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1201
|
+
/**
|
|
1202
|
+
* WORD (big word) navigation - whitespace separated
|
|
1203
|
+
*/
|
|
1204
|
+
/**
|
|
1205
|
+
* Find the start of the next WORD (W motion)
|
|
1206
|
+
* WORDs are whitespace-separated (hello-world is one WORD)
|
|
1207
|
+
*/
|
|
1208
|
+
declare function findNextWORDStart(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1209
|
+
/**
|
|
1210
|
+
* Find the end of the next WORD (E motion)
|
|
1211
|
+
* WORDs are whitespace-separated
|
|
1212
|
+
*/
|
|
1213
|
+
declare function findNextWORDEnd(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1214
|
+
/**
|
|
1215
|
+
* Find the start of the previous WORD (B motion)
|
|
1216
|
+
* WORDs are whitespace-separated
|
|
1217
|
+
*/
|
|
1218
|
+
declare function findPrevWORDStart(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1219
|
+
/**
|
|
1220
|
+
* Find the end of the previous word (ge motion)
|
|
1221
|
+
* This is the mirror of 'e' but going backward
|
|
1222
|
+
*/
|
|
1223
|
+
declare function findPrevWordEnd(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1224
|
+
/**
|
|
1225
|
+
* Find the end of the previous WORD (gE motion)
|
|
1226
|
+
* WORDs are whitespace-separated (hello-world is one WORD)
|
|
1227
|
+
*/
|
|
1228
|
+
declare function findPrevWORDEnd(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1229
|
+
/**
|
|
1230
|
+
* Whitespace navigation
|
|
1231
|
+
*/
|
|
1232
|
+
declare function skipWhitespace(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1233
|
+
|
|
1234
|
+
/**
|
|
1235
|
+
* Line navigation
|
|
1236
|
+
*/
|
|
1237
|
+
/**
|
|
1238
|
+
* First non-blank character on cursor's line
|
|
1239
|
+
*/
|
|
1240
|
+
declare function findFirstNonBlank(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1241
|
+
/**
|
|
1242
|
+
* Move to start of current line
|
|
1243
|
+
*/
|
|
1244
|
+
declare function findLineStart(cursor: Cursor): Cursor;
|
|
1245
|
+
/**
|
|
1246
|
+
* Move to end of current line
|
|
1247
|
+
*/
|
|
1248
|
+
declare function findLineEnd(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1249
|
+
|
|
1250
|
+
/**
|
|
1251
|
+
* Normalize a range so that start always comes before end.
|
|
1252
|
+
* Handles backward motions where end < start.
|
|
1253
|
+
*/
|
|
1254
|
+
declare function normalizeRange(range: Range): Range;
|
|
1255
|
+
/**
|
|
1256
|
+
* Extract text content from a range
|
|
1257
|
+
*/
|
|
1258
|
+
declare function getTextInRange(buffer: Buffer, range: Range): string;
|
|
1259
|
+
/**
|
|
1260
|
+
* Delete text in a range and return new buffer content
|
|
1261
|
+
*/
|
|
1262
|
+
declare function deleteRange(buffer: Buffer, range: Range): string;
|
|
1263
|
+
/**
|
|
1264
|
+
* Replace text in a range
|
|
1265
|
+
*/
|
|
1266
|
+
declare function replaceRange(buffer: Buffer, range: Range, text: string): string;
|
|
1267
|
+
/**
|
|
1268
|
+
* Expand range to include surrounding whitespace
|
|
1269
|
+
* Prefers trailing whitespace, falls back to leading if at end of line
|
|
1270
|
+
*/
|
|
1271
|
+
declare function expandRangeOuter(buffer: Buffer, range: Range): Range;
|
|
1272
|
+
/**
|
|
1273
|
+
* Check if cursor is within range
|
|
1274
|
+
*/
|
|
1275
|
+
declare function isInRange(cursor: Cursor, range: Range): boolean;
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Get lines array from buffer
|
|
1279
|
+
*/
|
|
1280
|
+
declare function getLines(buffer: Buffer): string[];
|
|
1281
|
+
/**
|
|
1282
|
+
* Get specific line
|
|
1283
|
+
*/
|
|
1284
|
+
declare function getLine(buffer: Buffer, lineNum: number): string;
|
|
1285
|
+
/**
|
|
1286
|
+
* Delete line and return new buffer content
|
|
1287
|
+
*/
|
|
1288
|
+
declare function deleteLine(buffer: Buffer, lineNum: number): string;
|
|
1289
|
+
/**
|
|
1290
|
+
* Delete multiple lines
|
|
1291
|
+
*/
|
|
1292
|
+
declare function deleteLines(buffer: Buffer, startLine: number, count: number): string;
|
|
1293
|
+
/**
|
|
1294
|
+
* Create new state with updated buffer content
|
|
1295
|
+
*/
|
|
1296
|
+
declare function withBufferContent(state: State, content: string): State;
|
|
1297
|
+
/**
|
|
1298
|
+
* Create new state with updated cursor
|
|
1299
|
+
* By default, preserves desiredColumn (for vertical motions)
|
|
1300
|
+
*/
|
|
1301
|
+
declare function withCursor(state: State, cursor: Cursor, preserveDesiredColumn?: boolean): State;
|
|
1302
|
+
/**
|
|
1303
|
+
* Create new state with updated cursor, maintaining desiredColumn for vertical motion
|
|
1304
|
+
* Sets desiredColumn to the target column if not already set
|
|
1305
|
+
*/
|
|
1306
|
+
declare function withCursorVertical(state: State, cursor: Cursor, targetColumn: number): State;
|
|
1307
|
+
/**
|
|
1308
|
+
* Create new state with updated cursor and reset desiredColumn (for horizontal motions)
|
|
1309
|
+
*/
|
|
1310
|
+
declare function withCursorHorizontal(state: State, cursor: Cursor): State;
|
|
1311
|
+
/**
|
|
1312
|
+
* Create new state with updated viewport
|
|
1313
|
+
*/
|
|
1314
|
+
declare function withViewport(state: State, topLine: number): State;
|
|
1315
|
+
/**
|
|
1316
|
+
* Create new state with updated cursor and viewport
|
|
1317
|
+
*/
|
|
1318
|
+
declare function withCursorAndViewport(state: State, cursor: Cursor, topLine: number, desiredCol?: number | null): State;
|
|
1319
|
+
/**
|
|
1320
|
+
* Clamp cursor to valid buffer position
|
|
1321
|
+
*/
|
|
1322
|
+
declare function clampCursor(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1323
|
+
/**
|
|
1324
|
+
* Clamp cursor for normal mode vertical motion
|
|
1325
|
+
* In normal mode, cursor must be ON a character, not past the end
|
|
1326
|
+
*/
|
|
1327
|
+
declare function clampCursorNormalMode(buffer: Buffer, cursor: Cursor): Cursor;
|
|
1328
|
+
/**
|
|
1329
|
+
* Clamp cursor for vertical motion (j/k) with Vim's whitespace handling.
|
|
1330
|
+
* If the desired column would land in leading whitespace (before any non-whitespace),
|
|
1331
|
+
* move to the beginning of the line instead.
|
|
1332
|
+
*/
|
|
1333
|
+
declare function clampCursorVerticalMotion(buffer: Buffer, cursor: Cursor, desiredColumn: number): Cursor;
|
|
1334
|
+
/**
|
|
1335
|
+
* Update visual selection based on current cursor and anchor
|
|
1336
|
+
* Used when cursor moves in visual mode
|
|
1337
|
+
*/
|
|
1338
|
+
declare function updateVisualSelection(state: State, newCursor: Cursor): State;
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* Get the effective count from a command context (defaults to 1).
|
|
1342
|
+
*/
|
|
1343
|
+
declare function getCount(context: CommandContext): number;
|
|
1344
|
+
/**
|
|
1345
|
+
* Get the text of the line at the cursor position.
|
|
1346
|
+
*/
|
|
1347
|
+
declare function currentLine(state: State): string;
|
|
1348
|
+
/**
|
|
1349
|
+
* Get the total number of lines in the buffer.
|
|
1350
|
+
*/
|
|
1351
|
+
declare function lineCount(state: State): number;
|
|
1352
|
+
/**
|
|
1353
|
+
* Get the maximum valid line index (0-based).
|
|
1354
|
+
*/
|
|
1355
|
+
declare function lastLine(state: State): number;
|
|
1356
|
+
/**
|
|
1357
|
+
* Apply a cursor motion function `count` times, clamping the result.
|
|
1358
|
+
* Replaces the repeated loop+clamp pattern in word motions.
|
|
1359
|
+
* Resets desiredColumn since word motions are horizontal.
|
|
1360
|
+
*/
|
|
1361
|
+
declare function repeatCursorMotion(state: State, context: CommandContext, fn: (buffer: Buffer, cursor: Cursor) => Cursor): State;
|
|
1362
|
+
/**
|
|
1363
|
+
* Resolve the operator range from either a text object or a motion in the context.
|
|
1364
|
+
* Returns null if neither is present.
|
|
1365
|
+
* Normalizes the range so start always comes before end (handles backward motions).
|
|
1366
|
+
* Handles inclusive motions by extending the range by 1 character.
|
|
1367
|
+
*/
|
|
1368
|
+
declare function resolveOperatorRange(state: State, context: CommandContext): Range | null;
|
|
1369
|
+
/**
|
|
1370
|
+
* Create a new state with both updated buffer content and cursor position.
|
|
1371
|
+
*/
|
|
1372
|
+
declare function withContentAndCursor(state: State, content: string, cursor: Cursor): State;
|
|
1373
|
+
/**
|
|
1374
|
+
* Delete a range and store the deleted text in the register manager.
|
|
1375
|
+
* Returns a new state with the content deleted and cursor repositioned.
|
|
1376
|
+
* Normalizes the range to ensure start comes before end.
|
|
1377
|
+
*/
|
|
1378
|
+
declare function deleteRangeWithRegister(state: State, range: Range, context: CommandContext, isLinewise?: boolean): State;
|
|
1379
|
+
|
|
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 };
|