@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.
@@ -1,1397 +1,649 @@
1
1
  /**
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
- * Note: types/fresh.d.ts is auto-generated from this template and src/ts_runtime.rs
12
- *
13
- * ## Core Concepts
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
- * Get the editor API instance.
51
- * Plugins must call this at the top of their file to get a scoped editor object.
52
- * @returns The editor API object for this plugin
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
- * Plugin-specific methods added by the JavaScript runtime wrapper.
60
- * These extend the base EditorAPI with i18n and command registration helpers.
61
- */
62
- interface EditorAPI {
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
- /** View token wire format for view transforms */
141
- interface ViewTokenWire {
142
- /** Source byte offset (null for injected view-only content) */
143
- source_offset: number | null;
144
- /** Token kind: Text, Newline, Space, or Break */
145
- kind: ViewTokenWireKind;
146
- }
147
-
148
- /** View token kind discriminated union */
149
- type ViewTokenWireKind =
150
- | { Text: string }
151
- | "Newline"
152
- | "Space"
153
- | "Break";
154
-
155
- /** Layout hints for compose mode */
156
- interface LayoutHints {
157
- /** Optional compose width for centering/wrapping */
158
- compose_width?: number | null;
159
- /** Optional column guides for tables */
160
- column_guides?: number[] | null;
161
- }
162
-
163
- /** Handle for a cancellable process spawned with spawnProcess */
164
- interface ProcessHandle extends PromiseLike<SpawnResult> {
165
- /** Promise that resolves to the process ID */
166
- readonly processId: Promise<number>;
167
- /** Promise that resolves to the result when the process completes */
168
- readonly result: Promise<SpawnResult>;
169
- /** Kill the process. Returns true if killed, false if already completed */
170
- kill(): Promise<boolean>;
171
- }
172
-
173
- /** Result from spawnProcess */
174
- interface SpawnResult {
175
- /** Complete stdout as string. Newlines preserved; trailing newline included. */
176
- stdout: string;
177
- /** Complete stderr as string. Contains error messages and warnings. */
178
- stderr: string;
179
- /** Process exit code. 0 usually means success; -1 if process was killed. */
180
- exit_code: number;
181
- }
182
-
183
- /** Result from spawnBackgroundProcess - just the process ID */
184
- interface BackgroundProcessResult {
185
- /** Unique process ID for later reference (kill, status check) */
186
- process_id: number;
187
- }
188
-
189
- /** File stat information */
190
- interface FileStat {
191
- /** Whether the path exists */
192
- exists: boolean;
193
- /** Whether the path is a file */
194
- is_file: boolean;
195
- /** Whether the path is a directory */
196
- is_dir: boolean;
197
- /** File size in bytes */
198
- size: number;
199
- /** Whether the file is read-only */
200
- readonly: boolean;
201
- }
202
-
203
- /** Buffer information */
204
- interface BufferInfo {
205
- /** Unique buffer ID */
206
- id: number;
207
- /** File path (empty string if no path) */
208
- path: string;
209
- /** Whether buffer has unsaved changes */
210
- modified: boolean;
211
- /** Buffer length in bytes */
212
- length: number;
213
- }
214
-
215
- /** Diff vs last save for a buffer */
216
- interface TsBufferSavedDiff {
217
- equal: boolean;
218
- byte_ranges: [number, number][];
219
- line_ranges?: [number, number][] | null;
220
- }
221
-
222
- /** Selection range */
223
- interface SelectionRange {
224
- /** Start byte position */
225
- start: number;
226
- /** End byte position */
227
- end: number;
228
- }
229
-
230
- /** Cursor information with optional selection */
231
- interface CursorInfo {
232
- /** Byte position of the cursor */
233
- position: number;
234
- /** Selection range if text is selected, null otherwise */
235
- selection?: SelectionRange | null;
236
- }
237
-
238
- /** LSP diagnostic position */
239
- interface TsDiagnosticPosition {
240
- line: number;
241
- character: number;
242
- }
243
-
244
- /** LSP diagnostic range */
245
- interface TsDiagnosticRange {
246
- start: TsDiagnosticPosition;
247
- end: TsDiagnosticPosition;
248
- }
249
-
250
- /** LSP diagnostic item for TypeScript plugins */
251
- interface TsDiagnostic {
252
- /** File URI (e.g., "file:///path/to/file.rs") */
253
- uri: string;
254
- /** Diagnostic severity: 1=Error, 2=Warning, 3=Info, 4=Hint */
255
- severity: number;
256
- /** Diagnostic message */
257
- message: string;
258
- /** Source of the diagnostic (e.g., "rust-analyzer") */
259
- source?: string | null;
260
- /** Location range in the file */
261
- range: TsDiagnosticRange;
262
- }
263
-
264
- /** Viewport information */
265
- interface ViewportInfo {
266
- /** Byte offset of the top-left visible position */
267
- top_byte: number;
268
- /** Column offset for horizontal scrolling */
269
- left_column: number;
270
- /** Viewport width in columns */
271
- width: number;
272
- /** Viewport height in rows */
273
- height: number;
274
- }
275
-
276
- /** Suggestion for prompt autocomplete */
277
- interface PromptSuggestion {
278
- /** Display text for the suggestion */
279
- text: string;
280
- /** Optional description shown alongside */
281
- description?: string | null;
282
- /** Optional value to use instead of text when selected */
283
- value?: string | null;
284
- /** Whether the suggestion is disabled */
285
- disabled?: boolean | null;
286
- /** Optional keybinding hint */
287
- keybinding?: string | null;
288
- }
289
-
290
- /** Directory entry from readDir */
291
- interface DirEntry {
292
- /** Entry name only (not full path). Join with parent path to get absolute path. */
293
- name: string;
294
- /** True if entry is a regular file */
295
- is_file: boolean;
296
- /** True if entry is a directory. Note: symlinks report the target type. */
297
- is_dir: boolean;
298
- }
299
-
300
- /** Entry for virtual buffer content with embedded metadata */
301
- interface TextPropertyEntry {
302
- /** Text to display. Include trailing newline for separate lines. */
303
- text: string;
304
- /** Arbitrary metadata queryable via getTextPropertiesAtCursor. */
305
- properties: Record<string, unknown>;
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
- * Main editor API interface
466
- */
197
+ * Main editor API interface
198
+ */
467
199
  interface EditorAPI {
468
- // === Status and Logging ===
469
- /**
470
- * Display a transient message in the editor's status bar
471
- *
472
- * The message will be shown until the next status update or user action.
473
- * Use for feedback on completed operations (e.g., "File saved", "2 matches found").
474
- * @param message - Text to display; keep short (status bar has limited width)
475
- */
476
- setStatus(message: string): void;
477
- /**
478
- * Log a debug message from a plugin
479
- *
480
- * Messages appear in log file when running with RUST_LOG=debug.
481
- * Useful for plugin development and troubleshooting.
482
- * @param message - Debug message; include context like function name and relevant values
483
- */
484
- debug(message: string): void;
485
-
486
- // === Buffer Queries ===
487
- /**
488
- * Get the theme JSON Schema for the theme editor
489
- *
490
- * Returns the raw JSON Schema generated by schemars for ThemeFile.
491
- * The schema uses standard JSON Schema format with $ref for type references.
492
- * Plugins are responsible for parsing the schema and resolving $ref references.
493
- * @returns JSON Schema object
494
- */
495
- getThemeSchema(): unknown;
496
- getBuiltinThemes(): unknown;
497
- /**
498
- * Get the current editor configuration
499
- *
500
- * Returns the merged configuration (user config file + compiled-in defaults).
501
- * This is the runtime config that the editor is actually using, including
502
- * all default values for LSP servers, languages, keybindings, etc.
503
- * @returns Configuration object
504
- */
505
- getConfig(): unknown;
506
- /**
507
- * Get the user's configuration (only explicitly set values)
508
- *
509
- * Returns only the configuration from the user's config file.
510
- * Fields not present here are using default values.
511
- * Use this with getConfig() to determine which values are defaults.
512
- * @returns User configuration object (sparse - only explicitly set values)
513
- */
514
- getUserConfig(): unknown;
515
- /**
516
- * Get the user configuration directory path
517
- *
518
- * Returns the absolute path to the directory where user config and themes are stored.
519
- * e.g. ~/.config/fresh/ on Linux or ~/Library/Application Support/fresh/ on macOS.
520
- */
521
- getConfigDir(): string;
522
- /**
523
- * Get the user themes directory path
524
- *
525
- * Returns the absolute path to the directory where user themes are stored.
526
- * e.g. ~/.config/fresh/themes/
527
- */
528
- getThemesDir(): string;
529
- /**
530
- * Get the buffer ID of the focused editor pane
531
- *
532
- * Returns 0 if no buffer is active (rare edge case).
533
- * Use this ID with other buffer operations like insertText.
534
- */
535
- getActiveBufferId(): number;
536
- /**
537
- * Get the byte offset of the primary cursor in the active buffer
538
- *
539
- * Returns 0 if no cursor exists. For multi-cursor scenarios, use getAllCursors
540
- * to get all cursor positions with selection info.
541
- * Note: This is a byte offset, not a character index (UTF-8 matters).
542
- */
543
- getCursorPosition(): number;
544
- /**
545
- * Get the absolute file path for a buffer
546
- *
547
- * Returns empty string for unsaved buffers or virtual buffers.
548
- * The path is always absolute. Use this to determine file type,
549
- * construct related paths, or display to the user.
550
- * @param buffer_id - Target buffer ID
551
- */
552
- getBufferPath(buffer_id: number): string;
553
- /**
554
- * Get the total byte length of a buffer's content
555
- *
556
- * Returns 0 if buffer doesn't exist.
557
- * @param buffer_id - Target buffer ID
558
- */
559
- getBufferLength(buffer_id: number): number;
560
- /**
561
- * Check if a buffer has been modified since last save
562
- *
563
- * Returns false if buffer doesn't exist or has never been saved.
564
- * Virtual buffers are never considered modified.
565
- * @param buffer_id - Target buffer ID
566
- */
567
- isBufferModified(buffer_id: number): boolean;
568
- /** Get the currently active locale */
569
- getCurrentLocale(): string;
570
- /**
571
- * Get the ID of the focused split pane
572
- *
573
- * Use with focusSplit, setSplitBuffer, or createVirtualBufferInExistingSplit
574
- * to manage split layouts.
575
- */
576
- getActiveSplitId(): number;
577
- /**
578
- * Get the line number of the primary cursor (1-indexed)
579
- *
580
- * Line numbers start at 1. Returns 1 if no cursor exists.
581
- * For byte offset use getCursorPosition instead.
582
- */
583
- getCursorLine(): number;
584
- /**
585
- * Get byte offsets of all cursors (multi-cursor support)
586
- *
587
- * Returns array of positions; empty if no cursors. Primary cursor
588
- * is typically first. For selection info use getAllCursors instead.
589
- */
590
- getAllCursorPositions(): number[];
591
- /**
592
- * Check if a background process is still running
593
- *
594
- * @param process_id - ID returned from spawnBackgroundProcess
595
- * @returns true if process is running, false if not found or exited
596
- */
597
- isProcessRunning(process_id: number): boolean;
598
- /** Compute syntax highlighting for a buffer range */
599
- getHighlights(buffer_id: number, start: number, end: number): Promise<TsHighlightSpan[]>;
600
- /** Get diff vs last saved snapshot for a buffer */
601
- getBufferSavedDiff(buffer_id: number): TsBufferSavedDiff | null;
602
- /**
603
- * Get all LSP diagnostics across all files
604
- * @returns Array of Diagnostic objects with file URI, severity, message, and range
605
- */
606
- getAllDiagnostics(): TsDiagnostic[];
607
- /**
608
- * Get text from a buffer range
609
- *
610
- * Used by vi mode plugin for yank operations - reads text without deleting.
611
- * @param buffer_id - Buffer ID
612
- * @param start - Start byte offset
613
- * @param end - End byte offset
614
- * @returns Text content of the range, or empty string on error
615
- */
616
- getBufferText(buffer_id: number, start: number, end: number): Promise<string>;
617
- /**
618
- * Get the current global editor mode
619
- *
620
- * @returns Current mode name or null if no mode is active
621
- */
622
- getEditorMode(): string;
623
-
624
- // === Buffer Info Queries ===
625
- /**
626
- * Get full information about a buffer
627
- * @param buffer_id - Buffer ID
628
- * @returns BufferInfo object or null if buffer not found
629
- */
630
- getBufferInfo(buffer_id: number): BufferInfo | null;
631
- /**
632
- * List all open buffers
633
- * @returns Array of BufferInfo objects
634
- */
635
- listBuffers(): BufferInfo[];
636
- /**
637
- * Get primary cursor with selection info
638
- * @returns CursorInfo object or null if no cursor
639
- */
640
- getPrimaryCursor(): CursorInfo | null;
641
- /**
642
- * Get all cursors (for multi-cursor support)
643
- * @returns Array of CursorInfo objects
644
- */
645
- getAllCursors(): CursorInfo[];
646
- /**
647
- * Get viewport information
648
- * @returns ViewportInfo object or null if no viewport
649
- */
650
- getViewport(): ViewportInfo | null;
651
-
652
- // === Prompt Operations ===
653
- /**
654
- * Start an interactive prompt
655
- * @param label - Label to display (e.g., "Git grep: ")
656
- * @param prompt_type - Type identifier (e.g., "git-grep")
657
- * @returns true if prompt was started successfully
658
- */
659
- startPrompt(label: string, prompt_type: string): boolean;
660
- /**
661
- * Set suggestions for the current prompt
662
- * @param suggestions - Array of suggestions to display
663
- * @returns true if suggestions were set successfully
664
- */
665
- setPromptSuggestions(suggestions: PromptSuggestion[]): boolean;
666
-
667
- // === Buffer Mutations ===
668
- /**
669
- * Apply a theme by name
670
- *
671
- * Loads and applies the specified theme immediately. The theme can be a built-in
672
- * theme name or a custom theme from the themes directory.
673
- * @param theme_name - Name of the theme to apply (e.g., "dark", "light", "my-custom-theme")
674
- */
675
- applyTheme(theme_name: string): void;
676
- /**
677
- * Reload configuration from file
678
- *
679
- * After a plugin saves config changes to the config file, call this to reload
680
- * the editor's in-memory configuration. This ensures the editor and plugins
681
- * stay in sync with the saved config.
682
- */
683
- reloadConfig(): void;
684
- /**
685
- * Log an error message from a plugin
686
- *
687
- * Messages appear in log file when running with RUST_LOG=error.
688
- * Use for critical errors that need attention.
689
- * @param message - Error message
690
- */
691
- error(message: string): void;
692
- /**
693
- * Log a warning message from a plugin
694
- *
695
- * Messages appear in log file when running with RUST_LOG=warn.
696
- * Use for warnings that don't prevent operation but indicate issues.
697
- * @param message - Warning message
698
- */
699
- warn(message: string): void;
700
- /**
701
- * Log an info message from a plugin
702
- *
703
- * Messages appear in log file when running with RUST_LOG=info.
704
- * Use for important operational messages.
705
- * @param message - Info message
706
- */
707
- info(message: string): void;
708
- /**
709
- * Copy text to the system clipboard
710
- *
711
- * Copies the provided text to both the internal and system clipboard.
712
- * Uses OSC 52 and arboard for cross-platform compatibility.
713
- * @param text - Text to copy to clipboard
714
- */
715
- setClipboard(text: string): void;
716
- /**
717
- * Insert text at a byte position in a buffer
718
- *
719
- * Text is inserted before the byte at position. Position must be valid
720
- * (0 to buffer length). Insertion shifts all text after position.
721
- * Operation is asynchronous; returns true if command was sent successfully.
722
- * @param buffer_id - Target buffer ID
723
- * @param position - Byte offset where text will be inserted (must be at char boundary)
724
- * @param text - UTF-8 text to insert
725
- */
726
- insertText(buffer_id: number, position: number, text: string): boolean;
727
- /**
728
- * Delete a byte range from a buffer
729
- *
730
- * Deletes bytes from start (inclusive) to end (exclusive).
731
- * Both positions must be at valid UTF-8 char boundaries.
732
- * Operation is asynchronous; returns true if command was sent successfully.
733
- * @param buffer_id - Target buffer ID
734
- * @param start - Start byte offset (inclusive)
735
- * @param end - End byte offset (exclusive)
736
- */
737
- deleteRange(buffer_id: number, start: number, end: number): boolean;
738
- /**
739
- * Clear all overlays in a namespace
740
- * @param buffer_id - The buffer ID
741
- * @param namespace - The namespace to clear
742
- * @returns true if successful
743
- */
744
- clearNamespace(buffer_id: number, namespace: string): boolean;
745
- /**
746
- * Enable/disable line numbers for a buffer
747
- * @param buffer_id - The buffer ID
748
- * @param enabled - Whether to show line numbers
749
- * @returns true if successful
750
- */
751
- setLineNumbers(buffer_id: number, enabled: boolean): boolean;
752
- /**
753
- * Add a virtual line above or below a source line
754
- * @param buffer_id - The buffer ID
755
- * @param position - Byte position to anchor the virtual line to
756
- * @param text - The text content of the virtual line
757
- * @param fg_r - Foreground red color component (0-255)
758
- * @param fg_g - Foreground green color component (0-255)
759
- * @param fg_b - Foreground blue color component (0-255)
760
- * @param bg_r - Background red color component (0-255), -1 for transparent
761
- * @param bg_g - Background green color component (0-255), -1 for transparent
762
- * @param bg_b - Background blue color component (0-255), -1 for transparent
763
- * @param above - Whether to insert above (true) or below (false) the line
764
- * @param namespace - Namespace for bulk removal (e.g., "git-blame")
765
- * @param priority - Priority for ordering multiple lines at same position
766
- * @returns true if virtual line was added
767
- */
768
- addVirtualLine(buffer_id: number, position: number, text: string, fg_r: number, fg_g: number, fg_b: number, bg_r: number, bg_g: number, bg_b: number, above: boolean, namespace: string, priority: number): boolean;
769
- /**
770
- * Set a line indicator in the gutter's indicator column
771
- * @param buffer_id - The buffer ID
772
- * @param line - Line number (0-indexed)
773
- * @param namespace - Namespace for grouping (e.g., "git-gutter", "breakpoints")
774
- * @param symbol - Symbol to display (e.g., "│", "●", "★")
775
- * @param r - Red color component (0-255)
776
- * @param g - Green color component (0-255)
777
- * @param b - Blue color component (0-255)
778
- * @param priority - Priority for display when multiple indicators exist (higher wins)
779
- * @returns true if indicator was set
780
- */
781
- setLineIndicator(buffer_id: number, line: number, namespace: string, symbol: string, r: number, g: number, b: number, priority: number): boolean;
782
- /**
783
- * Clear all line indicators for a specific namespace
784
- * @param buffer_id - The buffer ID
785
- * @param namespace - Namespace to clear (e.g., "git-gutter")
786
- * @returns true if indicators were cleared
787
- */
788
- clearLineIndicators(buffer_id: number, namespace: string): boolean;
789
- /**
790
- * Submit a transformed view stream for a viewport
791
- * @param buffer_id - Buffer to apply the transform to
792
- * @param start - Viewport start byte
793
- * @param end - Viewport end byte
794
- * @param tokens - Array of tokens with source offsets
795
- * @param source_map - Array of source offsets (null for injected)
796
- * @param layout_hints - Optional layout hints (compose width, column guides)
797
- */
798
- submitViewTransform(buffer_id: number, split_id?: number | null, start: number, end: number, tokens: ViewTokenWire[], layout_hints?: LayoutHints | null): boolean;
799
- /**
800
- * Clear view transform for a buffer/split (returns to normal rendering)
801
- * @param buffer_id - Buffer ID
802
- * @param split_id - Optional split ID (uses active split if not specified)
803
- * @returns true if clear succeeded
804
- */
805
- clearViewTransform(buffer_id: number, split_id?: number | null): boolean;
806
- /**
807
- * Insert text at the current cursor position in the active buffer
808
- * @param text - The text to insert
809
- * @returns true if insertion succeeded
810
- */
811
- insertAtCursor(text: string): boolean;
812
- /** Translate a string for a plugin using the current locale */
813
- pluginTranslate(plugin_name: string, key: string, args: Record<string, unknown>): string;
814
- /** Register a custom command that can be triggered by keybindings or the command palette */
815
- registerCommand(name: string, description: string, action: string, contexts: string, source: string): boolean;
816
- /**
817
- * Unregister a custom command by name
818
- * @param name - The name of the command to unregister
819
- * @returns true if the command was successfully unregistered
820
- */
821
- unregisterCommand(name: string): boolean;
822
- /**
823
- * Set or unset a custom context for command visibility
824
- * Custom contexts allow plugins to control when their commands are available.
825
- * For example, setting "config-editor" context makes config editor commands visible.
826
- * @param name - Context name (e.g., "config-editor")
827
- * @param active - Whether the context is active (true = set, false = unset)
828
- * @returns true if the context was updated
829
- */
830
- setContext(name: string, active: boolean): boolean;
831
- /**
832
- * Open a file in the editor, optionally at a specific location
833
- * @param path - File path to open
834
- * @param line - Line number to jump to (0 for no jump)
835
- * @param column - Column number to jump to (0 for no jump)
836
- * @returns true if file was opened
837
- */
838
- openFile(path: string, line: number, column: number): boolean;
839
- /**
840
- * Open a file in a specific split pane
841
- * @param split_id - The split ID to open the file in
842
- * @param path - File path to open
843
- * @param line - Line number to jump to (0 for no jump)
844
- * @param column - Column number to jump to (0 for no jump)
845
- * @returns true if file was opened
846
- */
847
- openFileInSplit(split_id: number, path: string, line: number, column: number): boolean;
848
- /**
849
- * Spawn a long-running background process
850
- *
851
- * Unlike spawnProcess which waits for completion, this starts a process
852
- * in the background and returns immediately with a process ID.
853
- * Use killProcess(id) to terminate the process later.
854
- * Use isProcessRunning(id) to check if it's still running.
855
- *
856
- * @param command - Program name (searched in PATH) or absolute path
857
- * @param args - Command arguments (each array element is one argument)
858
- * @param cwd - Working directory; null uses editor's cwd
859
- * @returns Object with process_id for later reference
860
- * @example
861
- * const proc = await editor.spawnBackgroundProcess("asciinema", ["rec", "output.cast"]);
862
- * // Later...
863
- * await editor.killProcess(proc.process_id);
864
- */
865
- spawnBackgroundProcess(command: string, args: string[], cwd?: string | null): Promise<BackgroundProcessResult>;
866
- /**
867
- * Kill a background or cancellable process by ID
868
- *
869
- * Sends SIGTERM to gracefully terminate the process.
870
- * Returns true if the process was found and killed, false if not found.
871
- *
872
- * @param process_id - ID returned from spawnBackgroundProcess or spawnProcessStart
873
- * @returns true if process was killed, false if not found
874
- */
875
- killProcess(process_id: number): Promise<boolean>;
876
- /**
877
- * Wait for a cancellable process to complete and get its result
878
- *
879
- * @param process_id - ID returned from spawnProcessStart
880
- * @returns SpawnResult with stdout, stderr, and exit_code
881
- */
882
- spawnProcessWait(process_id: number): Promise<SpawnResult>;
883
- /**
884
- * Delay execution for a specified number of milliseconds
885
- *
886
- * Useful for debouncing user input or adding delays between operations.
887
- * @param ms - Number of milliseconds to delay
888
- * @example
889
- * await editor.delay(100); // Wait 100ms
890
- */
891
- delay(ms: number): Promise<void>;
892
- /** Find a buffer ID by its file path */
893
- findBufferByPath(path: string): number;
894
- /**
895
- * Start a prompt with pre-filled initial value
896
- * @param label - Label to display (e.g., "Git grep: ")
897
- * @param prompt_type - Type identifier (e.g., "git-grep")
898
- * @param initial_value - Initial text to pre-fill in the prompt
899
- * @returns true if prompt was started successfully
900
- */
901
- startPromptWithInitial(label: string, prompt_type: string, initial_value: string): boolean;
902
- /**
903
- * Delete a theme file by name
904
- *
905
- * Only deletes files from the user's themes directory.
906
- * This is a safe operation that prevents plugins from deleting arbitrary files.
907
- * @param name - Theme name (without .json extension)
908
- */
909
- deleteTheme(name: string): Promise<void>;
910
- /**
911
- * Create a composite buffer that displays multiple source buffers
912
- *
913
- * Composite buffers allow displaying multiple underlying buffers in a single
914
- * tab/view area with custom layouts (side-by-side, stacked, unified).
915
- * This is useful for diff views, merge conflict resolution, etc.
916
- * @param options - Configuration for the composite buffer
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
  }