@involvex/fresh-editor 0.1.76 → 0.1.78
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/bin/CHANGELOG.md +1017 -0
- package/bin/LICENSE +117 -0
- package/bin/README.md +248 -0
- package/bin/fresh.exe +0 -0
- package/bin/plugins/README.md +71 -0
- package/bin/plugins/audit_mode.i18n.json +821 -0
- package/bin/plugins/audit_mode.ts +1810 -0
- package/bin/plugins/buffer_modified.i18n.json +67 -0
- package/bin/plugins/buffer_modified.ts +281 -0
- package/bin/plugins/calculator.i18n.json +93 -0
- package/bin/plugins/calculator.ts +770 -0
- package/bin/plugins/clangd-lsp.ts +168 -0
- package/bin/plugins/clangd_support.i18n.json +223 -0
- package/bin/plugins/clangd_support.md +20 -0
- package/bin/plugins/clangd_support.ts +325 -0
- package/bin/plugins/color_highlighter.i18n.json +145 -0
- package/bin/plugins/color_highlighter.ts +304 -0
- package/bin/plugins/config-schema.json +768 -0
- package/bin/plugins/csharp-lsp.ts +147 -0
- package/bin/plugins/csharp_support.i18n.json +80 -0
- package/bin/plugins/csharp_support.ts +170 -0
- package/bin/plugins/css-lsp.ts +143 -0
- package/bin/plugins/diagnostics_panel.i18n.json +236 -0
- package/bin/plugins/diagnostics_panel.ts +642 -0
- package/bin/plugins/examples/README.md +85 -0
- package/bin/plugins/examples/async_demo.ts +165 -0
- package/bin/plugins/examples/bookmarks.ts +329 -0
- package/bin/plugins/examples/buffer_query_demo.ts +110 -0
- package/bin/plugins/examples/git_grep.ts +262 -0
- package/bin/plugins/examples/hello_world.ts +93 -0
- package/bin/plugins/examples/virtual_buffer_demo.ts +116 -0
- package/bin/plugins/find_references.i18n.json +275 -0
- package/bin/plugins/find_references.ts +359 -0
- package/bin/plugins/git_blame.i18n.json +496 -0
- package/bin/plugins/git_blame.ts +707 -0
- package/bin/plugins/git_find_file.i18n.json +314 -0
- package/bin/plugins/git_find_file.ts +300 -0
- package/bin/plugins/git_grep.i18n.json +171 -0
- package/bin/plugins/git_grep.ts +191 -0
- package/bin/plugins/git_gutter.i18n.json +93 -0
- package/bin/plugins/git_gutter.ts +477 -0
- package/bin/plugins/git_log.i18n.json +481 -0
- package/bin/plugins/git_log.ts +1285 -0
- package/bin/plugins/go-lsp.ts +143 -0
- package/bin/plugins/html-lsp.ts +145 -0
- package/bin/plugins/json-lsp.ts +145 -0
- package/bin/plugins/lib/fresh.d.ts +1321 -0
- package/bin/plugins/lib/index.ts +24 -0
- package/bin/plugins/lib/navigation-controller.ts +214 -0
- package/bin/plugins/lib/panel-manager.ts +220 -0
- package/bin/plugins/lib/types.ts +72 -0
- package/bin/plugins/lib/virtual-buffer-factory.ts +130 -0
- package/bin/plugins/live_grep.i18n.json +171 -0
- package/bin/plugins/live_grep.ts +422 -0
- package/bin/plugins/markdown_compose.i18n.json +223 -0
- package/bin/plugins/markdown_compose.ts +630 -0
- package/bin/plugins/merge_conflict.i18n.json +821 -0
- package/bin/plugins/merge_conflict.ts +1810 -0
- package/bin/plugins/path_complete.i18n.json +80 -0
- package/bin/plugins/path_complete.ts +165 -0
- package/bin/plugins/python-lsp.ts +162 -0
- package/bin/plugins/rust-lsp.ts +166 -0
- package/bin/plugins/search_replace.i18n.json +405 -0
- package/bin/plugins/search_replace.ts +484 -0
- package/bin/plugins/test_i18n.i18n.json +67 -0
- package/bin/plugins/test_i18n.ts +18 -0
- package/bin/plugins/theme_editor.i18n.json +3746 -0
- package/bin/plugins/theme_editor.ts +2063 -0
- package/bin/plugins/todo_highlighter.i18n.json +184 -0
- package/bin/plugins/todo_highlighter.ts +206 -0
- package/bin/plugins/typescript-lsp.ts +167 -0
- package/bin/plugins/vi_mode.i18n.json +1549 -0
- package/bin/plugins/vi_mode.ts +2747 -0
- package/bin/plugins/welcome.i18n.json +236 -0
- package/bin/plugins/welcome.ts +76 -0
- package/bin/themes/dark.json +102 -0
- package/bin/themes/dracula.json +62 -0
- package/bin/themes/high-contrast.json +102 -0
- package/bin/themes/light.json +102 -0
- package/bin/themes/nord.json +62 -0
- package/bin/themes/nostalgia.json +102 -0
- package/bin/themes/solarized-dark.json +62 -0
- package/binary-install.js +1 -1
- package/dist/bin/fresh.js +9 -0
- package/dist/binary-install.js +149 -0
- package/dist/binary.js +30 -0
- package/dist/fresh-6yhknp07.exe +0 -0
- package/dist/install.js +158 -0
- package/dist/run-fresh.js +43 -0
- package/package.json +7 -2
|
@@ -0,0 +1,1321 @@
|
|
|
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
|
+
|
|
49
|
+
declare global {
|
|
50
|
+
/**
|
|
51
|
+
* Global editor API object available to all TypeScript plugins
|
|
52
|
+
*/
|
|
53
|
+
const editor: EditorAPI;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Buffer identifier (unique numeric ID)
|
|
58
|
+
*/
|
|
59
|
+
type BufferId = number;
|
|
60
|
+
|
|
61
|
+
/** View token wire format for view transforms */
|
|
62
|
+
interface ViewTokenWire {
|
|
63
|
+
/** Source byte offset (null for injected view-only content) */
|
|
64
|
+
source_offset: number | null;
|
|
65
|
+
/** Token kind: Text, Newline, Space, or Break */
|
|
66
|
+
kind: ViewTokenWireKind;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** View token kind discriminated union */
|
|
70
|
+
type ViewTokenWireKind =
|
|
71
|
+
| { Text: string }
|
|
72
|
+
| "Newline"
|
|
73
|
+
| "Space"
|
|
74
|
+
| "Break";
|
|
75
|
+
|
|
76
|
+
/** Layout hints for compose mode */
|
|
77
|
+
interface LayoutHints {
|
|
78
|
+
/** Optional compose width for centering/wrapping */
|
|
79
|
+
compose_width?: number | null;
|
|
80
|
+
/** Optional column guides for tables */
|
|
81
|
+
column_guides?: number[] | null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Handle for a cancellable process spawned with spawnProcess */
|
|
85
|
+
interface ProcessHandle extends PromiseLike<SpawnResult> {
|
|
86
|
+
/** Promise that resolves to the process ID */
|
|
87
|
+
readonly processId: Promise<number>;
|
|
88
|
+
/** Promise that resolves to the result when the process completes */
|
|
89
|
+
readonly result: Promise<SpawnResult>;
|
|
90
|
+
/** Kill the process. Returns true if killed, false if already completed */
|
|
91
|
+
kill(): Promise<boolean>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Result from spawnProcess */
|
|
95
|
+
interface SpawnResult {
|
|
96
|
+
/** Complete stdout as string. Newlines preserved; trailing newline included. */
|
|
97
|
+
stdout: string;
|
|
98
|
+
/** Complete stderr as string. Contains error messages and warnings. */
|
|
99
|
+
stderr: string;
|
|
100
|
+
/** Process exit code. 0 usually means success; -1 if process was killed. */
|
|
101
|
+
exit_code: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Result from spawnBackgroundProcess - just the process ID */
|
|
105
|
+
interface BackgroundProcessResult {
|
|
106
|
+
/** Unique process ID for later reference (kill, status check) */
|
|
107
|
+
process_id: number;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** File stat information */
|
|
111
|
+
interface FileStat {
|
|
112
|
+
/** Whether the path exists */
|
|
113
|
+
exists: boolean;
|
|
114
|
+
/** Whether the path is a file */
|
|
115
|
+
is_file: boolean;
|
|
116
|
+
/** Whether the path is a directory */
|
|
117
|
+
is_dir: boolean;
|
|
118
|
+
/** File size in bytes */
|
|
119
|
+
size: number;
|
|
120
|
+
/** Whether the file is read-only */
|
|
121
|
+
readonly: boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Buffer information */
|
|
125
|
+
interface BufferInfo {
|
|
126
|
+
/** Unique buffer ID */
|
|
127
|
+
id: number;
|
|
128
|
+
/** File path (empty string if no path) */
|
|
129
|
+
path: string;
|
|
130
|
+
/** Whether buffer has unsaved changes */
|
|
131
|
+
modified: boolean;
|
|
132
|
+
/** Buffer length in bytes */
|
|
133
|
+
length: number;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Diff vs last save for a buffer */
|
|
137
|
+
interface TsBufferSavedDiff {
|
|
138
|
+
equal: boolean;
|
|
139
|
+
byte_ranges: [number, number][];
|
|
140
|
+
line_ranges?: [number, number][] | null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Selection range */
|
|
144
|
+
interface SelectionRange {
|
|
145
|
+
/** Start byte position */
|
|
146
|
+
start: number;
|
|
147
|
+
/** End byte position */
|
|
148
|
+
end: number;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Cursor information with optional selection */
|
|
152
|
+
interface CursorInfo {
|
|
153
|
+
/** Byte position of the cursor */
|
|
154
|
+
position: number;
|
|
155
|
+
/** Selection range if text is selected, null otherwise */
|
|
156
|
+
selection?: SelectionRange | null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** LSP diagnostic position */
|
|
160
|
+
interface TsDiagnosticPosition {
|
|
161
|
+
line: number;
|
|
162
|
+
character: number;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** LSP diagnostic range */
|
|
166
|
+
interface TsDiagnosticRange {
|
|
167
|
+
start: TsDiagnosticPosition;
|
|
168
|
+
end: TsDiagnosticPosition;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** LSP diagnostic item for TypeScript plugins */
|
|
172
|
+
interface TsDiagnostic {
|
|
173
|
+
/** File URI (e.g., "file:///path/to/file.rs") */
|
|
174
|
+
uri: string;
|
|
175
|
+
/** Diagnostic severity: 1=Error, 2=Warning, 3=Info, 4=Hint */
|
|
176
|
+
severity: number;
|
|
177
|
+
/** Diagnostic message */
|
|
178
|
+
message: string;
|
|
179
|
+
/** Source of the diagnostic (e.g., "rust-analyzer") */
|
|
180
|
+
source?: string | null;
|
|
181
|
+
/** Location range in the file */
|
|
182
|
+
range: TsDiagnosticRange;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Viewport information */
|
|
186
|
+
interface ViewportInfo {
|
|
187
|
+
/** Byte offset of the top-left visible position */
|
|
188
|
+
top_byte: number;
|
|
189
|
+
/** Column offset for horizontal scrolling */
|
|
190
|
+
left_column: number;
|
|
191
|
+
/** Viewport width in columns */
|
|
192
|
+
width: number;
|
|
193
|
+
/** Viewport height in rows */
|
|
194
|
+
height: number;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Suggestion for prompt autocomplete */
|
|
198
|
+
interface PromptSuggestion {
|
|
199
|
+
/** Display text for the suggestion */
|
|
200
|
+
text: string;
|
|
201
|
+
/** Optional description shown alongside */
|
|
202
|
+
description?: string | null;
|
|
203
|
+
/** Optional value to use instead of text when selected */
|
|
204
|
+
value?: string | null;
|
|
205
|
+
/** Whether the suggestion is disabled */
|
|
206
|
+
disabled?: boolean | null;
|
|
207
|
+
/** Optional keybinding hint */
|
|
208
|
+
keybinding?: string | null;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Directory entry from readDir */
|
|
212
|
+
interface DirEntry {
|
|
213
|
+
/** Entry name only (not full path). Join with parent path to get absolute path. */
|
|
214
|
+
name: string;
|
|
215
|
+
/** True if entry is a regular file */
|
|
216
|
+
is_file: boolean;
|
|
217
|
+
/** True if entry is a directory. Note: symlinks report the target type. */
|
|
218
|
+
is_dir: boolean;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** Entry for virtual buffer content with embedded metadata */
|
|
222
|
+
interface TextPropertyEntry {
|
|
223
|
+
/** Text to display. Include trailing newline for separate lines. */
|
|
224
|
+
text: string;
|
|
225
|
+
/** Arbitrary metadata queryable via getTextPropertiesAtCursor. */
|
|
226
|
+
properties: Record<string, unknown>;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** Result from createVirtualBufferInSplit */
|
|
230
|
+
interface CreateVirtualBufferResult {
|
|
231
|
+
buffer_id: number;
|
|
232
|
+
split_id?: number | null;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Configuration for createVirtualBufferInSplit */
|
|
236
|
+
interface CreateVirtualBufferOptions {
|
|
237
|
+
/** Buffer name shown in status bar (convention: "*Name*") */
|
|
238
|
+
name: string;
|
|
239
|
+
/** Mode for keybindings; define with defineMode first */
|
|
240
|
+
mode: string;
|
|
241
|
+
/** Prevent text modifications */
|
|
242
|
+
read_only: boolean;
|
|
243
|
+
/** Content with embedded metadata */
|
|
244
|
+
entries: TextPropertyEntry[];
|
|
245
|
+
/** Split ratio (0.3 = new pane gets 30% of space) */
|
|
246
|
+
ratio: number;
|
|
247
|
+
/** Split direction: "horizontal" (below) or "vertical" (side-by-side). Default: horizontal */
|
|
248
|
+
direction?: string | null;
|
|
249
|
+
/** If set and panel exists, update content instead of creating new buffer */
|
|
250
|
+
panel_id?: string | null;
|
|
251
|
+
/** Show line numbers gutter (default: true) */
|
|
252
|
+
show_line_numbers?: boolean | null;
|
|
253
|
+
/** Show cursor in buffer (default: true) */
|
|
254
|
+
show_cursors?: boolean | null;
|
|
255
|
+
/** Disable all editing commands (default: false) */
|
|
256
|
+
editing_disabled?: boolean | null;
|
|
257
|
+
/** Enable/disable line wrapping (None = use global setting) */
|
|
258
|
+
line_wrap?: boolean | null;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Options for creating a virtual buffer in an existing split */
|
|
262
|
+
interface CreateVirtualBufferInExistingSplitOptions {
|
|
263
|
+
/** Display name (e.g., "*Commit Details*") */
|
|
264
|
+
name: string;
|
|
265
|
+
/** Mode name for buffer-local keybindings */
|
|
266
|
+
mode: string;
|
|
267
|
+
/** Whether the buffer is read-only */
|
|
268
|
+
read_only: boolean;
|
|
269
|
+
/** Entries with text and embedded properties */
|
|
270
|
+
entries: TextPropertyEntry[];
|
|
271
|
+
/** Target split ID where the buffer should be displayed */
|
|
272
|
+
split_id: number;
|
|
273
|
+
/** Whether to show line numbers in the buffer (default true) */
|
|
274
|
+
show_line_numbers?: boolean | null;
|
|
275
|
+
/** Whether to show cursors in the buffer (default true) */
|
|
276
|
+
show_cursors?: boolean | null;
|
|
277
|
+
/** Whether editing is disabled for this buffer (default false) */
|
|
278
|
+
editing_disabled?: boolean | null;
|
|
279
|
+
/** Enable/disable line wrapping (None = use global setting) */
|
|
280
|
+
line_wrap?: boolean | null;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Options for creating a virtual buffer in the current split as a new tab */
|
|
284
|
+
interface CreateVirtualBufferInCurrentSplitOptions {
|
|
285
|
+
/** Display name (e.g., "*Help*") */
|
|
286
|
+
name: string;
|
|
287
|
+
/** Mode name for buffer-local keybindings */
|
|
288
|
+
mode: string;
|
|
289
|
+
/** Whether the buffer is read-only */
|
|
290
|
+
read_only: boolean;
|
|
291
|
+
/** Entries with text and embedded properties */
|
|
292
|
+
entries: TextPropertyEntry[];
|
|
293
|
+
/** Whether to show line numbers in the buffer (default false for help/docs) */
|
|
294
|
+
show_line_numbers?: boolean | null;
|
|
295
|
+
/** Whether to show cursors in the buffer (default true) */
|
|
296
|
+
show_cursors?: boolean | null;
|
|
297
|
+
/** Whether editing is disabled for this buffer (default false) */
|
|
298
|
+
editing_disabled?: boolean | null;
|
|
299
|
+
/** Whether this buffer should be hidden from tabs (for composite source buffers) */
|
|
300
|
+
hidden_from_tabs?: boolean | null;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** Layout configuration for composite buffers */
|
|
304
|
+
interface TsCompositeLayoutConfig {
|
|
305
|
+
/** Layout type: "side-by-side", "stacked", or "unified" */
|
|
306
|
+
layout_type: string;
|
|
307
|
+
/** Relative widths for side-by-side layout (e.g., [0.5, 0.5]) */
|
|
308
|
+
ratios?: number[] | null;
|
|
309
|
+
/** Show separator between panes */
|
|
310
|
+
show_separator?: boolean | null;
|
|
311
|
+
/** Spacing between stacked panes */
|
|
312
|
+
spacing?: u16 | null;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** Pane style configuration */
|
|
316
|
+
interface TsCompositePaneStyle {
|
|
317
|
+
/** Background color for added lines (RGB tuple) */
|
|
318
|
+
add_bg?: [number, number, number] | null;
|
|
319
|
+
/** Background color for removed lines (RGB tuple) */
|
|
320
|
+
remove_bg?: [number, number, number] | null;
|
|
321
|
+
/** Background color for modified lines (RGB tuple) */
|
|
322
|
+
modify_bg?: [number, number, number] | null;
|
|
323
|
+
/** Gutter style: "line-numbers", "diff-markers", "both", "none" */
|
|
324
|
+
gutter_style?: string | null;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** Source pane configuration for composite buffers */
|
|
328
|
+
interface TsCompositeSourceConfig {
|
|
329
|
+
/** Buffer ID to display in this pane */
|
|
330
|
+
buffer_id: number;
|
|
331
|
+
/** Label for the pane (shown in header) */
|
|
332
|
+
label?: string | null;
|
|
333
|
+
/** Whether the pane is editable */
|
|
334
|
+
editable: boolean;
|
|
335
|
+
/** Pane styling options */
|
|
336
|
+
style?: TsCompositePaneStyle | null;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** Diff hunk configuration */
|
|
340
|
+
interface TsCompositeHunk {
|
|
341
|
+
/** Start line in old file (0-indexed) */
|
|
342
|
+
old_start: number;
|
|
343
|
+
/** Number of lines in old file */
|
|
344
|
+
old_count: number;
|
|
345
|
+
/** Start line in new file (0-indexed) */
|
|
346
|
+
new_start: number;
|
|
347
|
+
/** Number of lines in new file */
|
|
348
|
+
new_count: number;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** Options for creating a composite buffer */
|
|
352
|
+
interface CreateCompositeBufferOptions {
|
|
353
|
+
/** Display name for the composite buffer (shown in tab) */
|
|
354
|
+
name: string;
|
|
355
|
+
/** Mode for keybindings (e.g., "diff-view") */
|
|
356
|
+
mode: string;
|
|
357
|
+
/** Layout configuration */
|
|
358
|
+
layout: TsCompositeLayoutConfig;
|
|
359
|
+
/** Source panes to display */
|
|
360
|
+
sources: TsCompositeSourceConfig[];
|
|
361
|
+
/** Optional diff hunks for line alignment */
|
|
362
|
+
hunks?: TsCompositeHunk[] | null;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** JavaScript representation of ActionSpec (with optional count) */
|
|
366
|
+
interface ActionSpecJs {
|
|
367
|
+
action: string;
|
|
368
|
+
count?: number | null;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/** TypeScript struct for action popup action */
|
|
372
|
+
interface TsActionPopupAction {
|
|
373
|
+
id: string;
|
|
374
|
+
label: string;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** TypeScript struct for action popup options */
|
|
378
|
+
interface TsActionPopupOptions {
|
|
379
|
+
id: string;
|
|
380
|
+
title: string;
|
|
381
|
+
message: string;
|
|
382
|
+
actions: TsActionPopupAction[];
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Main editor API interface
|
|
387
|
+
*/
|
|
388
|
+
interface EditorAPI {
|
|
389
|
+
// === Status and Logging ===
|
|
390
|
+
/**
|
|
391
|
+
* Display a transient message in the editor's status bar
|
|
392
|
+
*
|
|
393
|
+
* The message will be shown until the next status update or user action.
|
|
394
|
+
* Use for feedback on completed operations (e.g., "File saved", "2 matches found").
|
|
395
|
+
* @param message - Text to display; keep short (status bar has limited width)
|
|
396
|
+
*/
|
|
397
|
+
setStatus(message: string): void;
|
|
398
|
+
/**
|
|
399
|
+
* Log a debug message from a plugin
|
|
400
|
+
*
|
|
401
|
+
* Messages appear in log file when running with RUST_LOG=debug.
|
|
402
|
+
* Useful for plugin development and troubleshooting.
|
|
403
|
+
* @param message - Debug message; include context like function name and relevant values
|
|
404
|
+
*/
|
|
405
|
+
debug(message: string): void;
|
|
406
|
+
|
|
407
|
+
// === Buffer Queries ===
|
|
408
|
+
/**
|
|
409
|
+
* Get the theme JSON Schema for the theme editor
|
|
410
|
+
*
|
|
411
|
+
* Returns the raw JSON Schema generated by schemars for ThemeFile.
|
|
412
|
+
* The schema uses standard JSON Schema format with $ref for type references.
|
|
413
|
+
* Plugins are responsible for parsing the schema and resolving $ref references.
|
|
414
|
+
* @returns JSON Schema object
|
|
415
|
+
*/
|
|
416
|
+
getThemeSchema(): unknown;
|
|
417
|
+
getBuiltinThemes(): unknown;
|
|
418
|
+
/**
|
|
419
|
+
* Get the current editor configuration
|
|
420
|
+
*
|
|
421
|
+
* Returns the merged configuration (user config file + compiled-in defaults).
|
|
422
|
+
* This is the runtime config that the editor is actually using, including
|
|
423
|
+
* all default values for LSP servers, languages, keybindings, etc.
|
|
424
|
+
* @returns Configuration object
|
|
425
|
+
*/
|
|
426
|
+
getConfig(): unknown;
|
|
427
|
+
/**
|
|
428
|
+
* Get the user's configuration (only explicitly set values)
|
|
429
|
+
*
|
|
430
|
+
* Returns only the configuration from the user's config file.
|
|
431
|
+
* Fields not present here are using default values.
|
|
432
|
+
* Use this with getConfig() to determine which values are defaults.
|
|
433
|
+
* @returns User configuration object (sparse - only explicitly set values)
|
|
434
|
+
*/
|
|
435
|
+
getUserConfig(): unknown;
|
|
436
|
+
/**
|
|
437
|
+
* Get the user configuration directory path
|
|
438
|
+
*
|
|
439
|
+
* Returns the absolute path to the directory where user config and themes are stored.
|
|
440
|
+
* e.g. ~/.config/fresh/ on Linux or ~/Library/Application Support/fresh/ on macOS.
|
|
441
|
+
*/
|
|
442
|
+
getConfigDir(): string;
|
|
443
|
+
/**
|
|
444
|
+
* Get the user themes directory path
|
|
445
|
+
*
|
|
446
|
+
* Returns the absolute path to the directory where user themes are stored.
|
|
447
|
+
* e.g. ~/.config/fresh/themes/
|
|
448
|
+
*/
|
|
449
|
+
getThemesDir(): string;
|
|
450
|
+
/**
|
|
451
|
+
* Get the buffer ID of the focused editor pane
|
|
452
|
+
*
|
|
453
|
+
* Returns 0 if no buffer is active (rare edge case).
|
|
454
|
+
* Use this ID with other buffer operations like insertText.
|
|
455
|
+
*/
|
|
456
|
+
getActiveBufferId(): number;
|
|
457
|
+
/**
|
|
458
|
+
* Get the byte offset of the primary cursor in the active buffer
|
|
459
|
+
*
|
|
460
|
+
* Returns 0 if no cursor exists. For multi-cursor scenarios, use getAllCursors
|
|
461
|
+
* to get all cursor positions with selection info.
|
|
462
|
+
* Note: This is a byte offset, not a character index (UTF-8 matters).
|
|
463
|
+
*/
|
|
464
|
+
getCursorPosition(): number;
|
|
465
|
+
/**
|
|
466
|
+
* Get the absolute file path for a buffer
|
|
467
|
+
*
|
|
468
|
+
* Returns empty string for unsaved buffers or virtual buffers.
|
|
469
|
+
* The path is always absolute. Use this to determine file type,
|
|
470
|
+
* construct related paths, or display to the user.
|
|
471
|
+
* @param buffer_id - Target buffer ID
|
|
472
|
+
*/
|
|
473
|
+
getBufferPath(buffer_id: number): string;
|
|
474
|
+
/**
|
|
475
|
+
* Get the total byte length of a buffer's content
|
|
476
|
+
*
|
|
477
|
+
* Returns 0 if buffer doesn't exist.
|
|
478
|
+
* @param buffer_id - Target buffer ID
|
|
479
|
+
*/
|
|
480
|
+
getBufferLength(buffer_id: number): number;
|
|
481
|
+
/**
|
|
482
|
+
* Check if a buffer has been modified since last save
|
|
483
|
+
*
|
|
484
|
+
* Returns false if buffer doesn't exist or has never been saved.
|
|
485
|
+
* Virtual buffers are never considered modified.
|
|
486
|
+
* @param buffer_id - Target buffer ID
|
|
487
|
+
*/
|
|
488
|
+
isBufferModified(buffer_id: number): boolean;
|
|
489
|
+
/** Get the currently active locale */
|
|
490
|
+
getCurrentLocale(): string;
|
|
491
|
+
/**
|
|
492
|
+
* Get the ID of the focused split pane
|
|
493
|
+
*
|
|
494
|
+
* Use with focusSplit, setSplitBuffer, or createVirtualBufferInExistingSplit
|
|
495
|
+
* to manage split layouts.
|
|
496
|
+
*/
|
|
497
|
+
getActiveSplitId(): number;
|
|
498
|
+
/**
|
|
499
|
+
* Get the line number of the primary cursor (1-indexed)
|
|
500
|
+
*
|
|
501
|
+
* Line numbers start at 1. Returns 1 if no cursor exists.
|
|
502
|
+
* For byte offset use getCursorPosition instead.
|
|
503
|
+
*/
|
|
504
|
+
getCursorLine(): number;
|
|
505
|
+
/**
|
|
506
|
+
* Get byte offsets of all cursors (multi-cursor support)
|
|
507
|
+
*
|
|
508
|
+
* Returns array of positions; empty if no cursors. Primary cursor
|
|
509
|
+
* is typically first. For selection info use getAllCursors instead.
|
|
510
|
+
*/
|
|
511
|
+
getAllCursorPositions(): number[];
|
|
512
|
+
/**
|
|
513
|
+
* Check if a background process is still running
|
|
514
|
+
*
|
|
515
|
+
* @param process_id - ID returned from spawnBackgroundProcess
|
|
516
|
+
* @returns true if process is running, false if not found or exited
|
|
517
|
+
*/
|
|
518
|
+
isProcessRunning(#[bigint] process_id: number): boolean;
|
|
519
|
+
/** Compute syntax highlighting for a buffer range */
|
|
520
|
+
getHighlights(buffer_id: number, start: number, end: number): Promise<TsHighlightSpan[]>;
|
|
521
|
+
/** Get diff vs last saved snapshot for a buffer */
|
|
522
|
+
getBufferSavedDiff(buffer_id: number): TsBufferSavedDiff | null;
|
|
523
|
+
/**
|
|
524
|
+
* Get all LSP diagnostics across all files
|
|
525
|
+
* @returns Array of Diagnostic objects with file URI, severity, message, and range
|
|
526
|
+
*/
|
|
527
|
+
getAllDiagnostics(): TsDiagnostic[];
|
|
528
|
+
/**
|
|
529
|
+
* Get text from a buffer range
|
|
530
|
+
*
|
|
531
|
+
* Used by vi mode plugin for yank operations - reads text without deleting.
|
|
532
|
+
* @param buffer_id - Buffer ID
|
|
533
|
+
* @param start - Start byte offset
|
|
534
|
+
* @param end - End byte offset
|
|
535
|
+
* @returns Text content of the range, or empty string on error
|
|
536
|
+
*/
|
|
537
|
+
getBufferText(buffer_id: number, start: number, end: number): Promise<string>;
|
|
538
|
+
/**
|
|
539
|
+
* Get the current global editor mode
|
|
540
|
+
*
|
|
541
|
+
* @returns Current mode name or null if no mode is active
|
|
542
|
+
*/
|
|
543
|
+
getEditorMode(): string;
|
|
544
|
+
|
|
545
|
+
// === Buffer Info Queries ===
|
|
546
|
+
/**
|
|
547
|
+
* Get full information about a buffer
|
|
548
|
+
* @param buffer_id - Buffer ID
|
|
549
|
+
* @returns BufferInfo object or null if buffer not found
|
|
550
|
+
*/
|
|
551
|
+
getBufferInfo(buffer_id: number): BufferInfo | null;
|
|
552
|
+
/**
|
|
553
|
+
* List all open buffers
|
|
554
|
+
* @returns Array of BufferInfo objects
|
|
555
|
+
*/
|
|
556
|
+
listBuffers(): BufferInfo[];
|
|
557
|
+
/**
|
|
558
|
+
* Get primary cursor with selection info
|
|
559
|
+
* @returns CursorInfo object or null if no cursor
|
|
560
|
+
*/
|
|
561
|
+
getPrimaryCursor(): CursorInfo | null;
|
|
562
|
+
/**
|
|
563
|
+
* Get all cursors (for multi-cursor support)
|
|
564
|
+
* @returns Array of CursorInfo objects
|
|
565
|
+
*/
|
|
566
|
+
getAllCursors(): CursorInfo[];
|
|
567
|
+
/**
|
|
568
|
+
* Get viewport information
|
|
569
|
+
* @returns ViewportInfo object or null if no viewport
|
|
570
|
+
*/
|
|
571
|
+
getViewport(): ViewportInfo | null;
|
|
572
|
+
|
|
573
|
+
// === Prompt Operations ===
|
|
574
|
+
/**
|
|
575
|
+
* Start an interactive prompt
|
|
576
|
+
* @param label - Label to display (e.g., "Git grep: ")
|
|
577
|
+
* @param prompt_type - Type identifier (e.g., "git-grep")
|
|
578
|
+
* @returns true if prompt was started successfully
|
|
579
|
+
*/
|
|
580
|
+
startPrompt(label: string, prompt_type: string): boolean;
|
|
581
|
+
/**
|
|
582
|
+
* Set suggestions for the current prompt
|
|
583
|
+
* @param suggestions - Array of suggestions to display
|
|
584
|
+
* @returns true if suggestions were set successfully
|
|
585
|
+
*/
|
|
586
|
+
setPromptSuggestions(suggestions: PromptSuggestion[]): boolean;
|
|
587
|
+
|
|
588
|
+
// === Buffer Mutations ===
|
|
589
|
+
/**
|
|
590
|
+
* Apply a theme by name
|
|
591
|
+
*
|
|
592
|
+
* Loads and applies the specified theme immediately. The theme can be a built-in
|
|
593
|
+
* theme name or a custom theme from the themes directory.
|
|
594
|
+
* @param theme_name - Name of the theme to apply (e.g., "dark", "light", "my-custom-theme")
|
|
595
|
+
*/
|
|
596
|
+
applyTheme(theme_name: string): void;
|
|
597
|
+
/**
|
|
598
|
+
* Reload configuration from file
|
|
599
|
+
*
|
|
600
|
+
* After a plugin saves config changes to the config file, call this to reload
|
|
601
|
+
* the editor's in-memory configuration. This ensures the editor and plugins
|
|
602
|
+
* stay in sync with the saved config.
|
|
603
|
+
*/
|
|
604
|
+
reloadConfig(): void;
|
|
605
|
+
/**
|
|
606
|
+
* Log an error message from a plugin
|
|
607
|
+
*
|
|
608
|
+
* Messages appear in log file when running with RUST_LOG=error.
|
|
609
|
+
* Use for critical errors that need attention.
|
|
610
|
+
* @param message - Error message
|
|
611
|
+
*/
|
|
612
|
+
error(message: string): void;
|
|
613
|
+
/**
|
|
614
|
+
* Log a warning message from a plugin
|
|
615
|
+
*
|
|
616
|
+
* Messages appear in log file when running with RUST_LOG=warn.
|
|
617
|
+
* Use for warnings that don't prevent operation but indicate issues.
|
|
618
|
+
* @param message - Warning message
|
|
619
|
+
*/
|
|
620
|
+
warn(message: string): void;
|
|
621
|
+
/**
|
|
622
|
+
* Log an info message from a plugin
|
|
623
|
+
*
|
|
624
|
+
* Messages appear in log file when running with RUST_LOG=info.
|
|
625
|
+
* Use for important operational messages.
|
|
626
|
+
* @param message - Info message
|
|
627
|
+
*/
|
|
628
|
+
info(message: string): void;
|
|
629
|
+
/**
|
|
630
|
+
* Copy text to the system clipboard
|
|
631
|
+
*
|
|
632
|
+
* Copies the provided text to both the internal and system clipboard.
|
|
633
|
+
* Uses OSC 52 and arboard for cross-platform compatibility.
|
|
634
|
+
* @param text - Text to copy to clipboard
|
|
635
|
+
*/
|
|
636
|
+
setClipboard(text: string): void;
|
|
637
|
+
/**
|
|
638
|
+
* Insert text at a byte position in a buffer
|
|
639
|
+
*
|
|
640
|
+
* Text is inserted before the byte at position. Position must be valid
|
|
641
|
+
* (0 to buffer length). Insertion shifts all text after position.
|
|
642
|
+
* Operation is asynchronous; returns true if command was sent successfully.
|
|
643
|
+
* @param buffer_id - Target buffer ID
|
|
644
|
+
* @param position - Byte offset where text will be inserted (must be at char boundary)
|
|
645
|
+
* @param text - UTF-8 text to insert
|
|
646
|
+
*/
|
|
647
|
+
insertText(buffer_id: number, position: number, text: string): boolean;
|
|
648
|
+
/**
|
|
649
|
+
* Delete a byte range from a buffer
|
|
650
|
+
*
|
|
651
|
+
* Deletes bytes from start (inclusive) to end (exclusive).
|
|
652
|
+
* Both positions must be at valid UTF-8 char boundaries.
|
|
653
|
+
* Operation is asynchronous; returns true if command was sent successfully.
|
|
654
|
+
* @param buffer_id - Target buffer ID
|
|
655
|
+
* @param start - Start byte offset (inclusive)
|
|
656
|
+
* @param end - End byte offset (exclusive)
|
|
657
|
+
*/
|
|
658
|
+
deleteRange(buffer_id: number, start: number, end: number): boolean;
|
|
659
|
+
/**
|
|
660
|
+
* Clear all overlays in a namespace
|
|
661
|
+
* @param buffer_id - The buffer ID
|
|
662
|
+
* @param namespace - The namespace to clear
|
|
663
|
+
* @returns true if successful
|
|
664
|
+
*/
|
|
665
|
+
clearNamespace(buffer_id: number, namespace: string): boolean;
|
|
666
|
+
/**
|
|
667
|
+
* Enable/disable line numbers for a buffer
|
|
668
|
+
* @param buffer_id - The buffer ID
|
|
669
|
+
* @param enabled - Whether to show line numbers
|
|
670
|
+
* @returns true if successful
|
|
671
|
+
*/
|
|
672
|
+
setLineNumbers(buffer_id: number, enabled: boolean): boolean;
|
|
673
|
+
/**
|
|
674
|
+
* Add a virtual line above or below a source line
|
|
675
|
+
* @param buffer_id - The buffer ID
|
|
676
|
+
* @param position - Byte position to anchor the virtual line to
|
|
677
|
+
* @param text - The text content of the virtual line
|
|
678
|
+
* @param fg_r - Foreground red color component (0-255)
|
|
679
|
+
* @param fg_g - Foreground green color component (0-255)
|
|
680
|
+
* @param fg_b - Foreground blue color component (0-255)
|
|
681
|
+
* @param bg_r - Background red color component (0-255), -1 for transparent
|
|
682
|
+
* @param bg_g - Background green color component (0-255), -1 for transparent
|
|
683
|
+
* @param bg_b - Background blue color component (0-255), -1 for transparent
|
|
684
|
+
* @param above - Whether to insert above (true) or below (false) the line
|
|
685
|
+
* @param namespace - Namespace for bulk removal (e.g., "git-blame")
|
|
686
|
+
* @param priority - Priority for ordering multiple lines at same position
|
|
687
|
+
* @returns true if virtual line was added
|
|
688
|
+
*/
|
|
689
|
+
addVirtualLine(buffer_id: number, position: number, text: string, fg_r: number, fg_g: number, fg_b: number, bg_r: i16, bg_g: i16, bg_b: i16, above: boolean, namespace: string, priority: number): boolean;
|
|
690
|
+
/**
|
|
691
|
+
* Set a line indicator in the gutter's indicator column
|
|
692
|
+
* @param buffer_id - The buffer ID
|
|
693
|
+
* @param line - Line number (0-indexed)
|
|
694
|
+
* @param namespace - Namespace for grouping (e.g., "git-gutter", "breakpoints")
|
|
695
|
+
* @param symbol - Symbol to display (e.g., "│", "●", "★")
|
|
696
|
+
* @param r - Red color component (0-255)
|
|
697
|
+
* @param g - Green color component (0-255)
|
|
698
|
+
* @param b - Blue color component (0-255)
|
|
699
|
+
* @param priority - Priority for display when multiple indicators exist (higher wins)
|
|
700
|
+
* @returns true if indicator was set
|
|
701
|
+
*/
|
|
702
|
+
setLineIndicator(buffer_id: number, line: number, namespace: string, symbol: string, r: number, g: number, b: number, priority: number): boolean;
|
|
703
|
+
/**
|
|
704
|
+
* Clear all line indicators for a specific namespace
|
|
705
|
+
* @param buffer_id - The buffer ID
|
|
706
|
+
* @param namespace - Namespace to clear (e.g., "git-gutter")
|
|
707
|
+
* @returns true if indicators were cleared
|
|
708
|
+
*/
|
|
709
|
+
clearLineIndicators(buffer_id: number, namespace: string): boolean;
|
|
710
|
+
/**
|
|
711
|
+
* Submit a transformed view stream for a viewport
|
|
712
|
+
* @param buffer_id - Buffer to apply the transform to
|
|
713
|
+
* @param start - Viewport start byte
|
|
714
|
+
* @param end - Viewport end byte
|
|
715
|
+
* @param tokens - Array of tokens with source offsets
|
|
716
|
+
* @param source_map - Array of source offsets (null for injected)
|
|
717
|
+
* @param layout_hints - Optional layout hints (compose width, column guides)
|
|
718
|
+
*/
|
|
719
|
+
submitViewTransform(buffer_id: number, split_id?: number | null, start: number, end: number, tokens: ViewTokenWire[], layout_hints?: LayoutHints | null): boolean;
|
|
720
|
+
/**
|
|
721
|
+
* Clear view transform for a buffer/split (returns to normal rendering)
|
|
722
|
+
* @param buffer_id - Buffer ID
|
|
723
|
+
* @param split_id - Optional split ID (uses active split if not specified)
|
|
724
|
+
* @returns true if clear succeeded
|
|
725
|
+
*/
|
|
726
|
+
clearViewTransform(buffer_id: number, split_id?: number | null): boolean;
|
|
727
|
+
/**
|
|
728
|
+
* Insert text at the current cursor position in the active buffer
|
|
729
|
+
* @param text - The text to insert
|
|
730
|
+
* @returns true if insertion succeeded
|
|
731
|
+
*/
|
|
732
|
+
insertAtCursor(text: string): boolean;
|
|
733
|
+
/** Translate a string for a plugin using the current locale */
|
|
734
|
+
pluginTranslate(plugin_name: string, key: string, args: Record<string, unknown>): string;
|
|
735
|
+
/** Register a custom command that can be triggered by keybindings or the command palette */
|
|
736
|
+
registerCommand(name: string, description: string, action: string, contexts: string, source: string): boolean;
|
|
737
|
+
/**
|
|
738
|
+
* Unregister a custom command by name
|
|
739
|
+
* @param name - The name of the command to unregister
|
|
740
|
+
* @returns true if the command was successfully unregistered
|
|
741
|
+
*/
|
|
742
|
+
unregisterCommand(name: string): boolean;
|
|
743
|
+
/**
|
|
744
|
+
* Set or unset a custom context for command visibility
|
|
745
|
+
* Custom contexts allow plugins to control when their commands are available.
|
|
746
|
+
* For example, setting "config-editor" context makes config editor commands visible.
|
|
747
|
+
* @param name - Context name (e.g., "config-editor")
|
|
748
|
+
* @param active - Whether the context is active (true = set, false = unset)
|
|
749
|
+
* @returns true if the context was updated
|
|
750
|
+
*/
|
|
751
|
+
setContext(name: string, active: boolean): boolean;
|
|
752
|
+
/**
|
|
753
|
+
* Open a file in the editor, optionally at a specific location
|
|
754
|
+
* @param path - File path to open
|
|
755
|
+
* @param line - Line number to jump to (0 for no jump)
|
|
756
|
+
* @param column - Column number to jump to (0 for no jump)
|
|
757
|
+
* @returns true if file was opened
|
|
758
|
+
*/
|
|
759
|
+
openFile(path: string, line: number, column: number): boolean;
|
|
760
|
+
/**
|
|
761
|
+
* Open a file in a specific split pane
|
|
762
|
+
* @param split_id - The split ID to open the file in
|
|
763
|
+
* @param path - File path to open
|
|
764
|
+
* @param line - Line number to jump to (0 for no jump)
|
|
765
|
+
* @param column - Column number to jump to (0 for no jump)
|
|
766
|
+
* @returns true if file was opened
|
|
767
|
+
*/
|
|
768
|
+
openFileInSplit(split_id: number, path: string, line: number, column: number): boolean;
|
|
769
|
+
/**
|
|
770
|
+
* Spawn a long-running background process
|
|
771
|
+
*
|
|
772
|
+
* Unlike spawnProcess which waits for completion, this starts a process
|
|
773
|
+
* in the background and returns immediately with a process ID.
|
|
774
|
+
* Use killProcess(id) to terminate the process later.
|
|
775
|
+
* Use isProcessRunning(id) to check if it's still running.
|
|
776
|
+
*
|
|
777
|
+
* @param command - Program name (searched in PATH) or absolute path
|
|
778
|
+
* @param args - Command arguments (each array element is one argument)
|
|
779
|
+
* @param cwd - Working directory; null uses editor's cwd
|
|
780
|
+
* @returns Object with process_id for later reference
|
|
781
|
+
* @example
|
|
782
|
+
* const proc = await editor.spawnBackgroundProcess("asciinema", ["rec", "output.cast"]);
|
|
783
|
+
* // Later...
|
|
784
|
+
* await editor.killProcess(proc.process_id);
|
|
785
|
+
*/
|
|
786
|
+
spawnBackgroundProcess(command: string, args: string[], cwd?: string | null): Promise<BackgroundProcessResult>;
|
|
787
|
+
/**
|
|
788
|
+
* Kill a background or cancellable process by ID
|
|
789
|
+
*
|
|
790
|
+
* Sends SIGTERM to gracefully terminate the process.
|
|
791
|
+
* Returns true if the process was found and killed, false if not found.
|
|
792
|
+
*
|
|
793
|
+
* @param process_id - ID returned from spawnBackgroundProcess or spawnProcessStart
|
|
794
|
+
* @returns true if process was killed, false if not found
|
|
795
|
+
*/
|
|
796
|
+
killProcess(#[bigint] process_id: number): Promise<boolean>;
|
|
797
|
+
/**
|
|
798
|
+
* Wait for a cancellable process to complete and get its result
|
|
799
|
+
*
|
|
800
|
+
* @param process_id - ID returned from spawnProcessStart
|
|
801
|
+
* @returns SpawnResult with stdout, stderr, and exit_code
|
|
802
|
+
*/
|
|
803
|
+
spawnProcessWait(#[bigint] process_id: number): Promise<SpawnResult>;
|
|
804
|
+
/**
|
|
805
|
+
* Delay execution for a specified number of milliseconds
|
|
806
|
+
*
|
|
807
|
+
* Useful for debouncing user input or adding delays between operations.
|
|
808
|
+
* @param ms - Number of milliseconds to delay
|
|
809
|
+
* @example
|
|
810
|
+
* await editor.delay(100); // Wait 100ms
|
|
811
|
+
*/
|
|
812
|
+
delay(#[bigint] ms: number): Promise<[]>;
|
|
813
|
+
/** Find a buffer ID by its file path */
|
|
814
|
+
findBufferByPath(path: string): number;
|
|
815
|
+
/**
|
|
816
|
+
* Start a prompt with pre-filled initial value
|
|
817
|
+
* @param label - Label to display (e.g., "Git grep: ")
|
|
818
|
+
* @param prompt_type - Type identifier (e.g., "git-grep")
|
|
819
|
+
* @param initial_value - Initial text to pre-fill in the prompt
|
|
820
|
+
* @returns true if prompt was started successfully
|
|
821
|
+
*/
|
|
822
|
+
startPromptWithInitial(label: string, prompt_type: string, initial_value: string): boolean;
|
|
823
|
+
/**
|
|
824
|
+
* Delete a theme file by name
|
|
825
|
+
*
|
|
826
|
+
* Only deletes files from the user's themes directory.
|
|
827
|
+
* This is a safe operation that prevents plugins from deleting arbitrary files.
|
|
828
|
+
* @param name - Theme name (without .json extension)
|
|
829
|
+
*/
|
|
830
|
+
deleteTheme(name: string): Promise<[]>;
|
|
831
|
+
/**
|
|
832
|
+
* Create a composite buffer that displays multiple source buffers
|
|
833
|
+
*
|
|
834
|
+
* Composite buffers allow displaying multiple underlying buffers in a single
|
|
835
|
+
* tab/view area with custom layouts (side-by-side, stacked, unified).
|
|
836
|
+
* This is useful for diff views, merge conflict resolution, etc.
|
|
837
|
+
* @param options - Configuration for the composite buffer
|
|
838
|
+
* @returns Promise resolving to the buffer ID of the created composite buffer
|
|
839
|
+
*/
|
|
840
|
+
createCompositeBuffer(options: CreateCompositeBufferOptions): Promise<number>;
|
|
841
|
+
/**
|
|
842
|
+
* Update line alignment for a composite buffer
|
|
843
|
+
* @param buffer_id - The composite buffer ID
|
|
844
|
+
* @param hunks - New diff hunks for alignment
|
|
845
|
+
*/
|
|
846
|
+
updateCompositeAlignment(buffer_id: number, hunks: TsCompositeHunk[]): boolean;
|
|
847
|
+
/**
|
|
848
|
+
* Close a composite buffer
|
|
849
|
+
* @param buffer_id - The composite buffer ID to close
|
|
850
|
+
*/
|
|
851
|
+
closeCompositeBuffer(buffer_id: number): boolean;
|
|
852
|
+
/**
|
|
853
|
+
* Send an arbitrary LSP request and receive the raw JSON response
|
|
854
|
+
* @param language - Language ID (e.g., "cpp")
|
|
855
|
+
* @param method - Full LSP method (e.g., "textDocument/switchSourceHeader")
|
|
856
|
+
* @param params - Optional request payload
|
|
857
|
+
* @returns Promise resolving to the JSON response value
|
|
858
|
+
*/
|
|
859
|
+
sendLspRequest(language: string, method: string, params?: unknown | null): Promise<unknown>;
|
|
860
|
+
/**
|
|
861
|
+
* Set the scroll position of a specific split
|
|
862
|
+
* @param split_id - The split ID
|
|
863
|
+
* @param top_byte - The byte offset of the top visible line
|
|
864
|
+
* @returns true if successful
|
|
865
|
+
*/
|
|
866
|
+
setSplitScroll(split_id: number, top_byte: number): boolean;
|
|
867
|
+
/**
|
|
868
|
+
* Set the ratio of a split container
|
|
869
|
+
* @param split_id - ID of the split
|
|
870
|
+
* @param ratio - Ratio between 0.0 and 1.0 (0.5 = equal split)
|
|
871
|
+
* @returns true if the ratio was set successfully
|
|
872
|
+
*/
|
|
873
|
+
setSplitRatio(split_id: number, ratio: number): boolean;
|
|
874
|
+
/**
|
|
875
|
+
* Distribute all visible splits evenly
|
|
876
|
+
* This adjusts the ratios of all container splits so each leaf split gets equal space
|
|
877
|
+
* @returns true if the command was sent successfully
|
|
878
|
+
*/
|
|
879
|
+
distributeSplitsEvenly(): boolean;
|
|
880
|
+
/**
|
|
881
|
+
* Set cursor position in a buffer (also scrolls viewport to show cursor)
|
|
882
|
+
* @param buffer_id - ID of the buffer
|
|
883
|
+
* @param position - Byte offset position for the cursor
|
|
884
|
+
* @returns true if the command was sent successfully
|
|
885
|
+
*/
|
|
886
|
+
setBufferCursor(buffer_id: number, position: number): boolean;
|
|
887
|
+
/**
|
|
888
|
+
* Execute a built-in editor action by name
|
|
889
|
+
*
|
|
890
|
+
* This is used by vi mode plugin to run motions and then check cursor position.
|
|
891
|
+
* For example, to implement "dw" (delete word), the plugin:
|
|
892
|
+
* 1. Saves current cursor position
|
|
893
|
+
* 2. Calls executeAction("move_word_right") - cursor moves
|
|
894
|
+
* 3. Gets new cursor position
|
|
895
|
+
* 4. Deletes from old to new position
|
|
896
|
+
*
|
|
897
|
+
* @param action_name - Action name (e.g., "move_word_right", "move_line_end")
|
|
898
|
+
* @returns true if action was sent successfully
|
|
899
|
+
*/
|
|
900
|
+
executeAction(action_name: string): boolean;
|
|
901
|
+
/**
|
|
902
|
+
* Execute multiple actions in sequence, each with an optional repeat count
|
|
903
|
+
*
|
|
904
|
+
* Used by vi mode for count prefix (e.g., "3dw" = delete 3 words).
|
|
905
|
+
* All actions execute atomically with no plugin roundtrips between them.
|
|
906
|
+
*
|
|
907
|
+
* @param actions - Array of {action: string, count?: number} objects
|
|
908
|
+
* @returns true if actions were sent successfully
|
|
909
|
+
*/
|
|
910
|
+
executeActions(actions: ActionSpecJs[]): boolean;
|
|
911
|
+
/**
|
|
912
|
+
* Set the global editor mode (for modal editing like vi mode)
|
|
913
|
+
*
|
|
914
|
+
* When a mode is set, its keybindings take precedence over normal key handling.
|
|
915
|
+
* Pass null/undefined to clear the mode and return to normal editing.
|
|
916
|
+
*
|
|
917
|
+
* @param mode - Mode name (e.g., "vi-normal") or null to clear
|
|
918
|
+
* @returns true if command was sent successfully
|
|
919
|
+
*/
|
|
920
|
+
setEditorMode(mode?: string | null): boolean;
|
|
921
|
+
/**
|
|
922
|
+
* Show an action popup with buttons for user interaction
|
|
923
|
+
*
|
|
924
|
+
* When the user selects an action, the ActionPopupResult hook is fired.
|
|
925
|
+
* @param options - Popup configuration with id, title, message, and actions
|
|
926
|
+
*/
|
|
927
|
+
showActionPopup(options: TsActionPopupOptions): boolean;
|
|
928
|
+
/**
|
|
929
|
+
* Disable LSP for a specific language and persist to config
|
|
930
|
+
*
|
|
931
|
+
* This is used by LSP helper plugins to let users disable LSP for languages
|
|
932
|
+
* where the server is not available or not working.
|
|
933
|
+
* @param language - The language to disable LSP for (e.g., "python", "rust")
|
|
934
|
+
*/
|
|
935
|
+
disableLspForLanguage(language: string): boolean;
|
|
936
|
+
/**
|
|
937
|
+
* Create a scroll sync group for anchor-based synchronized scrolling
|
|
938
|
+
*
|
|
939
|
+
* Used for side-by-side diff views where two panes need to scroll together.
|
|
940
|
+
* The plugin provides the group ID (must be unique per plugin).
|
|
941
|
+
*/
|
|
942
|
+
createScrollSyncGroup(group_id: number, left_split: number, right_split: number): boolean;
|
|
943
|
+
/**
|
|
944
|
+
* Set sync anchors for a scroll sync group
|
|
945
|
+
*
|
|
946
|
+
* Anchors map corresponding line numbers between left and right buffers.
|
|
947
|
+
* Each anchor is a tuple of (left_line, right_line).
|
|
948
|
+
*/
|
|
949
|
+
setScrollSyncAnchors(group_id: number, anchors: Vec<(usize, usize): boolean;
|
|
950
|
+
/** Remove a scroll sync group */
|
|
951
|
+
removeScrollSyncGroup(group_id: number): boolean;
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* Spawn an external process and return a cancellable handle
|
|
955
|
+
*
|
|
956
|
+
* Returns a ProcessHandle that can be awaited for the result or killed early.
|
|
957
|
+
* The handle is also a PromiseLike, so `await spawnProcess(...)` works directly.
|
|
958
|
+
* @param command - Program name (searched in PATH) or absolute path
|
|
959
|
+
* @param args - Command arguments (each array element is one argument)
|
|
960
|
+
* @param cwd - Working directory; null uses editor's cwd
|
|
961
|
+
* @example
|
|
962
|
+
* // Simple usage (backward compatible)
|
|
963
|
+
* const result = await editor.spawnProcess("git", ["status"]);
|
|
964
|
+
*
|
|
965
|
+
* // Cancellable usage
|
|
966
|
+
* const search = editor.spawnProcess("rg", ["pattern"]);
|
|
967
|
+
* // ... later, if user types new query:
|
|
968
|
+
* search.kill(); // Cancel the search
|
|
969
|
+
*/
|
|
970
|
+
spawnProcess(command: string, args?: string[], cwd?: string | null): ProcessHandle;
|
|
971
|
+
// === Overlay Operations ===
|
|
972
|
+
/**
|
|
973
|
+
* Add a colored highlight overlay to text without modifying content
|
|
974
|
+
*
|
|
975
|
+
* Overlays are visual decorations that persist until explicitly removed.
|
|
976
|
+
* Add an overlay (visual decoration) to a buffer
|
|
977
|
+
* Use namespaces for easy batch removal (e.g., "spell", "todo").
|
|
978
|
+
* Multiple overlays can apply to the same range; colors blend.
|
|
979
|
+
* @param buffer_id - Target buffer ID
|
|
980
|
+
* @param namespace - Optional namespace for grouping (use clearNamespace for batch removal)
|
|
981
|
+
* @param start - Start byte offset
|
|
982
|
+
* @param end - End byte offset
|
|
983
|
+
* @param r - Red (0-255)
|
|
984
|
+
* @param g - Green (0-255)
|
|
985
|
+
* @param b - Blue (0-255)
|
|
986
|
+
* @param underline - Add underline decoration
|
|
987
|
+
* @param bold - Use bold text
|
|
988
|
+
* @param italic - Use italic text
|
|
989
|
+
* @param extend_to_line_end - Extend background to end of visual line
|
|
990
|
+
* @returns true if overlay was added
|
|
991
|
+
*/
|
|
992
|
+
addOverlay(buffer_id: number, namespace: string, start: number, end: number, r: number, g: number, b: number, bg_r: i16, bg_g: i16, bg_b: i16, underline: boolean, bold: boolean, italic: boolean, extend_to_line_end: boolean): boolean;
|
|
993
|
+
/**
|
|
994
|
+
* Remove a specific overlay by its handle
|
|
995
|
+
* @param buffer_id - The buffer ID
|
|
996
|
+
* @param handle - The overlay handle to remove
|
|
997
|
+
* @returns true if overlay was removed
|
|
998
|
+
*/
|
|
999
|
+
removeOverlay(buffer_id: number, handle: string): boolean;
|
|
1000
|
+
/**
|
|
1001
|
+
* Clear all overlays that overlap with a byte range
|
|
1002
|
+
* @param buffer_id - The buffer ID
|
|
1003
|
+
* @param start - Start byte position (inclusive)
|
|
1004
|
+
* @param end - End byte position (exclusive)
|
|
1005
|
+
* @returns true if successful
|
|
1006
|
+
*/
|
|
1007
|
+
clearOverlaysInRange(buffer_id: number, start: number, end: number): boolean;
|
|
1008
|
+
/**
|
|
1009
|
+
* Remove all overlays from a buffer
|
|
1010
|
+
* @param buffer_id - The buffer ID
|
|
1011
|
+
* @returns true if overlays were cleared
|
|
1012
|
+
*/
|
|
1013
|
+
clearAllOverlays(buffer_id: number): boolean;
|
|
1014
|
+
/**
|
|
1015
|
+
* Add virtual text (inline decoration) at a position
|
|
1016
|
+
* @param buffer_id - The buffer ID
|
|
1017
|
+
* @param virtual_text_id - Unique identifier for this virtual text
|
|
1018
|
+
* @param position - Byte position to insert at
|
|
1019
|
+
* @param text - The virtual text to display
|
|
1020
|
+
* @param r - Red color component (0-255)
|
|
1021
|
+
* @param g - Green color component (0-255)
|
|
1022
|
+
* @param b - Blue color component (0-255)
|
|
1023
|
+
* @param before - Whether to insert before (true) or after (false) the position
|
|
1024
|
+
* @param use_bg - Whether to use the color as background (true) or foreground (false)
|
|
1025
|
+
* @returns true if virtual text was added
|
|
1026
|
+
*/
|
|
1027
|
+
addVirtualText(buffer_id: number, virtual_text_id: string, position: number, text: string, r: number, g: number, b: number, before: boolean, use_bg: boolean): boolean;
|
|
1028
|
+
/**
|
|
1029
|
+
* Remove virtual text by ID
|
|
1030
|
+
* @param buffer_id - The buffer ID
|
|
1031
|
+
* @param virtual_text_id - The virtual text ID to remove
|
|
1032
|
+
* @returns true if virtual text was removed
|
|
1033
|
+
*/
|
|
1034
|
+
removeVirtualText(buffer_id: number, virtual_text_id: string): boolean;
|
|
1035
|
+
/**
|
|
1036
|
+
* Remove all virtual texts with IDs starting with a prefix
|
|
1037
|
+
* @param buffer_id - The buffer ID
|
|
1038
|
+
* @param prefix - The prefix to match virtual text IDs against
|
|
1039
|
+
* @returns true if any virtual texts were removed
|
|
1040
|
+
*/
|
|
1041
|
+
removeVirtualTextsByPrefix(buffer_id: number, prefix: string): boolean;
|
|
1042
|
+
/**
|
|
1043
|
+
* Remove all virtual texts from a buffer
|
|
1044
|
+
* @param buffer_id - The buffer ID
|
|
1045
|
+
* @returns true if virtual texts were cleared
|
|
1046
|
+
*/
|
|
1047
|
+
clearVirtualTexts(buffer_id: number): boolean;
|
|
1048
|
+
/**
|
|
1049
|
+
* Clear all virtual texts in a namespace
|
|
1050
|
+
* @param buffer_id - The buffer ID
|
|
1051
|
+
* @param namespace - The namespace to clear (e.g., "git-blame")
|
|
1052
|
+
* @returns true if namespace was cleared
|
|
1053
|
+
*/
|
|
1054
|
+
clearVirtualTextNamespace(buffer_id: number, namespace: string): boolean;
|
|
1055
|
+
/**
|
|
1056
|
+
* Force a refresh of line display for a buffer
|
|
1057
|
+
* @param buffer_id - The buffer ID
|
|
1058
|
+
* @returns true if refresh was triggered
|
|
1059
|
+
*/
|
|
1060
|
+
refreshLines(buffer_id: number): boolean;
|
|
1061
|
+
|
|
1062
|
+
// === File System Operations ===
|
|
1063
|
+
/**
|
|
1064
|
+
* Read entire file contents as UTF-8 string
|
|
1065
|
+
*
|
|
1066
|
+
* Throws if file doesn't exist, isn't readable, or isn't valid UTF-8.
|
|
1067
|
+
* For binary files, this will fail. For large files, consider memory usage.
|
|
1068
|
+
* @param path - File path (absolute or relative to cwd)
|
|
1069
|
+
*/
|
|
1070
|
+
readFile(path: string): Promise<string>;
|
|
1071
|
+
/**
|
|
1072
|
+
* Write string content to a NEW file (fails if file exists)
|
|
1073
|
+
*
|
|
1074
|
+
* Creates a new file with the given content. Fails if the file already exists
|
|
1075
|
+
* to prevent plugins from accidentally overwriting user data.
|
|
1076
|
+
* @param path - Destination path (absolute or relative to cwd)
|
|
1077
|
+
* @param content - UTF-8 string to write
|
|
1078
|
+
*/
|
|
1079
|
+
writeFile(path: string, content: string): Promise<[]>;
|
|
1080
|
+
/**
|
|
1081
|
+
* Check if a path exists (file, directory, or symlink)
|
|
1082
|
+
*
|
|
1083
|
+
* Does not follow symlinks; returns true for broken symlinks.
|
|
1084
|
+
* Use fileStat for more detailed information.
|
|
1085
|
+
* @param path - Path to check (absolute or relative to cwd)
|
|
1086
|
+
*/
|
|
1087
|
+
fileExists(path: string): boolean;
|
|
1088
|
+
/**
|
|
1089
|
+
* Get metadata about a file or directory
|
|
1090
|
+
*
|
|
1091
|
+
* Follows symlinks. Returns exists=false for non-existent paths
|
|
1092
|
+
* rather than throwing. Size is in bytes; directories may report 0.
|
|
1093
|
+
* @param path - Path to stat (absolute or relative to cwd)
|
|
1094
|
+
*/
|
|
1095
|
+
fileStat(path: string): FileStat;
|
|
1096
|
+
/**
|
|
1097
|
+
* List directory contents
|
|
1098
|
+
*
|
|
1099
|
+
* Returns unsorted entries with type info. Entry names are relative
|
|
1100
|
+
* to the directory (use pathJoin to construct full paths).
|
|
1101
|
+
* Throws on permission errors or if path is not a directory.
|
|
1102
|
+
* @param path - Directory path (absolute or relative to cwd)
|
|
1103
|
+
* @example
|
|
1104
|
+
* const entries = editor.readDir("/home/user");
|
|
1105
|
+
* for (const e of entries) {
|
|
1106
|
+
* const fullPath = editor.pathJoin("/home/user", e.name);
|
|
1107
|
+
* }
|
|
1108
|
+
*/
|
|
1109
|
+
readDir(path: string): DirEntry[];
|
|
1110
|
+
|
|
1111
|
+
// === Environment Operations ===
|
|
1112
|
+
/**
|
|
1113
|
+
* Get an environment variable
|
|
1114
|
+
* @param name - Name of environment variable
|
|
1115
|
+
* @returns Value if set, null if not set
|
|
1116
|
+
*/
|
|
1117
|
+
getEnv(name: string): string;
|
|
1118
|
+
/**
|
|
1119
|
+
* Get the editor's current working directory
|
|
1120
|
+
*
|
|
1121
|
+
* Returns the editor's working directory (set when the editor was started).
|
|
1122
|
+
* Use as base for resolving relative paths and spawning processes.
|
|
1123
|
+
* Note: This returns the editor's stored working_dir, not process CWD,
|
|
1124
|
+
* which is important for test isolation.
|
|
1125
|
+
*/
|
|
1126
|
+
getCwd(): string;
|
|
1127
|
+
|
|
1128
|
+
// === Path Operations ===
|
|
1129
|
+
/**
|
|
1130
|
+
* Join path segments using the OS path separator
|
|
1131
|
+
*
|
|
1132
|
+
* Handles empty segments and normalizes separators.
|
|
1133
|
+
* If a segment is absolute, previous segments are discarded.
|
|
1134
|
+
* @param parts - Path segments to join
|
|
1135
|
+
* @example
|
|
1136
|
+
* pathJoin("/home", "user", "file.txt") // "/home/user/file.txt"
|
|
1137
|
+
* pathJoin("relative", "/absolute") // "/absolute"
|
|
1138
|
+
*/
|
|
1139
|
+
pathJoin(parts: string[]): string;
|
|
1140
|
+
/**
|
|
1141
|
+
* Get the parent directory of a path
|
|
1142
|
+
*
|
|
1143
|
+
* Returns empty string for root paths or paths without parent.
|
|
1144
|
+
* Does not resolve symlinks or check existence.
|
|
1145
|
+
* @param path - File or directory path
|
|
1146
|
+
* @example
|
|
1147
|
+
* pathDirname("/home/user/file.txt") // "/home/user"
|
|
1148
|
+
* pathDirname("/") // ""
|
|
1149
|
+
*/
|
|
1150
|
+
pathDirname(path: string): string;
|
|
1151
|
+
/**
|
|
1152
|
+
* Get the final component of a path
|
|
1153
|
+
*
|
|
1154
|
+
* Returns empty string for root paths.
|
|
1155
|
+
* Does not strip file extension; use pathExtname for that.
|
|
1156
|
+
* @param path - File or directory path
|
|
1157
|
+
* @example
|
|
1158
|
+
* pathBasename("/home/user/file.txt") // "file.txt"
|
|
1159
|
+
* pathBasename("/home/user/") // "user"
|
|
1160
|
+
*/
|
|
1161
|
+
pathBasename(path: string): string;
|
|
1162
|
+
/**
|
|
1163
|
+
* Get the file extension including the dot
|
|
1164
|
+
*
|
|
1165
|
+
* Returns empty string if no extension. Only returns the last extension
|
|
1166
|
+
* for files like "archive.tar.gz" (returns ".gz").
|
|
1167
|
+
* @param path - File path
|
|
1168
|
+
* @example
|
|
1169
|
+
* pathExtname("file.txt") // ".txt"
|
|
1170
|
+
* pathExtname("archive.tar.gz") // ".gz"
|
|
1171
|
+
* pathExtname("Makefile") // ""
|
|
1172
|
+
*/
|
|
1173
|
+
pathExtname(path: string): string;
|
|
1174
|
+
/**
|
|
1175
|
+
* Check if a path is absolute
|
|
1176
|
+
*
|
|
1177
|
+
* On Unix: starts with "/". On Windows: starts with drive letter or UNC path.
|
|
1178
|
+
* @param path - Path to check
|
|
1179
|
+
*/
|
|
1180
|
+
pathIsAbsolute(path: string): boolean;
|
|
1181
|
+
|
|
1182
|
+
// === Event/Hook Operations ===
|
|
1183
|
+
/**
|
|
1184
|
+
* Subscribe to an editor event
|
|
1185
|
+
*
|
|
1186
|
+
* Handler must be a global function name (not a closure).
|
|
1187
|
+
* Multiple handlers can be registered for the same event.
|
|
1188
|
+
* Events: "buffer_save", "cursor_moved", "buffer_modified", etc.
|
|
1189
|
+
* @param event_name - Event to subscribe to
|
|
1190
|
+
* @param handler_name - Name of globalThis function to call with event data
|
|
1191
|
+
* @example
|
|
1192
|
+
* globalThis.onSave = (data) => {
|
|
1193
|
+
* editor.setStatus(`Saved: ${data.path}`);
|
|
1194
|
+
* };
|
|
1195
|
+
* editor.on("buffer_save", "onSave");
|
|
1196
|
+
*/
|
|
1197
|
+
on(event_name: string, handler_name: string): boolean;
|
|
1198
|
+
/**
|
|
1199
|
+
* Unregister an event handler
|
|
1200
|
+
* @param event_name - Name of the event
|
|
1201
|
+
* @param handler_name - Name of the handler to remove
|
|
1202
|
+
* @returns true if handler was found and removed
|
|
1203
|
+
*/
|
|
1204
|
+
off(event_name: string, handler_name: string): boolean;
|
|
1205
|
+
/**
|
|
1206
|
+
* Get list of registered handlers for an event
|
|
1207
|
+
* @param event_name - Name of the event
|
|
1208
|
+
* @returns Array of handler function names
|
|
1209
|
+
*/
|
|
1210
|
+
getHandlers(event_name: string): string[];
|
|
1211
|
+
|
|
1212
|
+
// === Virtual Buffer Operations ===
|
|
1213
|
+
/**
|
|
1214
|
+
* Create a virtual buffer in a new horizontal split below current pane
|
|
1215
|
+
*
|
|
1216
|
+
* Use for results panels, diagnostics, logs, etc. The panel_id enables
|
|
1217
|
+
* idempotent updates: if a panel with that ID exists, its content is replaced
|
|
1218
|
+
* instead of creating a new split. Define the mode with defineMode first.
|
|
1219
|
+
* @param options - Buffer configuration
|
|
1220
|
+
* @example
|
|
1221
|
+
* // First define the mode with keybindings
|
|
1222
|
+
* editor.defineMode("search-results", "special", [
|
|
1223
|
+
* ["Return", "search_goto"],
|
|
1224
|
+
* ["q", "close_buffer"]
|
|
1225
|
+
* ], true);
|
|
1226
|
+
*
|
|
1227
|
+
* // Then create the buffer
|
|
1228
|
+
* const id = await editor.createVirtualBufferInSplit({
|
|
1229
|
+
* name: "*Search*",
|
|
1230
|
+
* mode: "search-results",
|
|
1231
|
+
* read_only: true,
|
|
1232
|
+
* entries: [
|
|
1233
|
+
* { text: "src/main.rs:42: match\n", properties: { file: "src/main.rs", line: 42 } }
|
|
1234
|
+
* ],
|
|
1235
|
+
* ratio: 0.3,
|
|
1236
|
+
* panel_id: "search"
|
|
1237
|
+
* });
|
|
1238
|
+
*/
|
|
1239
|
+
createVirtualBufferInSplit(options: CreateVirtualBufferOptions): Promise<CreateVirtualBufferResult>;
|
|
1240
|
+
/**
|
|
1241
|
+
* Create a virtual buffer in an existing split
|
|
1242
|
+
* @param options - Configuration for the virtual buffer
|
|
1243
|
+
* @returns Promise resolving to the buffer ID of the created virtual buffer
|
|
1244
|
+
*/
|
|
1245
|
+
createVirtualBufferInExistingSplit(options: CreateVirtualBufferInExistingSplitOptions): Promise<number>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Create a virtual buffer in the current split as a new tab
|
|
1248
|
+
* This is useful for help panels, documentation, etc. that should open
|
|
1249
|
+
* alongside other buffers rather than in a separate split.
|
|
1250
|
+
* @param options - Configuration for the virtual buffer
|
|
1251
|
+
* @returns Promise resolving to the buffer ID of the created virtual buffer
|
|
1252
|
+
*/
|
|
1253
|
+
createVirtualBuffer(options: CreateVirtualBufferInCurrentSplitOptions): Promise<number>;
|
|
1254
|
+
/**
|
|
1255
|
+
* Define a buffer mode with keybindings
|
|
1256
|
+
* @param name - Mode name (e.g., "diagnostics-list")
|
|
1257
|
+
* @param parent - Parent mode name for inheritance (e.g., "special"), or null
|
|
1258
|
+
* @param bindings - Array of [key_string, command_name] pairs
|
|
1259
|
+
* @param read_only - Whether buffers in this mode are read-only
|
|
1260
|
+
* @returns true if mode was defined successfully
|
|
1261
|
+
* @example
|
|
1262
|
+
* editor.defineMode("diagnostics-list", "special", [
|
|
1263
|
+
* ["Return", "diagnostics_goto"],
|
|
1264
|
+
* ["q", "close_buffer"]
|
|
1265
|
+
* ], true);
|
|
1266
|
+
*/
|
|
1267
|
+
defineMode(name: string, parent: string, bindings: Vec<(String, String): boolean;
|
|
1268
|
+
/**
|
|
1269
|
+
* Switch the current split to display a buffer
|
|
1270
|
+
* @param buffer_id - ID of the buffer to show
|
|
1271
|
+
* @returns true if buffer was shown successfully
|
|
1272
|
+
*/
|
|
1273
|
+
showBuffer(buffer_id: number): boolean;
|
|
1274
|
+
/**
|
|
1275
|
+
* Close a buffer and remove it from all splits
|
|
1276
|
+
* @param buffer_id - ID of the buffer to close
|
|
1277
|
+
* @returns true if buffer was closed successfully
|
|
1278
|
+
*/
|
|
1279
|
+
closeBuffer(buffer_id: number): boolean;
|
|
1280
|
+
/**
|
|
1281
|
+
* Focus a specific split
|
|
1282
|
+
* @param split_id - ID of the split to focus
|
|
1283
|
+
* @returns true if split was focused successfully
|
|
1284
|
+
*/
|
|
1285
|
+
focusSplit(split_id: number): boolean;
|
|
1286
|
+
/**
|
|
1287
|
+
* Set the buffer displayed in a specific split
|
|
1288
|
+
* @param split_id - ID of the split
|
|
1289
|
+
* @param buffer_id - ID of the buffer to display in the split
|
|
1290
|
+
* @returns true if the buffer was set successfully
|
|
1291
|
+
*/
|
|
1292
|
+
setSplitBuffer(split_id: number, buffer_id: number): boolean;
|
|
1293
|
+
/**
|
|
1294
|
+
* Close a split (if not the last one)
|
|
1295
|
+
* @param split_id - ID of the split to close
|
|
1296
|
+
* @returns true if the split was closed successfully
|
|
1297
|
+
*/
|
|
1298
|
+
closeSplit(split_id: number): boolean;
|
|
1299
|
+
/**
|
|
1300
|
+
* Get text properties at the cursor position in a buffer
|
|
1301
|
+
* @param buffer_id - ID of the buffer to query
|
|
1302
|
+
* @returns Array of property objects for text ranges containing the cursor
|
|
1303
|
+
* @example
|
|
1304
|
+
* const props = editor.getTextPropertiesAtCursor(bufferId);
|
|
1305
|
+
* if (props.length > 0 && props[0].location) {
|
|
1306
|
+
* editor.openFile(props[0].location.file, props[0].location.line, 0);
|
|
1307
|
+
* }
|
|
1308
|
+
*/
|
|
1309
|
+
getTextPropertiesAtCursor(buffer_id: number): Record<string, unknown>[];
|
|
1310
|
+
/**
|
|
1311
|
+
* Set the content of a virtual buffer with text properties
|
|
1312
|
+
* @param buffer_id - ID of the virtual buffer
|
|
1313
|
+
* @param entries - Array of text entries with properties
|
|
1314
|
+
* @returns true if content was set successfully
|
|
1315
|
+
*/
|
|
1316
|
+
setVirtualBufferContent(buffer_id: number, entries: TextPropertyEntry[]): boolean;
|
|
1317
|
+
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
// Export for module compatibility
|
|
1321
|
+
export {};
|