@fresh-editor/fresh-editor 0.1.76 → 0.1.83
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/CHANGELOG.md +57 -0
- package/README.md +2 -0
- package/package.json +1 -1
- package/plugins/audit_mode.ts +17 -17
- package/plugins/calculator.ts +1 -1
- package/plugins/config-schema.json +32 -2
- package/plugins/git_blame.ts +5 -5
- package/plugins/git_explorer.ts +159 -0
- package/plugins/git_find_file.ts +7 -3
- package/plugins/git_grep.ts +1 -1
- package/plugins/git_log.ts +15 -15
- package/plugins/lib/finder.ts +5 -3
- package/plugins/lib/fresh.d.ts +641 -1389
- package/plugins/lib/index.ts +9 -1
- package/plugins/lib/types.ts +14 -0
- package/plugins/live_grep.ts +1 -1
- package/plugins/odin-lsp.ts +135 -0
- package/plugins/search_replace.ts +1 -1
- package/plugins/theme_editor.ts +40 -8
- package/plugins/vi_mode.ts +6 -0
- package/plugins/welcome.ts +5 -5
- package/plugins/lib/results-panel.ts +0 -914
package/plugins/lib/fresh.d.ts
CHANGED
|
@@ -1,1397 +1,649 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
* ### Buffers
|
|
16
|
-
* A buffer holds text content and may or may not be associated with a file.
|
|
17
|
-
* Each buffer has a unique numeric ID that persists for the editor session.
|
|
18
|
-
* Buffers track their content, modification state, cursor positions, and path.
|
|
19
|
-
* All text operations (insert, delete, read) use byte offsets, not character indices.
|
|
20
|
-
*
|
|
21
|
-
* ### Splits
|
|
22
|
-
* A split is a viewport pane that displays a buffer. The editor can have multiple
|
|
23
|
-
* splits arranged in a tree layout. Each split shows exactly one buffer, but the
|
|
24
|
-
* same buffer can be displayed in multiple splits. Use split IDs to control which
|
|
25
|
-
* pane displays which buffer.
|
|
26
|
-
*
|
|
27
|
-
* ### Virtual Buffers
|
|
28
|
-
* Special buffers created by plugins to display structured data like search results,
|
|
29
|
-
* diagnostics, or git logs. Virtual buffers support text properties (metadata attached
|
|
30
|
-
* to text ranges) that plugins can query when the user selects a line. Unlike normal
|
|
31
|
-
* buffers, virtual buffers are typically read-only and not backed by files.
|
|
32
|
-
*
|
|
33
|
-
* ### Text Properties
|
|
34
|
-
* Metadata attached to text ranges in virtual buffers. Each entry has text content
|
|
35
|
-
* and a properties object with arbitrary key-value pairs. Use `getTextPropertiesAtCursor`
|
|
36
|
-
* to retrieve properties at the cursor position (e.g., to get file/line info for "go to").
|
|
37
|
-
*
|
|
38
|
-
* ### Overlays
|
|
39
|
-
* Visual decorations applied to buffer text without modifying content. Overlays can
|
|
40
|
-
* change text color and add underlines. Use overlay IDs to manage them; prefix IDs
|
|
41
|
-
* enable batch removal (e.g., "lint:" prefix for all linter highlights).
|
|
42
|
-
*
|
|
43
|
-
* ### Modes
|
|
44
|
-
* Keybinding contexts that determine how keypresses are interpreted. Each buffer has
|
|
45
|
-
* a mode (e.g., "normal", "insert", "special"). Custom modes can inherit from parents
|
|
46
|
-
* and define buffer-local keybindings. Virtual buffers typically use custom modes.
|
|
47
|
-
*/
|
|
48
|
-
|
|
2
|
+
* Fresh Editor TypeScript Plugin API
|
|
3
|
+
*
|
|
4
|
+
* This file provides type definitions for the Fresh editor's TypeScript plugin system.
|
|
5
|
+
* Plugins have access to the global `editor` object which provides methods to:
|
|
6
|
+
* - Query editor state (buffers, cursors, viewports)
|
|
7
|
+
* - Modify buffer content (insert, delete text)
|
|
8
|
+
* - Add visual decorations (overlays, highlighting)
|
|
9
|
+
* - Interact with the editor UI (status messages, prompts)
|
|
10
|
+
*
|
|
11
|
+
* AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
|
|
12
|
+
* Generated by fresh-plugin-api-macros + ts-rs from JsEditorApi impl
|
|
13
|
+
*/
|
|
49
14
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
* @example
|
|
54
|
-
* const editor = getEditor();
|
|
55
|
-
*/
|
|
15
|
+
* Get the editor API instance.
|
|
16
|
+
* Plugins must call this at the top of their file to get a scoped editor object.
|
|
17
|
+
*/
|
|
56
18
|
declare function getEditor(): EditorAPI;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Translate a string using the plugin's i18n file
|
|
65
|
-
* @param key - Translation key (e.g., "status.ready")
|
|
66
|
-
* @param args - Optional interpolation arguments
|
|
67
|
-
* @returns Translated string
|
|
68
|
-
*/
|
|
69
|
-
t(key: string, args?: Record<string, string>): string;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Get the i18n helper object (for compatibility)
|
|
73
|
-
* @returns Object with t() method bound to this plugin
|
|
74
|
-
*/
|
|
75
|
-
getL10n(): { t: (key: string, args?: Record<string, string>) => string };
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Register a custom command (plugin wrapper - source is added automatically)
|
|
79
|
-
* @param name - Command name (use %key for i18n)
|
|
80
|
-
* @param description - Command description (use %key for i18n)
|
|
81
|
-
* @param action - Global function name to call
|
|
82
|
-
* @param contexts - Comma-separated contexts (default: "")
|
|
83
|
-
* @returns true if command was registered
|
|
84
|
-
*/
|
|
85
|
-
registerCommand(name: string, description: string, action: string, contexts?: string): boolean;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Copy text to system clipboard (alias for setClipboard)
|
|
89
|
-
* @param text - Text to copy
|
|
90
|
-
*/
|
|
91
|
-
copyToClipboard(text: string): void;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Join path segments into a single path (variadic version)
|
|
95
|
-
* @param parts - Path segments to join
|
|
96
|
-
* @returns Joined path string
|
|
97
|
-
*/
|
|
98
|
-
pathJoin(...parts: string[]): string;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Add a visual overlay to buffer text (with optional parameters)
|
|
102
|
-
* Most parameters have defaults: bold=false, italic=false, bg=-1 (transparent), extend=false
|
|
103
|
-
*/
|
|
104
|
-
addOverlay(
|
|
105
|
-
buffer_id: number,
|
|
106
|
-
namespace: string,
|
|
107
|
-
start: number,
|
|
108
|
-
end: number,
|
|
109
|
-
r: number,
|
|
110
|
-
g: number,
|
|
111
|
-
b: number,
|
|
112
|
-
underline: boolean,
|
|
113
|
-
bold?: boolean,
|
|
114
|
-
italic?: boolean,
|
|
115
|
-
bg_r?: number,
|
|
116
|
-
bg_g?: number,
|
|
117
|
-
bg_b?: number,
|
|
118
|
-
extend_to_line_end?: boolean
|
|
119
|
-
): boolean;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Get the theme JSON Schema (with proper typing)
|
|
123
|
-
*/
|
|
124
|
-
getThemeSchema(): {
|
|
125
|
-
$defs?: Record<string, Record<string, unknown>>;
|
|
126
|
-
properties?: Record<string, unknown>;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Get built-in themes as a map of name to JSON string
|
|
131
|
-
*/
|
|
132
|
-
getBuiltinThemes(): Record<string, string>;
|
|
19
|
+
/** Handle for a cancellable async operation */
|
|
20
|
+
interface ProcessHandle<T> extends PromiseLike<T> {
|
|
21
|
+
/** Promise that resolves to the result when complete */
|
|
22
|
+
readonly result: Promise<T>;
|
|
23
|
+
/** Cancel/kill the operation. Returns true if cancelled, false if already completed */
|
|
24
|
+
kill(): Promise<boolean>;
|
|
133
25
|
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Buffer identifier (unique numeric ID)
|
|
137
|
-
*/
|
|
26
|
+
/** Buffer identifier */
|
|
138
27
|
type BufferId = number;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/** Result from createVirtualBufferInSplit */
|
|
309
|
-
interface CreateVirtualBufferResult {
|
|
310
|
-
buffer_id: number;
|
|
311
|
-
split_id?: number | null;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/** Configuration for createVirtualBufferInSplit */
|
|
315
|
-
interface CreateVirtualBufferOptions {
|
|
316
|
-
/** Buffer name shown in status bar (convention: "*Name*") */
|
|
317
|
-
name: string;
|
|
318
|
-
/** Mode for keybindings; define with defineMode first */
|
|
319
|
-
mode: string;
|
|
320
|
-
/** Prevent text modifications */
|
|
321
|
-
read_only: boolean;
|
|
322
|
-
/** Content with embedded metadata */
|
|
323
|
-
entries: TextPropertyEntry[];
|
|
324
|
-
/** Split ratio (0.3 = new pane gets 30% of space) */
|
|
325
|
-
ratio: number;
|
|
326
|
-
/** Split direction: "horizontal" (below) or "vertical" (side-by-side). Default: horizontal */
|
|
327
|
-
direction?: string | null;
|
|
328
|
-
/** If set and panel exists, update content instead of creating new buffer */
|
|
329
|
-
panel_id?: string | null;
|
|
330
|
-
/** Show line numbers gutter (default: true) */
|
|
331
|
-
show_line_numbers?: boolean | null;
|
|
332
|
-
/** Show cursor in buffer (default: true) */
|
|
333
|
-
show_cursors?: boolean | null;
|
|
334
|
-
/** Disable all editing commands (default: false) */
|
|
335
|
-
editing_disabled?: boolean | null;
|
|
336
|
-
/** Enable/disable line wrapping (None = use global setting) */
|
|
337
|
-
line_wrap?: boolean | null;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/** Options for creating a virtual buffer in an existing split */
|
|
341
|
-
interface CreateVirtualBufferInExistingSplitOptions {
|
|
342
|
-
/** Display name (e.g., "*Commit Details*") */
|
|
343
|
-
name: string;
|
|
344
|
-
/** Mode name for buffer-local keybindings */
|
|
345
|
-
mode: string;
|
|
346
|
-
/** Whether the buffer is read-only */
|
|
347
|
-
read_only: boolean;
|
|
348
|
-
/** Entries with text and embedded properties */
|
|
349
|
-
entries: TextPropertyEntry[];
|
|
350
|
-
/** Target split ID where the buffer should be displayed */
|
|
351
|
-
split_id: number;
|
|
352
|
-
/** Whether to show line numbers in the buffer (default true) */
|
|
353
|
-
show_line_numbers?: boolean | null;
|
|
354
|
-
/** Whether to show cursors in the buffer (default true) */
|
|
355
|
-
show_cursors?: boolean | null;
|
|
356
|
-
/** Whether editing is disabled for this buffer (default false) */
|
|
357
|
-
editing_disabled?: boolean | null;
|
|
358
|
-
/** Enable/disable line wrapping (None = use global setting) */
|
|
359
|
-
line_wrap?: boolean | null;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/** Options for creating a virtual buffer in the current split as a new tab */
|
|
363
|
-
interface CreateVirtualBufferInCurrentSplitOptions {
|
|
364
|
-
/** Display name (e.g., "*Help*") */
|
|
365
|
-
name: string;
|
|
366
|
-
/** Mode name for buffer-local keybindings */
|
|
367
|
-
mode: string;
|
|
368
|
-
/** Whether the buffer is read-only */
|
|
369
|
-
read_only: boolean;
|
|
370
|
-
/** Entries with text and embedded properties */
|
|
371
|
-
entries: TextPropertyEntry[];
|
|
372
|
-
/** Whether to show line numbers in the buffer (default false for help/docs) */
|
|
373
|
-
show_line_numbers?: boolean | null;
|
|
374
|
-
/** Whether to show cursors in the buffer (default true) */
|
|
375
|
-
show_cursors?: boolean | null;
|
|
376
|
-
/** Whether editing is disabled for this buffer (default false) */
|
|
377
|
-
editing_disabled?: boolean | null;
|
|
378
|
-
/** Whether this buffer should be hidden from tabs (for composite source buffers) */
|
|
379
|
-
hidden_from_tabs?: boolean | null;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/** Layout configuration for composite buffers */
|
|
383
|
-
interface TsCompositeLayoutConfig {
|
|
384
|
-
/** Layout type: "side-by-side", "stacked", or "unified" */
|
|
385
|
-
layout_type: string;
|
|
386
|
-
/** Relative widths for side-by-side layout (e.g., [0.5, 0.5]) */
|
|
387
|
-
ratios?: number[] | null;
|
|
388
|
-
/** Show separator between panes */
|
|
389
|
-
show_separator?: boolean | null;
|
|
390
|
-
/** Spacing between stacked panes */
|
|
391
|
-
spacing?: number | null;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/** Pane style configuration */
|
|
395
|
-
interface TsCompositePaneStyle {
|
|
396
|
-
/** Background color for added lines (RGB tuple) */
|
|
397
|
-
add_bg?: [number, number, number] | null;
|
|
398
|
-
/** Background color for removed lines (RGB tuple) */
|
|
399
|
-
remove_bg?: [number, number, number] | null;
|
|
400
|
-
/** Background color for modified lines (RGB tuple) */
|
|
401
|
-
modify_bg?: [number, number, number] | null;
|
|
402
|
-
/** Gutter style: "line-numbers", "diff-markers", "both", "none" */
|
|
403
|
-
gutter_style?: string | null;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/** Source pane configuration for composite buffers */
|
|
407
|
-
interface TsCompositeSourceConfig {
|
|
408
|
-
/** Buffer ID to display in this pane */
|
|
409
|
-
buffer_id: number;
|
|
410
|
-
/** Label for the pane (shown in header) */
|
|
411
|
-
label?: string | null;
|
|
412
|
-
/** Whether the pane is editable */
|
|
413
|
-
editable: boolean;
|
|
414
|
-
/** Pane styling options */
|
|
415
|
-
style?: TsCompositePaneStyle | null;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/** Diff hunk configuration */
|
|
419
|
-
interface TsCompositeHunk {
|
|
420
|
-
/** Start line in old file (0-indexed) */
|
|
421
|
-
old_start: number;
|
|
422
|
-
/** Number of lines in old file */
|
|
423
|
-
old_count: number;
|
|
424
|
-
/** Start line in new file (0-indexed) */
|
|
425
|
-
new_start: number;
|
|
426
|
-
/** Number of lines in new file */
|
|
427
|
-
new_count: number;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/** Options for creating a composite buffer */
|
|
431
|
-
interface CreateCompositeBufferOptions {
|
|
432
|
-
/** Display name for the composite buffer (shown in tab) */
|
|
433
|
-
name: string;
|
|
434
|
-
/** Mode for keybindings (e.g., "diff-view") */
|
|
435
|
-
mode: string;
|
|
436
|
-
/** Layout configuration */
|
|
437
|
-
layout: TsCompositeLayoutConfig;
|
|
438
|
-
/** Source panes to display */
|
|
439
|
-
sources: TsCompositeSourceConfig[];
|
|
440
|
-
/** Optional diff hunks for line alignment */
|
|
441
|
-
hunks?: TsCompositeHunk[] | null;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
/** JavaScript representation of ActionSpec (with optional count) */
|
|
445
|
-
interface ActionSpecJs {
|
|
446
|
-
action: string;
|
|
447
|
-
count?: number | null;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
/** TypeScript struct for action popup action */
|
|
451
|
-
interface TsActionPopupAction {
|
|
452
|
-
id: string;
|
|
453
|
-
label: string;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
/** TypeScript struct for action popup options */
|
|
457
|
-
interface TsActionPopupOptions {
|
|
458
|
-
id: string;
|
|
459
|
-
title: string;
|
|
460
|
-
message: string;
|
|
461
|
-
actions: TsActionPopupAction[];
|
|
462
|
-
}
|
|
463
|
-
|
|
28
|
+
/** Split identifier */
|
|
29
|
+
type SplitId = number;
|
|
30
|
+
type TextPropertyEntry = {
|
|
31
|
+
/**
|
|
32
|
+
* Text content for this entry
|
|
33
|
+
*/
|
|
34
|
+
text: string;
|
|
35
|
+
/**
|
|
36
|
+
* Optional properties attached to this text (e.g., file path, line number)
|
|
37
|
+
*/
|
|
38
|
+
properties?: Record<string, unknown>;
|
|
39
|
+
};
|
|
40
|
+
type BackgroundProcessResult = {
|
|
41
|
+
/**
|
|
42
|
+
* Unique process ID for later reference
|
|
43
|
+
*/
|
|
44
|
+
process_id: number;
|
|
45
|
+
/**
|
|
46
|
+
* Process exit code (0 usually means success, -1 if killed)
|
|
47
|
+
* Only present when the process has exited
|
|
48
|
+
*/
|
|
49
|
+
exit_code: number;
|
|
50
|
+
};
|
|
51
|
+
type BufferSavedDiff = {
|
|
52
|
+
equal: boolean;
|
|
53
|
+
byte_ranges: Array<[number, number]>;
|
|
54
|
+
line_ranges: Array<[number, number]> | null;
|
|
55
|
+
};
|
|
56
|
+
type CreateVirtualBufferInExistingSplitOptions = {
|
|
57
|
+
/**
|
|
58
|
+
* Buffer name (displayed in tabs/title)
|
|
59
|
+
*/
|
|
60
|
+
name: string;
|
|
61
|
+
/**
|
|
62
|
+
* Target split ID (required)
|
|
63
|
+
*/
|
|
64
|
+
splitId: number;
|
|
65
|
+
/**
|
|
66
|
+
* Mode for keybindings (e.g., "git-log", "search-results")
|
|
67
|
+
*/
|
|
68
|
+
mode?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Whether buffer is read-only (default: false)
|
|
71
|
+
*/
|
|
72
|
+
readOnly?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Show line numbers in gutter (default: true)
|
|
75
|
+
*/
|
|
76
|
+
showLineNumbers?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Show cursor (default: true)
|
|
79
|
+
*/
|
|
80
|
+
showCursors?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Disable text editing (default: false)
|
|
83
|
+
*/
|
|
84
|
+
editingDisabled?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Enable line wrapping
|
|
87
|
+
*/
|
|
88
|
+
lineWrap?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Initial content entries with optional properties
|
|
91
|
+
*/
|
|
92
|
+
entries?: Array<TextPropertyEntry>;
|
|
93
|
+
};
|
|
94
|
+
type CreateVirtualBufferInSplitOptions = {
|
|
95
|
+
/**
|
|
96
|
+
* Buffer name (displayed in tabs/title)
|
|
97
|
+
*/
|
|
98
|
+
name: string;
|
|
99
|
+
/**
|
|
100
|
+
* Mode for keybindings (e.g., "git-log", "search-results")
|
|
101
|
+
*/
|
|
102
|
+
mode?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Whether buffer is read-only (default: false)
|
|
105
|
+
*/
|
|
106
|
+
readOnly?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Split ratio 0.0-1.0 (default: 0.5)
|
|
109
|
+
*/
|
|
110
|
+
ratio?: number;
|
|
111
|
+
/**
|
|
112
|
+
* Split direction: "horizontal" or "vertical"
|
|
113
|
+
*/
|
|
114
|
+
direction?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Panel ID to split from
|
|
117
|
+
*/
|
|
118
|
+
panelId?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Show line numbers in gutter (default: true)
|
|
121
|
+
*/
|
|
122
|
+
showLineNumbers?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Show cursor (default: true)
|
|
125
|
+
*/
|
|
126
|
+
showCursors?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Disable text editing (default: false)
|
|
129
|
+
*/
|
|
130
|
+
editingDisabled?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Enable line wrapping
|
|
133
|
+
*/
|
|
134
|
+
lineWrap?: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Initial content entries with optional properties
|
|
137
|
+
*/
|
|
138
|
+
entries?: Array<TextPropertyEntry>;
|
|
139
|
+
};
|
|
140
|
+
type CreateVirtualBufferOptions = {
|
|
141
|
+
/**
|
|
142
|
+
* Buffer name (displayed in tabs/title)
|
|
143
|
+
*/
|
|
144
|
+
name: string;
|
|
145
|
+
/**
|
|
146
|
+
* Mode for keybindings (e.g., "git-log", "search-results")
|
|
147
|
+
*/
|
|
148
|
+
mode?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Whether buffer is read-only (default: false)
|
|
151
|
+
*/
|
|
152
|
+
readOnly?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Show line numbers in gutter (default: false)
|
|
155
|
+
*/
|
|
156
|
+
showLineNumbers?: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Show cursor (default: true)
|
|
159
|
+
*/
|
|
160
|
+
showCursors?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Disable text editing (default: false)
|
|
163
|
+
*/
|
|
164
|
+
editingDisabled?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Hide from tab bar (default: false)
|
|
167
|
+
*/
|
|
168
|
+
hiddenFromTabs?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Initial content entries with optional properties
|
|
171
|
+
*/
|
|
172
|
+
entries?: Array<TextPropertyEntry>;
|
|
173
|
+
};
|
|
174
|
+
type SpawnResult = {
|
|
175
|
+
/**
|
|
176
|
+
* Complete stdout as string
|
|
177
|
+
*/
|
|
178
|
+
stdout: string;
|
|
179
|
+
/**
|
|
180
|
+
* Complete stderr as string
|
|
181
|
+
*/
|
|
182
|
+
stderr: string;
|
|
183
|
+
/**
|
|
184
|
+
* Process exit code (0 usually means success, -1 if killed)
|
|
185
|
+
*/
|
|
186
|
+
exit_code: number;
|
|
187
|
+
};
|
|
188
|
+
type TextPropertiesAtCursor = Array<Record<string, unknown>>;
|
|
189
|
+
type TsHighlightSpan = {
|
|
190
|
+
start: number;
|
|
191
|
+
end: number;
|
|
192
|
+
color: [number, number, number];
|
|
193
|
+
bold: boolean;
|
|
194
|
+
italic: boolean;
|
|
195
|
+
};
|
|
464
196
|
/**
|
|
465
|
-
|
|
466
|
-
|
|
197
|
+
* Main editor API interface
|
|
198
|
+
*/
|
|
467
199
|
interface EditorAPI {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
* @returns Promise resolving to the buffer ID of the created composite buffer
|
|
918
|
-
*/
|
|
919
|
-
createCompositeBuffer(options: CreateCompositeBufferOptions): Promise<number>;
|
|
920
|
-
/**
|
|
921
|
-
* Update line alignment for a composite buffer
|
|
922
|
-
* @param buffer_id - The composite buffer ID
|
|
923
|
-
* @param hunks - New diff hunks for alignment
|
|
924
|
-
*/
|
|
925
|
-
updateCompositeAlignment(buffer_id: number, hunks: TsCompositeHunk[]): boolean;
|
|
926
|
-
/**
|
|
927
|
-
* Close a composite buffer
|
|
928
|
-
* @param buffer_id - The composite buffer ID to close
|
|
929
|
-
*/
|
|
930
|
-
closeCompositeBuffer(buffer_id: number): boolean;
|
|
931
|
-
/**
|
|
932
|
-
* Send an arbitrary LSP request and receive the raw JSON response
|
|
933
|
-
* @param language - Language ID (e.g., "cpp")
|
|
934
|
-
* @param method - Full LSP method (e.g., "textDocument/switchSourceHeader")
|
|
935
|
-
* @param params - Optional request payload
|
|
936
|
-
* @returns Promise resolving to the JSON response value
|
|
937
|
-
*/
|
|
938
|
-
sendLspRequest(language: string, method: string, params?: unknown | null): Promise<unknown>;
|
|
939
|
-
/**
|
|
940
|
-
* Set the scroll position of a specific split
|
|
941
|
-
* @param split_id - The split ID
|
|
942
|
-
* @param top_byte - The byte offset of the top visible line
|
|
943
|
-
* @returns true if successful
|
|
944
|
-
*/
|
|
945
|
-
setSplitScroll(split_id: number, top_byte: number): boolean;
|
|
946
|
-
/**
|
|
947
|
-
* Set the ratio of a split container
|
|
948
|
-
* @param split_id - ID of the split
|
|
949
|
-
* @param ratio - Ratio between 0.0 and 1.0 (0.5 = equal split)
|
|
950
|
-
* @returns true if the ratio was set successfully
|
|
951
|
-
*/
|
|
952
|
-
setSplitRatio(split_id: number, ratio: number): boolean;
|
|
953
|
-
/**
|
|
954
|
-
* Distribute all visible splits evenly
|
|
955
|
-
* This adjusts the ratios of all container splits so each leaf split gets equal space
|
|
956
|
-
* @returns true if the command was sent successfully
|
|
957
|
-
*/
|
|
958
|
-
distributeSplitsEvenly(): boolean;
|
|
959
|
-
/**
|
|
960
|
-
* Set cursor position in a buffer (also scrolls viewport to show cursor)
|
|
961
|
-
* @param buffer_id - ID of the buffer
|
|
962
|
-
* @param position - Byte offset position for the cursor
|
|
963
|
-
* @returns true if the command was sent successfully
|
|
964
|
-
*/
|
|
965
|
-
setBufferCursor(buffer_id: number, position: number): boolean;
|
|
966
|
-
/**
|
|
967
|
-
* Execute a built-in editor action by name
|
|
968
|
-
*
|
|
969
|
-
* This is used by vi mode plugin to run motions and then check cursor position.
|
|
970
|
-
* For example, to implement "dw" (delete word), the plugin:
|
|
971
|
-
* 1. Saves current cursor position
|
|
972
|
-
* 2. Calls executeAction("move_word_right") - cursor moves
|
|
973
|
-
* 3. Gets new cursor position
|
|
974
|
-
* 4. Deletes from old to new position
|
|
975
|
-
*
|
|
976
|
-
* @param action_name - Action name (e.g., "move_word_right", "move_line_end")
|
|
977
|
-
* @returns true if action was sent successfully
|
|
978
|
-
*/
|
|
979
|
-
executeAction(action_name: string): boolean;
|
|
980
|
-
/**
|
|
981
|
-
* Execute multiple actions in sequence, each with an optional repeat count
|
|
982
|
-
*
|
|
983
|
-
* Used by vi mode for count prefix (e.g., "3dw" = delete 3 words).
|
|
984
|
-
* All actions execute atomically with no plugin roundtrips between them.
|
|
985
|
-
*
|
|
986
|
-
* @param actions - Array of {action: string, count?: number} objects
|
|
987
|
-
* @returns true if actions were sent successfully
|
|
988
|
-
*/
|
|
989
|
-
executeActions(actions: ActionSpecJs[]): boolean;
|
|
990
|
-
/**
|
|
991
|
-
* Set the global editor mode (for modal editing like vi mode)
|
|
992
|
-
*
|
|
993
|
-
* When a mode is set, its keybindings take precedence over normal key handling.
|
|
994
|
-
* Pass null/undefined to clear the mode and return to normal editing.
|
|
995
|
-
*
|
|
996
|
-
* @param mode - Mode name (e.g., "vi-normal") or null to clear
|
|
997
|
-
* @returns true if command was sent successfully
|
|
998
|
-
*/
|
|
999
|
-
setEditorMode(mode?: string | null): boolean;
|
|
1000
|
-
/**
|
|
1001
|
-
* Show an action popup with buttons for user interaction
|
|
1002
|
-
*
|
|
1003
|
-
* When the user selects an action, the ActionPopupResult hook is fired.
|
|
1004
|
-
* @param options - Popup configuration with id, title, message, and actions
|
|
1005
|
-
*/
|
|
1006
|
-
showActionPopup(options: TsActionPopupOptions): boolean;
|
|
1007
|
-
/**
|
|
1008
|
-
* Disable LSP for a specific language and persist to config
|
|
1009
|
-
*
|
|
1010
|
-
* This is used by LSP helper plugins to let users disable LSP for languages
|
|
1011
|
-
* where the server is not available or not working.
|
|
1012
|
-
* @param language - The language to disable LSP for (e.g., "python", "rust")
|
|
1013
|
-
*/
|
|
1014
|
-
disableLspForLanguage(language: string): boolean;
|
|
1015
|
-
/**
|
|
1016
|
-
* Create a scroll sync group for anchor-based synchronized scrolling
|
|
1017
|
-
*
|
|
1018
|
-
* Used for side-by-side diff views where two panes need to scroll together.
|
|
1019
|
-
* The plugin provides the group ID (must be unique per plugin).
|
|
1020
|
-
*/
|
|
1021
|
-
createScrollSyncGroup(group_id: number, left_split: number, right_split: number): boolean;
|
|
1022
|
-
/**
|
|
1023
|
-
* Set sync anchors for a scroll sync group
|
|
1024
|
-
*
|
|
1025
|
-
* Anchors map corresponding line numbers between left and right buffers.
|
|
1026
|
-
* Each anchor is a tuple of (left_line, right_line).
|
|
1027
|
-
*/
|
|
1028
|
-
setScrollSyncAnchors(group_id: number, anchors: [number, number][]): boolean;
|
|
1029
|
-
/** Remove a scroll sync group */
|
|
1030
|
-
removeScrollSyncGroup(group_id: number): boolean;
|
|
1031
|
-
|
|
1032
|
-
/**
|
|
1033
|
-
* Spawn an external process and return a cancellable handle
|
|
1034
|
-
*
|
|
1035
|
-
* Returns a ProcessHandle that can be awaited for the result or killed early.
|
|
1036
|
-
* The handle is also a PromiseLike, so `await spawnProcess(...)` works directly.
|
|
1037
|
-
* @param command - Program name (searched in PATH) or absolute path
|
|
1038
|
-
* @param args - Command arguments (each array element is one argument)
|
|
1039
|
-
* @param cwd - Working directory; null uses editor's cwd
|
|
1040
|
-
* @example
|
|
1041
|
-
* // Simple usage (backward compatible)
|
|
1042
|
-
* const result = await editor.spawnProcess("git", ["status"]);
|
|
1043
|
-
*
|
|
1044
|
-
* // Cancellable usage
|
|
1045
|
-
* const search = editor.spawnProcess("rg", ["pattern"]);
|
|
1046
|
-
* // ... later, if user types new query:
|
|
1047
|
-
* search.kill(); // Cancel the search
|
|
1048
|
-
*/
|
|
1049
|
-
spawnProcess(command: string, args?: string[], cwd?: string | null): ProcessHandle;
|
|
1050
|
-
// === Overlay Operations ===
|
|
1051
|
-
/**
|
|
1052
|
-
* Add a colored highlight overlay to text without modifying content
|
|
1053
|
-
*
|
|
1054
|
-
* Overlays are visual decorations that persist until explicitly removed.
|
|
1055
|
-
* Add an overlay (visual decoration) to a buffer
|
|
1056
|
-
* Use namespaces for easy batch removal (e.g., "spell", "todo").
|
|
1057
|
-
* Multiple overlays can apply to the same range; colors blend.
|
|
1058
|
-
* @param buffer_id - Target buffer ID
|
|
1059
|
-
* @param namespace - Optional namespace for grouping (use clearNamespace for batch removal)
|
|
1060
|
-
* @param start - Start byte offset
|
|
1061
|
-
* @param end - End byte offset
|
|
1062
|
-
* @param r - Red (0-255)
|
|
1063
|
-
* @param g - Green (0-255)
|
|
1064
|
-
* @param b - Blue (0-255)
|
|
1065
|
-
* @param underline - Add underline decoration
|
|
1066
|
-
* @param bold - Use bold text
|
|
1067
|
-
* @param italic - Use italic text
|
|
1068
|
-
* @param extend_to_line_end - Extend background to end of visual line
|
|
1069
|
-
* @returns true if overlay was added
|
|
1070
|
-
*/
|
|
1071
|
-
addOverlay(buffer_id: number, namespace: string, start: number, end: number, r: number, g: number, b: number, bg_r: number, bg_g: number, bg_b: number, underline: boolean, bold: boolean, italic: boolean, extend_to_line_end: boolean): boolean;
|
|
1072
|
-
/**
|
|
1073
|
-
* Remove a specific overlay by its handle
|
|
1074
|
-
* @param buffer_id - The buffer ID
|
|
1075
|
-
* @param handle - The overlay handle to remove
|
|
1076
|
-
* @returns true if overlay was removed
|
|
1077
|
-
*/
|
|
1078
|
-
removeOverlay(buffer_id: number, handle: string): boolean;
|
|
1079
|
-
/**
|
|
1080
|
-
* Clear all overlays that overlap with a byte range
|
|
1081
|
-
* @param buffer_id - The buffer ID
|
|
1082
|
-
* @param start - Start byte position (inclusive)
|
|
1083
|
-
* @param end - End byte position (exclusive)
|
|
1084
|
-
* @returns true if successful
|
|
1085
|
-
*/
|
|
1086
|
-
clearOverlaysInRange(buffer_id: number, start: number, end: number): boolean;
|
|
1087
|
-
/**
|
|
1088
|
-
* Remove all overlays from a buffer
|
|
1089
|
-
* @param buffer_id - The buffer ID
|
|
1090
|
-
* @returns true if overlays were cleared
|
|
1091
|
-
*/
|
|
1092
|
-
clearAllOverlays(buffer_id: number): boolean;
|
|
1093
|
-
/**
|
|
1094
|
-
* Add virtual text (inline decoration) at a position
|
|
1095
|
-
* @param buffer_id - The buffer ID
|
|
1096
|
-
* @param virtual_text_id - Unique identifier for this virtual text
|
|
1097
|
-
* @param position - Byte position to insert at
|
|
1098
|
-
* @param text - The virtual text to display
|
|
1099
|
-
* @param r - Red color component (0-255)
|
|
1100
|
-
* @param g - Green color component (0-255)
|
|
1101
|
-
* @param b - Blue color component (0-255)
|
|
1102
|
-
* @param before - Whether to insert before (true) or after (false) the position
|
|
1103
|
-
* @param use_bg - Whether to use the color as background (true) or foreground (false)
|
|
1104
|
-
* @returns true if virtual text was added
|
|
1105
|
-
*/
|
|
1106
|
-
addVirtualText(buffer_id: number, virtual_text_id: string, position: number, text: string, r: number, g: number, b: number, before: boolean, use_bg: boolean): boolean;
|
|
1107
|
-
/**
|
|
1108
|
-
* Remove virtual text by ID
|
|
1109
|
-
* @param buffer_id - The buffer ID
|
|
1110
|
-
* @param virtual_text_id - The virtual text ID to remove
|
|
1111
|
-
* @returns true if virtual text was removed
|
|
1112
|
-
*/
|
|
1113
|
-
removeVirtualText(buffer_id: number, virtual_text_id: string): boolean;
|
|
1114
|
-
/**
|
|
1115
|
-
* Remove all virtual texts with IDs starting with a prefix
|
|
1116
|
-
* @param buffer_id - The buffer ID
|
|
1117
|
-
* @param prefix - The prefix to match virtual text IDs against
|
|
1118
|
-
* @returns true if any virtual texts were removed
|
|
1119
|
-
*/
|
|
1120
|
-
removeVirtualTextsByPrefix(buffer_id: number, prefix: string): boolean;
|
|
1121
|
-
/**
|
|
1122
|
-
* Remove all virtual texts from a buffer
|
|
1123
|
-
* @param buffer_id - The buffer ID
|
|
1124
|
-
* @returns true if virtual texts were cleared
|
|
1125
|
-
*/
|
|
1126
|
-
clearVirtualTexts(buffer_id: number): boolean;
|
|
1127
|
-
/**
|
|
1128
|
-
* Clear all virtual texts in a namespace
|
|
1129
|
-
* @param buffer_id - The buffer ID
|
|
1130
|
-
* @param namespace - The namespace to clear (e.g., "git-blame")
|
|
1131
|
-
* @returns true if namespace was cleared
|
|
1132
|
-
*/
|
|
1133
|
-
clearVirtualTextNamespace(buffer_id: number, namespace: string): boolean;
|
|
1134
|
-
/**
|
|
1135
|
-
* Force a refresh of line display for a buffer
|
|
1136
|
-
* @param buffer_id - The buffer ID
|
|
1137
|
-
* @returns true if refresh was triggered
|
|
1138
|
-
*/
|
|
1139
|
-
refreshLines(buffer_id: number): boolean;
|
|
1140
|
-
|
|
1141
|
-
// === File System Operations ===
|
|
1142
|
-
/**
|
|
1143
|
-
* Read entire file contents as UTF-8 string
|
|
1144
|
-
*
|
|
1145
|
-
* Throws if file doesn't exist, isn't readable, or isn't valid UTF-8.
|
|
1146
|
-
* For binary files, this will fail. For large files, consider memory usage.
|
|
1147
|
-
* @param path - File path (absolute or relative to cwd)
|
|
1148
|
-
*/
|
|
1149
|
-
readFile(path: string): Promise<string>;
|
|
1150
|
-
/**
|
|
1151
|
-
* Write string content to a NEW file (fails if file exists)
|
|
1152
|
-
*
|
|
1153
|
-
* Creates a new file with the given content. Fails if the file already exists
|
|
1154
|
-
* to prevent plugins from accidentally overwriting user data.
|
|
1155
|
-
* @param path - Destination path (absolute or relative to cwd)
|
|
1156
|
-
* @param content - UTF-8 string to write
|
|
1157
|
-
*/
|
|
1158
|
-
writeFile(path: string, content: string): Promise<void>;
|
|
1159
|
-
/**
|
|
1160
|
-
* Check if a path exists (file, directory, or symlink)
|
|
1161
|
-
*
|
|
1162
|
-
* Does not follow symlinks; returns true for broken symlinks.
|
|
1163
|
-
* Use fileStat for more detailed information.
|
|
1164
|
-
* @param path - Path to check (absolute or relative to cwd)
|
|
1165
|
-
*/
|
|
1166
|
-
fileExists(path: string): boolean;
|
|
1167
|
-
/**
|
|
1168
|
-
* Get metadata about a file or directory
|
|
1169
|
-
*
|
|
1170
|
-
* Follows symlinks. Returns exists=false for non-existent paths
|
|
1171
|
-
* rather than throwing. Size is in bytes; directories may report 0.
|
|
1172
|
-
* @param path - Path to stat (absolute or relative to cwd)
|
|
1173
|
-
*/
|
|
1174
|
-
fileStat(path: string): FileStat;
|
|
1175
|
-
/**
|
|
1176
|
-
* List directory contents
|
|
1177
|
-
*
|
|
1178
|
-
* Returns unsorted entries with type info. Entry names are relative
|
|
1179
|
-
* to the directory (use pathJoin to construct full paths).
|
|
1180
|
-
* Throws on permission errors or if path is not a directory.
|
|
1181
|
-
* @param path - Directory path (absolute or relative to cwd)
|
|
1182
|
-
* @example
|
|
1183
|
-
* const entries = editor.readDir("/home/user");
|
|
1184
|
-
* for (const e of entries) {
|
|
1185
|
-
* const fullPath = editor.pathJoin("/home/user", e.name);
|
|
1186
|
-
* }
|
|
1187
|
-
*/
|
|
1188
|
-
readDir(path: string): DirEntry[];
|
|
1189
|
-
|
|
1190
|
-
// === Environment Operations ===
|
|
1191
|
-
/**
|
|
1192
|
-
* Get an environment variable
|
|
1193
|
-
* @param name - Name of environment variable
|
|
1194
|
-
* @returns Value if set, null if not set
|
|
1195
|
-
*/
|
|
1196
|
-
getEnv(name: string): string;
|
|
1197
|
-
/**
|
|
1198
|
-
* Get the editor's current working directory
|
|
1199
|
-
*
|
|
1200
|
-
* Returns the editor's working directory (set when the editor was started).
|
|
1201
|
-
* Use as base for resolving relative paths and spawning processes.
|
|
1202
|
-
* Note: This returns the editor's stored working_dir, not process CWD,
|
|
1203
|
-
* which is important for test isolation.
|
|
1204
|
-
*/
|
|
1205
|
-
getCwd(): string;
|
|
1206
|
-
|
|
1207
|
-
// === Path Operations ===
|
|
1208
|
-
/**
|
|
1209
|
-
* Join path segments using the OS path separator
|
|
1210
|
-
*
|
|
1211
|
-
* Handles empty segments and normalizes separators.
|
|
1212
|
-
* If a segment is absolute, previous segments are discarded.
|
|
1213
|
-
* @param parts - Path segments to join
|
|
1214
|
-
* @example
|
|
1215
|
-
* pathJoin("/home", "user", "file.txt") // "/home/user/file.txt"
|
|
1216
|
-
* pathJoin("relative", "/absolute") // "/absolute"
|
|
1217
|
-
*/
|
|
1218
|
-
pathJoin(parts: string[]): string;
|
|
1219
|
-
/**
|
|
1220
|
-
* Get the parent directory of a path
|
|
1221
|
-
*
|
|
1222
|
-
* Returns empty string for root paths or paths without parent.
|
|
1223
|
-
* Does not resolve symlinks or check existence.
|
|
1224
|
-
* @param path - File or directory path
|
|
1225
|
-
* @example
|
|
1226
|
-
* pathDirname("/home/user/file.txt") // "/home/user"
|
|
1227
|
-
* pathDirname("/") // ""
|
|
1228
|
-
*/
|
|
1229
|
-
pathDirname(path: string): string;
|
|
1230
|
-
/**
|
|
1231
|
-
* Get the final component of a path
|
|
1232
|
-
*
|
|
1233
|
-
* Returns empty string for root paths.
|
|
1234
|
-
* Does not strip file extension; use pathExtname for that.
|
|
1235
|
-
* @param path - File or directory path
|
|
1236
|
-
* @example
|
|
1237
|
-
* pathBasename("/home/user/file.txt") // "file.txt"
|
|
1238
|
-
* pathBasename("/home/user/") // "user"
|
|
1239
|
-
*/
|
|
1240
|
-
pathBasename(path: string): string;
|
|
1241
|
-
/**
|
|
1242
|
-
* Get the file extension including the dot
|
|
1243
|
-
*
|
|
1244
|
-
* Returns empty string if no extension. Only returns the last extension
|
|
1245
|
-
* for files like "archive.tar.gz" (returns ".gz").
|
|
1246
|
-
* @param path - File path
|
|
1247
|
-
* @example
|
|
1248
|
-
* pathExtname("file.txt") // ".txt"
|
|
1249
|
-
* pathExtname("archive.tar.gz") // ".gz"
|
|
1250
|
-
* pathExtname("Makefile") // ""
|
|
1251
|
-
*/
|
|
1252
|
-
pathExtname(path: string): string;
|
|
1253
|
-
/**
|
|
1254
|
-
* Check if a path is absolute
|
|
1255
|
-
*
|
|
1256
|
-
* On Unix: starts with "/". On Windows: starts with drive letter or UNC path.
|
|
1257
|
-
* @param path - Path to check
|
|
1258
|
-
*/
|
|
1259
|
-
pathIsAbsolute(path: string): boolean;
|
|
1260
|
-
|
|
1261
|
-
// === Event/Hook Operations ===
|
|
1262
|
-
/**
|
|
1263
|
-
* Subscribe to an editor event
|
|
1264
|
-
*
|
|
1265
|
-
* Handler must be a global function name (not a closure).
|
|
1266
|
-
* Multiple handlers can be registered for the same event.
|
|
1267
|
-
* Events: "buffer_save", "cursor_moved", "buffer_modified", etc.
|
|
1268
|
-
* @param event_name - Event to subscribe to
|
|
1269
|
-
* @param handler_name - Name of globalThis function to call with event data
|
|
1270
|
-
* @example
|
|
1271
|
-
* globalThis.onSave = (data) => {
|
|
1272
|
-
* editor.setStatus(`Saved: ${data.path}`);
|
|
1273
|
-
* };
|
|
1274
|
-
* editor.on("buffer_save", "onSave");
|
|
1275
|
-
*/
|
|
1276
|
-
on(event_name: string, handler_name: string): boolean;
|
|
1277
|
-
/**
|
|
1278
|
-
* Unregister an event handler
|
|
1279
|
-
* @param event_name - Name of the event
|
|
1280
|
-
* @param handler_name - Name of the handler to remove
|
|
1281
|
-
* @returns true if handler was found and removed
|
|
1282
|
-
*/
|
|
1283
|
-
off(event_name: string, handler_name: string): boolean;
|
|
1284
|
-
/**
|
|
1285
|
-
* Get list of registered handlers for an event
|
|
1286
|
-
* @param event_name - Name of the event
|
|
1287
|
-
* @returns Array of handler function names
|
|
1288
|
-
*/
|
|
1289
|
-
getHandlers(event_name: string): string[];
|
|
1290
|
-
|
|
1291
|
-
// === Virtual Buffer Operations ===
|
|
1292
|
-
/**
|
|
1293
|
-
* Create a virtual buffer in a new horizontal split below current pane
|
|
1294
|
-
*
|
|
1295
|
-
* Use for results panels, diagnostics, logs, etc. The panel_id enables
|
|
1296
|
-
* idempotent updates: if a panel with that ID exists, its content is replaced
|
|
1297
|
-
* instead of creating a new split. Define the mode with defineMode first.
|
|
1298
|
-
* @param options - Buffer configuration
|
|
1299
|
-
* @example
|
|
1300
|
-
* // First define the mode with keybindings
|
|
1301
|
-
* editor.defineMode("search-results", "special", [
|
|
1302
|
-
* ["Return", "search_goto"],
|
|
1303
|
-
* ["q", "close_buffer"]
|
|
1304
|
-
* ], true);
|
|
1305
|
-
*
|
|
1306
|
-
* // Then create the buffer
|
|
1307
|
-
* const id = await editor.createVirtualBufferInSplit({
|
|
1308
|
-
* name: "*Search*",
|
|
1309
|
-
* mode: "search-results",
|
|
1310
|
-
* read_only: true,
|
|
1311
|
-
* entries: [
|
|
1312
|
-
* { text: "src/main.rs:42: match\n", properties: { file: "src/main.rs", line: 42 } }
|
|
1313
|
-
* ],
|
|
1314
|
-
* ratio: 0.3,
|
|
1315
|
-
* panel_id: "search"
|
|
1316
|
-
* });
|
|
1317
|
-
*/
|
|
1318
|
-
createVirtualBufferInSplit(options: CreateVirtualBufferOptions): Promise<CreateVirtualBufferResult>;
|
|
1319
|
-
/**
|
|
1320
|
-
* Create a virtual buffer in an existing split
|
|
1321
|
-
* @param options - Configuration for the virtual buffer
|
|
1322
|
-
* @returns Promise resolving to the buffer ID of the created virtual buffer
|
|
1323
|
-
*/
|
|
1324
|
-
createVirtualBufferInExistingSplit(options: CreateVirtualBufferInExistingSplitOptions): Promise<number>;
|
|
1325
|
-
/**
|
|
1326
|
-
* Create a virtual buffer in the current split as a new tab
|
|
1327
|
-
* This is useful for help panels, documentation, etc. that should open
|
|
1328
|
-
* alongside other buffers rather than in a separate split.
|
|
1329
|
-
* @param options - Configuration for the virtual buffer
|
|
1330
|
-
* @returns Promise resolving to the buffer ID of the created virtual buffer
|
|
1331
|
-
*/
|
|
1332
|
-
createVirtualBuffer(options: CreateVirtualBufferInCurrentSplitOptions): Promise<number>;
|
|
1333
|
-
/**
|
|
1334
|
-
* Define a buffer mode with keybindings
|
|
1335
|
-
* @param name - Mode name (e.g., "diagnostics-list")
|
|
1336
|
-
* @param parent - Parent mode name for inheritance (e.g., "special"), or null
|
|
1337
|
-
* @param bindings - Array of [key_string, command_name] pairs
|
|
1338
|
-
* @param read_only - Whether buffers in this mode are read-only
|
|
1339
|
-
* @returns true if mode was defined successfully
|
|
1340
|
-
* @example
|
|
1341
|
-
* editor.defineMode("diagnostics-list", "special", [
|
|
1342
|
-
* ["Return", "diagnostics_goto"],
|
|
1343
|
-
* ["q", "close_buffer"]
|
|
1344
|
-
* ], true);
|
|
1345
|
-
*/
|
|
1346
|
-
defineMode(name: string, parent: string, bindings: [string, string][], read_only: boolean): boolean;
|
|
1347
|
-
/**
|
|
1348
|
-
* Switch the current split to display a buffer
|
|
1349
|
-
* @param buffer_id - ID of the buffer to show
|
|
1350
|
-
* @returns true if buffer was shown successfully
|
|
1351
|
-
*/
|
|
1352
|
-
showBuffer(buffer_id: number): boolean;
|
|
1353
|
-
/**
|
|
1354
|
-
* Close a buffer and remove it from all splits
|
|
1355
|
-
* @param buffer_id - ID of the buffer to close
|
|
1356
|
-
* @returns true if buffer was closed successfully
|
|
1357
|
-
*/
|
|
1358
|
-
closeBuffer(buffer_id: number): boolean;
|
|
1359
|
-
/**
|
|
1360
|
-
* Focus a specific split
|
|
1361
|
-
* @param split_id - ID of the split to focus
|
|
1362
|
-
* @returns true if split was focused successfully
|
|
1363
|
-
*/
|
|
1364
|
-
focusSplit(split_id: number): boolean;
|
|
1365
|
-
/**
|
|
1366
|
-
* Set the buffer displayed in a specific split
|
|
1367
|
-
* @param split_id - ID of the split
|
|
1368
|
-
* @param buffer_id - ID of the buffer to display in the split
|
|
1369
|
-
* @returns true if the buffer was set successfully
|
|
1370
|
-
*/
|
|
1371
|
-
setSplitBuffer(split_id: number, buffer_id: number): boolean;
|
|
1372
|
-
/**
|
|
1373
|
-
* Close a split (if not the last one)
|
|
1374
|
-
* @param split_id - ID of the split to close
|
|
1375
|
-
* @returns true if the split was closed successfully
|
|
1376
|
-
*/
|
|
1377
|
-
closeSplit(split_id: number): boolean;
|
|
1378
|
-
/**
|
|
1379
|
-
* Get text properties at the cursor position in a buffer
|
|
1380
|
-
* @param buffer_id - ID of the buffer to query
|
|
1381
|
-
* @returns Array of property objects for text ranges containing the cursor
|
|
1382
|
-
* @example
|
|
1383
|
-
* const props = editor.getTextPropertiesAtCursor(bufferId);
|
|
1384
|
-
* if (props.length > 0 && props[0].location) {
|
|
1385
|
-
* editor.openFile(props[0].location.file, props[0].location.line, 0);
|
|
1386
|
-
* }
|
|
1387
|
-
*/
|
|
1388
|
-
getTextPropertiesAtCursor(buffer_id: number): Record<string, unknown>[];
|
|
1389
|
-
/**
|
|
1390
|
-
* Set the content of a virtual buffer with text properties
|
|
1391
|
-
* @param buffer_id - ID of the virtual buffer
|
|
1392
|
-
* @param entries - Array of text entries with properties
|
|
1393
|
-
* @returns true if content was set successfully
|
|
1394
|
-
*/
|
|
1395
|
-
setVirtualBufferContent(buffer_id: number, entries: TextPropertyEntry[]): boolean;
|
|
1396
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Get the active buffer ID (0 if none)
|
|
202
|
+
*/
|
|
203
|
+
getActiveBufferId(): number;
|
|
204
|
+
/**
|
|
205
|
+
* Get the active split ID
|
|
206
|
+
*/
|
|
207
|
+
getActiveSplitId(): number;
|
|
208
|
+
/**
|
|
209
|
+
* List all open buffers - returns array of BufferInfo objects
|
|
210
|
+
*/
|
|
211
|
+
listBuffers(): unknown;
|
|
212
|
+
debug(msg: string): void;
|
|
213
|
+
info(msg: string): void;
|
|
214
|
+
warn(msg: string): void;
|
|
215
|
+
error(msg: string): void;
|
|
216
|
+
setStatus(msg: string): void;
|
|
217
|
+
copyToClipboard(text: string): void;
|
|
218
|
+
setClipboard(text: string): void;
|
|
219
|
+
/**
|
|
220
|
+
* Register a command - reads plugin name from __currentPluginName__ global
|
|
221
|
+
* context is optional - can be omitted, null, undefined, or a string
|
|
222
|
+
*/
|
|
223
|
+
registerCommand(name: string, description: string, handlerName: string, context?: unknown): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Unregister a command by name
|
|
226
|
+
*/
|
|
227
|
+
unregisterCommand(name: string): boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Set a context (for keybinding conditions)
|
|
230
|
+
*/
|
|
231
|
+
setContext(name: string, active: boolean): boolean;
|
|
232
|
+
/**
|
|
233
|
+
* Execute a built-in action
|
|
234
|
+
*/
|
|
235
|
+
executeAction(actionName: string): boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Translate a string - reads plugin name from __currentPluginName__ global
|
|
238
|
+
* Args is optional - can be omitted, undefined, null, or an object
|
|
239
|
+
*/
|
|
240
|
+
t(key: string, ...args: unknown[]): string;
|
|
241
|
+
/**
|
|
242
|
+
* Get cursor position in active buffer
|
|
243
|
+
*/
|
|
244
|
+
getCursorPosition(): number;
|
|
245
|
+
/**
|
|
246
|
+
* Get file path for a buffer
|
|
247
|
+
*/
|
|
248
|
+
getBufferPath(bufferId: number): string;
|
|
249
|
+
/**
|
|
250
|
+
* Get buffer length in bytes
|
|
251
|
+
*/
|
|
252
|
+
getBufferLength(bufferId: number): number;
|
|
253
|
+
/**
|
|
254
|
+
* Check if buffer has unsaved changes
|
|
255
|
+
*/
|
|
256
|
+
isBufferModified(bufferId: number): boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Get buffer info by ID
|
|
259
|
+
*/
|
|
260
|
+
getBufferInfo(bufferId: number): unknown;
|
|
261
|
+
/**
|
|
262
|
+
* Get primary cursor info for active buffer
|
|
263
|
+
*/
|
|
264
|
+
getPrimaryCursor(): unknown;
|
|
265
|
+
/**
|
|
266
|
+
* Get all cursors for active buffer
|
|
267
|
+
*/
|
|
268
|
+
getAllCursors(): unknown;
|
|
269
|
+
/**
|
|
270
|
+
* Get all cursor positions as byte offsets
|
|
271
|
+
*/
|
|
272
|
+
getAllCursorPositions(): unknown;
|
|
273
|
+
/**
|
|
274
|
+
* Get viewport info for active buffer
|
|
275
|
+
*/
|
|
276
|
+
getViewport(): unknown;
|
|
277
|
+
/**
|
|
278
|
+
* Get the line number (0-indexed) of the primary cursor
|
|
279
|
+
*/
|
|
280
|
+
getCursorLine(): number;
|
|
281
|
+
/**
|
|
282
|
+
* Find buffer by file path, returns buffer ID or 0 if not found
|
|
283
|
+
*/
|
|
284
|
+
findBufferByPath(path: string): number;
|
|
285
|
+
/**
|
|
286
|
+
* Get diff between buffer content and last saved version
|
|
287
|
+
*/
|
|
288
|
+
getBufferSavedDiff(bufferId: number): BufferSavedDiff | null;
|
|
289
|
+
/**
|
|
290
|
+
* Insert text at a position in a buffer
|
|
291
|
+
*/
|
|
292
|
+
insertText(bufferId: number, position: number, text: string): boolean;
|
|
293
|
+
/**
|
|
294
|
+
* Delete a range from a buffer
|
|
295
|
+
*/
|
|
296
|
+
deleteRange(bufferId: number, start: number, end: number): boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Insert text at cursor position in active buffer
|
|
299
|
+
*/
|
|
300
|
+
insertAtCursor(text: string): boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Open a file, optionally at a specific line/column
|
|
303
|
+
*/
|
|
304
|
+
openFile(path: string, line: number | null, column: number | null): boolean;
|
|
305
|
+
/**
|
|
306
|
+
* Open a file in a specific split
|
|
307
|
+
*/
|
|
308
|
+
openFileInSplit(splitId: number, path: string, line: number, column: number): boolean;
|
|
309
|
+
/**
|
|
310
|
+
* Show a buffer in the current split
|
|
311
|
+
*/
|
|
312
|
+
showBuffer(bufferId: number): boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Close a buffer
|
|
315
|
+
*/
|
|
316
|
+
closeBuffer(bufferId: number): boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Subscribe to an editor event
|
|
319
|
+
*/
|
|
320
|
+
on(eventName: string, handlerName: string): void;
|
|
321
|
+
/**
|
|
322
|
+
* Unsubscribe from an event
|
|
323
|
+
*/
|
|
324
|
+
off(eventName: string, handlerName: string): void;
|
|
325
|
+
/**
|
|
326
|
+
* Get an environment variable
|
|
327
|
+
*/
|
|
328
|
+
getEnv(name: string): string | null;
|
|
329
|
+
/**
|
|
330
|
+
* Get current working directory
|
|
331
|
+
*/
|
|
332
|
+
getCwd(): string;
|
|
333
|
+
/**
|
|
334
|
+
* Join path components (variadic - accepts multiple string arguments)
|
|
335
|
+
*/
|
|
336
|
+
pathJoin(...parts: string[]): string;
|
|
337
|
+
/**
|
|
338
|
+
* Get directory name from path
|
|
339
|
+
*/
|
|
340
|
+
pathDirname(path: string): string;
|
|
341
|
+
/**
|
|
342
|
+
* Get file name from path
|
|
343
|
+
*/
|
|
344
|
+
pathBasename(path: string): string;
|
|
345
|
+
/**
|
|
346
|
+
* Get file extension
|
|
347
|
+
*/
|
|
348
|
+
pathExtname(path: string): string;
|
|
349
|
+
/**
|
|
350
|
+
* Check if path is absolute
|
|
351
|
+
*/
|
|
352
|
+
pathIsAbsolute(path: string): boolean;
|
|
353
|
+
/**
|
|
354
|
+
* Check if file exists
|
|
355
|
+
*/
|
|
356
|
+
fileExists(path: string): boolean;
|
|
357
|
+
/**
|
|
358
|
+
* Read file contents
|
|
359
|
+
*/
|
|
360
|
+
readFile(path: string): string | null;
|
|
361
|
+
/**
|
|
362
|
+
* Write file contents
|
|
363
|
+
*/
|
|
364
|
+
writeFile(path: string, content: string): boolean;
|
|
365
|
+
/**
|
|
366
|
+
* Read directory contents (returns array of {name, is_file, is_dir})
|
|
367
|
+
*/
|
|
368
|
+
readDir(path: string): unknown;
|
|
369
|
+
/**
|
|
370
|
+
* Get current config as JS object
|
|
371
|
+
*/
|
|
372
|
+
getConfig(): unknown;
|
|
373
|
+
/**
|
|
374
|
+
* Get user config as JS object
|
|
375
|
+
*/
|
|
376
|
+
getUserConfig(): unknown;
|
|
377
|
+
/**
|
|
378
|
+
* Reload configuration from file
|
|
379
|
+
*/
|
|
380
|
+
reloadConfig(): void;
|
|
381
|
+
/**
|
|
382
|
+
* Get config directory path
|
|
383
|
+
*/
|
|
384
|
+
getConfigDir(): string;
|
|
385
|
+
/**
|
|
386
|
+
* Get themes directory path
|
|
387
|
+
*/
|
|
388
|
+
getThemesDir(): string;
|
|
389
|
+
/**
|
|
390
|
+
* Apply a theme by name
|
|
391
|
+
*/
|
|
392
|
+
applyTheme(themeName: string): boolean;
|
|
393
|
+
/**
|
|
394
|
+
* Get theme schema as JS object
|
|
395
|
+
*/
|
|
396
|
+
getThemeSchema(): unknown;
|
|
397
|
+
/**
|
|
398
|
+
* Get list of builtin themes as JS object
|
|
399
|
+
*/
|
|
400
|
+
getBuiltinThemes(): unknown;
|
|
401
|
+
/**
|
|
402
|
+
* Delete a custom theme (alias for deleteThemeSync)
|
|
403
|
+
*/
|
|
404
|
+
deleteTheme(name: string): boolean;
|
|
405
|
+
/**
|
|
406
|
+
* Get file stat information
|
|
407
|
+
*/
|
|
408
|
+
fileStat(path: string): unknown;
|
|
409
|
+
/**
|
|
410
|
+
* Check if a background process is still running
|
|
411
|
+
*/
|
|
412
|
+
isProcessRunning(processId: number): boolean;
|
|
413
|
+
/**
|
|
414
|
+
* Kill a process by ID (alias for killBackgroundProcess)
|
|
415
|
+
*/
|
|
416
|
+
killProcess(processId: number): boolean;
|
|
417
|
+
/**
|
|
418
|
+
* Translate a key for a specific plugin
|
|
419
|
+
*/
|
|
420
|
+
pluginTranslate(pluginName: string, key: string, args?: Record<string, unknown>): string;
|
|
421
|
+
/**
|
|
422
|
+
* Create a composite buffer (async)
|
|
423
|
+
*/
|
|
424
|
+
createCompositeBuffer(opts: Record<string, unknown>): Promise<number>;
|
|
425
|
+
/**
|
|
426
|
+
* Update alignment hunks for a composite buffer
|
|
427
|
+
*/
|
|
428
|
+
updateCompositeAlignment(bufferId: number, hunks: Record<string, unknown>[]): boolean;
|
|
429
|
+
/**
|
|
430
|
+
* Close a composite buffer
|
|
431
|
+
*/
|
|
432
|
+
closeCompositeBuffer(bufferId: number): boolean;
|
|
433
|
+
/**
|
|
434
|
+
* Request syntax highlights for a buffer range (async)
|
|
435
|
+
*/
|
|
436
|
+
getHighlights(bufferId: number, start: number, end: number): Promise<TsHighlightSpan[]>;
|
|
437
|
+
/**
|
|
438
|
+
* Add an overlay with styling
|
|
439
|
+
*/
|
|
440
|
+
addOverlay(bufferId: number, namespace: string, start: number, end: number, r: number, g: number, b: number, underline?: boolean, bold?: boolean, italic?: boolean, bgR?: number, bgG?: number, bgB?: number, extendToLineEnd?: boolean): boolean;
|
|
441
|
+
/**
|
|
442
|
+
* Clear all overlays in a namespace
|
|
443
|
+
*/
|
|
444
|
+
clearNamespace(bufferId: number, namespace: string): boolean;
|
|
445
|
+
/**
|
|
446
|
+
* Clear all overlays from a buffer
|
|
447
|
+
*/
|
|
448
|
+
clearAllOverlays(bufferId: number): boolean;
|
|
449
|
+
/**
|
|
450
|
+
* Clear all overlays that overlap with a byte range
|
|
451
|
+
*/
|
|
452
|
+
clearOverlaysInRange(bufferId: number, start: number, end: number): boolean;
|
|
453
|
+
/**
|
|
454
|
+
* Remove an overlay by its handle
|
|
455
|
+
*/
|
|
456
|
+
removeOverlay(bufferId: number, handle: string): boolean;
|
|
457
|
+
/**
|
|
458
|
+
* Submit a view transform for a buffer/split
|
|
459
|
+
*/
|
|
460
|
+
submitViewTransform(bufferId: number, splitId: number | null, start: number, end: number, tokens: Record<string, unknown>[], LayoutHints?: Record<string, unknown>): boolean;
|
|
461
|
+
/**
|
|
462
|
+
* Clear view transform for a buffer/split
|
|
463
|
+
*/
|
|
464
|
+
clearViewTransform(bufferId: number, splitId: number | null): boolean;
|
|
465
|
+
/**
|
|
466
|
+
* Set file explorer decorations for a namespace
|
|
467
|
+
*/
|
|
468
|
+
setFileExplorerDecorations(namespace: string, decorations: Record<string, unknown>[]): boolean;
|
|
469
|
+
/**
|
|
470
|
+
* Clear file explorer decorations for a namespace
|
|
471
|
+
*/
|
|
472
|
+
clearFileExplorerDecorations(namespace: string): boolean;
|
|
473
|
+
/**
|
|
474
|
+
* Add virtual text (inline text that doesn't exist in the buffer)
|
|
475
|
+
*/
|
|
476
|
+
addVirtualText(bufferId: number, virtualTextId: string, position: number, text: string, r: number, g: number, b: number, before: boolean, useBg: boolean): boolean;
|
|
477
|
+
/**
|
|
478
|
+
* Remove a virtual text by ID
|
|
479
|
+
*/
|
|
480
|
+
removeVirtualText(bufferId: number, virtualTextId: string): boolean;
|
|
481
|
+
/**
|
|
482
|
+
* Remove virtual texts whose ID starts with the given prefix
|
|
483
|
+
*/
|
|
484
|
+
removeVirtualTextsByPrefix(bufferId: number, prefix: string): boolean;
|
|
485
|
+
/**
|
|
486
|
+
* Clear all virtual texts from a buffer
|
|
487
|
+
*/
|
|
488
|
+
clearVirtualTexts(bufferId: number): boolean;
|
|
489
|
+
/**
|
|
490
|
+
* Clear all virtual texts in a namespace
|
|
491
|
+
*/
|
|
492
|
+
clearVirtualTextNamespace(bufferId: number, namespace: string): boolean;
|
|
493
|
+
/**
|
|
494
|
+
* Add a virtual line (full line above/below a position)
|
|
495
|
+
*/
|
|
496
|
+
addVirtualLine(bufferId: number, position: number, text: string, fgR: number, fgG: number, fgB: number, bgR: number, bgG: number, bgB: number, above: boolean, namespace: string, priority: number): boolean;
|
|
497
|
+
/**
|
|
498
|
+
* Start an interactive prompt
|
|
499
|
+
*/
|
|
500
|
+
startPrompt(label: string, promptType: string): boolean;
|
|
501
|
+
/**
|
|
502
|
+
* Start a prompt with initial value
|
|
503
|
+
*/
|
|
504
|
+
startPromptWithInitial(label: string, promptType: string, initialValue: string): boolean;
|
|
505
|
+
/**
|
|
506
|
+
* Set suggestions for the current prompt (takes array of suggestion objects)
|
|
507
|
+
*/
|
|
508
|
+
setPromptSuggestions(suggestionsArr: Record<string, unknown>[]): boolean;
|
|
509
|
+
/**
|
|
510
|
+
* Define a buffer mode (takes bindings as array of [key, command] pairs)
|
|
511
|
+
*/
|
|
512
|
+
defineMode(name: string, parent: string | null, bindingsArr: string[][], readOnly?: boolean): boolean;
|
|
513
|
+
/**
|
|
514
|
+
* Set the global editor mode
|
|
515
|
+
*/
|
|
516
|
+
setEditorMode(mode: string | null): boolean;
|
|
517
|
+
/**
|
|
518
|
+
* Get the current editor mode
|
|
519
|
+
*/
|
|
520
|
+
getEditorMode(): string | null;
|
|
521
|
+
/**
|
|
522
|
+
* Close a split
|
|
523
|
+
*/
|
|
524
|
+
closeSplit(splitId: number): boolean;
|
|
525
|
+
/**
|
|
526
|
+
* Set the buffer displayed in a split
|
|
527
|
+
*/
|
|
528
|
+
setSplitBuffer(splitId: number, bufferId: number): boolean;
|
|
529
|
+
/**
|
|
530
|
+
* Focus a specific split
|
|
531
|
+
*/
|
|
532
|
+
focusSplit(splitId: number): boolean;
|
|
533
|
+
/**
|
|
534
|
+
* Set scroll position of a split
|
|
535
|
+
*/
|
|
536
|
+
setSplitScroll(splitId: number, topByte: number): boolean;
|
|
537
|
+
/**
|
|
538
|
+
* Set the ratio of a split (0.0 to 1.0, 0.5 = equal)
|
|
539
|
+
*/
|
|
540
|
+
setSplitRatio(splitId: number, ratio: number): boolean;
|
|
541
|
+
/**
|
|
542
|
+
* Distribute all splits evenly
|
|
543
|
+
*/
|
|
544
|
+
distributeSplitsEvenly(): boolean;
|
|
545
|
+
/**
|
|
546
|
+
* Set cursor position in a buffer
|
|
547
|
+
*/
|
|
548
|
+
setBufferCursor(bufferId: number, position: number): boolean;
|
|
549
|
+
/**
|
|
550
|
+
* Set a line indicator in the gutter
|
|
551
|
+
*/
|
|
552
|
+
setLineIndicator(bufferId: number, line: number, namespace: string, symbol: string, r: number, g: number, b: number, priority: number): boolean;
|
|
553
|
+
/**
|
|
554
|
+
* Clear line indicators in a namespace
|
|
555
|
+
*/
|
|
556
|
+
clearLineIndicators(bufferId: number, namespace: string): boolean;
|
|
557
|
+
/**
|
|
558
|
+
* Enable or disable line numbers for a buffer
|
|
559
|
+
*/
|
|
560
|
+
setLineNumbers(bufferId: number, enabled: boolean): boolean;
|
|
561
|
+
/**
|
|
562
|
+
* Create a scroll sync group for anchor-based synchronized scrolling
|
|
563
|
+
*/
|
|
564
|
+
createScrollSyncGroup(groupId: number, leftSplit: number, rightSplit: number): boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Set sync anchors for a scroll sync group
|
|
567
|
+
*/
|
|
568
|
+
setScrollSyncAnchors(groupId: number, anchors: number[][]): boolean;
|
|
569
|
+
/**
|
|
570
|
+
* Remove a scroll sync group
|
|
571
|
+
*/
|
|
572
|
+
removeScrollSyncGroup(groupId: number): boolean;
|
|
573
|
+
/**
|
|
574
|
+
* Execute multiple actions in sequence
|
|
575
|
+
*/
|
|
576
|
+
executeActions(actions: Record<string, unknown>[]): boolean;
|
|
577
|
+
/**
|
|
578
|
+
* Show an action popup
|
|
579
|
+
*/
|
|
580
|
+
showActionPopup(opts: Record<string, unknown>): boolean;
|
|
581
|
+
/**
|
|
582
|
+
* Disable LSP for a specific language
|
|
583
|
+
*/
|
|
584
|
+
disableLspForLanguage(language: string): boolean;
|
|
585
|
+
/**
|
|
586
|
+
* Get all diagnostics from LSP
|
|
587
|
+
*/
|
|
588
|
+
getAllDiagnostics(): unknown;
|
|
589
|
+
/**
|
|
590
|
+
* Get registered event handlers for an event
|
|
591
|
+
*/
|
|
592
|
+
getHandlers(eventName: string): string[];
|
|
593
|
+
/**
|
|
594
|
+
* Create a virtual buffer in current split (async, returns buffer ID)
|
|
595
|
+
*/
|
|
596
|
+
createVirtualBuffer(opts: CreateVirtualBufferOptions): Promise<number>;
|
|
597
|
+
/**
|
|
598
|
+
* Create a virtual buffer in a new split (async, returns request_id)
|
|
599
|
+
*/
|
|
600
|
+
createVirtualBufferInSplit(opts: CreateVirtualBufferInSplitOptions): Promise<number>;
|
|
601
|
+
/**
|
|
602
|
+
* Create a virtual buffer in an existing split (async, returns request_id)
|
|
603
|
+
*/
|
|
604
|
+
createVirtualBufferInExistingSplit(opts: CreateVirtualBufferInExistingSplitOptions): Promise<number>;
|
|
605
|
+
/**
|
|
606
|
+
* Set virtual buffer content (takes array of entry objects)
|
|
607
|
+
*/
|
|
608
|
+
setVirtualBufferContent(bufferId: number, entriesArr: Record<string, unknown>[]): boolean;
|
|
609
|
+
/**
|
|
610
|
+
* Get text properties at cursor position (returns JS array)
|
|
611
|
+
*/
|
|
612
|
+
getTextPropertiesAtCursor(bufferId: number): TextPropertiesAtCursor;
|
|
613
|
+
/**
|
|
614
|
+
* Spawn a process (async, returns request_id)
|
|
615
|
+
*/
|
|
616
|
+
spawnProcess(command: string, args: string[], cwd?: string): ProcessHandle<SpawnResult>;
|
|
617
|
+
/**
|
|
618
|
+
* Wait for a process to complete and get its result (async)
|
|
619
|
+
*/
|
|
620
|
+
spawnProcessWait(processId: number): Promise<SpawnResult>;
|
|
621
|
+
/**
|
|
622
|
+
* Get buffer text range (async, returns request_id)
|
|
623
|
+
*/
|
|
624
|
+
getBufferText(bufferId: number, start: number, end: number): Promise<string>;
|
|
625
|
+
/**
|
|
626
|
+
* Delay/sleep (async, returns request_id)
|
|
627
|
+
*/
|
|
628
|
+
delay(durationMs: number): Promise<void>;
|
|
629
|
+
/**
|
|
630
|
+
* Send LSP request (async, returns request_id)
|
|
631
|
+
*/
|
|
632
|
+
sendLspRequest(language: string, method: string, params: Record<string, unknown> | null): Promise<unknown>;
|
|
633
|
+
/**
|
|
634
|
+
* Spawn a background process (async, returns request_id which is also process_id)
|
|
635
|
+
*/
|
|
636
|
+
spawnBackgroundProcess(command: string, args: string[], cwd?: string): ProcessHandle<BackgroundProcessResult>;
|
|
637
|
+
/**
|
|
638
|
+
* Kill a background process
|
|
639
|
+
*/
|
|
640
|
+
killBackgroundProcess(processId: number): boolean;
|
|
641
|
+
/**
|
|
642
|
+
* Force refresh of line display
|
|
643
|
+
*/
|
|
644
|
+
refreshLines(bufferId: number): boolean;
|
|
645
|
+
/**
|
|
646
|
+
* Get the current locale
|
|
647
|
+
*/
|
|
648
|
+
getCurrentLocale(): string;
|
|
1397
649
|
}
|