@fresh-editor/fresh-editor 0.1.65 → 0.1.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +106 -0
- package/README.md +4 -2
- package/package.json +1 -1
- package/plugins/audit_mode.i18n.json +380 -0
- package/plugins/audit_mode.ts +1813 -0
- package/plugins/buffer_modified.i18n.json +32 -0
- package/plugins/buffer_modified.ts +5 -3
- package/plugins/calculator.i18n.json +44 -0
- package/plugins/calculator.ts +6 -4
- package/plugins/clangd-lsp.ts +168 -0
- package/plugins/clangd_support.i18n.json +104 -0
- package/plugins/clangd_support.ts +18 -16
- package/plugins/color_highlighter.i18n.json +68 -0
- package/plugins/color_highlighter.ts +12 -10
- package/plugins/config-schema.json +79 -141
- package/plugins/csharp-lsp.ts +147 -0
- package/plugins/csharp_support.i18n.json +38 -0
- package/plugins/csharp_support.ts +6 -4
- package/plugins/css-lsp.ts +143 -0
- package/plugins/diagnostics_panel.i18n.json +110 -0
- package/plugins/diagnostics_panel.ts +19 -17
- package/plugins/find_references.i18n.json +128 -0
- package/plugins/find_references.ts +22 -20
- package/plugins/git_blame.i18n.json +230 -0
- package/plugins/git_blame.ts +39 -37
- package/plugins/git_find_file.i18n.json +146 -0
- package/plugins/git_find_file.ts +24 -22
- package/plugins/git_grep.i18n.json +80 -0
- package/plugins/git_grep.ts +15 -13
- package/plugins/git_gutter.i18n.json +44 -0
- package/plugins/git_gutter.ts +7 -5
- package/plugins/git_log.i18n.json +224 -0
- package/plugins/git_log.ts +41 -39
- package/plugins/go-lsp.ts +143 -0
- package/plugins/html-lsp.ts +145 -0
- package/plugins/json-lsp.ts +145 -0
- package/plugins/lib/fresh.d.ts +150 -14
- package/plugins/lib/index.ts +1 -1
- package/plugins/lib/navigation-controller.ts +3 -3
- package/plugins/lib/panel-manager.ts +15 -13
- package/plugins/lib/virtual-buffer-factory.ts +84 -112
- package/plugins/live_grep.i18n.json +80 -0
- package/plugins/live_grep.ts +15 -13
- package/plugins/markdown_compose.i18n.json +104 -0
- package/plugins/markdown_compose.ts +17 -15
- package/plugins/merge_conflict.i18n.json +380 -0
- package/plugins/merge_conflict.ts +72 -73
- package/plugins/path_complete.i18n.json +38 -0
- package/plugins/path_complete.ts +6 -4
- package/plugins/python-lsp.ts +162 -0
- package/plugins/rust-lsp.ts +166 -0
- package/plugins/search_replace.i18n.json +188 -0
- package/plugins/search_replace.ts +31 -29
- package/plugins/test_i18n.i18n.json +12 -0
- package/plugins/test_i18n.ts +18 -0
- package/plugins/theme_editor.i18n.json +1417 -0
- package/plugins/theme_editor.ts +73 -69
- package/plugins/todo_highlighter.i18n.json +86 -0
- package/plugins/todo_highlighter.ts +15 -13
- package/plugins/typescript-lsp.ts +167 -0
- package/plugins/vi_mode.i18n.json +716 -0
- package/plugins/vi_mode.ts +2747 -0
- package/plugins/welcome.i18n.json +110 -0
- package/plugins/welcome.ts +18 -16
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
const editor = getEditor();
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* JSON LSP Helper Plugin
|
|
7
|
+
*
|
|
8
|
+
* Provides user-friendly error handling for JSON LSP server issues.
|
|
9
|
+
* When the JSON language server fails to start, this plugin shows an
|
|
10
|
+
* actionable popup with installation instructions.
|
|
11
|
+
*
|
|
12
|
+
* Features:
|
|
13
|
+
* - Detects JSON LSP server errors
|
|
14
|
+
* - Shows popup with install commands (npm)
|
|
15
|
+
* - Allows copying install commands to clipboard
|
|
16
|
+
* - Provides option to disable JSON LSP
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
interface LspServerErrorData {
|
|
20
|
+
language: string;
|
|
21
|
+
server_command: string;
|
|
22
|
+
error_type: string;
|
|
23
|
+
message: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface LspStatusClickedData {
|
|
27
|
+
language: string;
|
|
28
|
+
has_error: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface ActionPopupResultData {
|
|
32
|
+
popup_id: string;
|
|
33
|
+
action_id: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Install commands for JSON LSP server
|
|
37
|
+
// vscode-langservers-extracted provides HTML, CSS, and JSON language servers
|
|
38
|
+
// See: https://www.npmjs.com/package/vscode-langservers-extracted
|
|
39
|
+
const INSTALL_COMMANDS = {
|
|
40
|
+
npm: "npm install -g vscode-langservers-extracted",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Track error state for JSON LSP
|
|
44
|
+
let jsonLspError: { serverCommand: string; message: string } | null = null;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Handle LSP server errors for JSON
|
|
48
|
+
*/
|
|
49
|
+
globalThis.on_json_lsp_server_error = function (
|
|
50
|
+
data: LspServerErrorData
|
|
51
|
+
): void {
|
|
52
|
+
// Only handle JSON language errors
|
|
53
|
+
if (data.language !== "json") {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
editor.debug(`json-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
58
|
+
|
|
59
|
+
// Store error state for later reference
|
|
60
|
+
jsonLspError = {
|
|
61
|
+
serverCommand: data.server_command,
|
|
62
|
+
message: data.message,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Show a status message for immediate feedback
|
|
66
|
+
if (data.error_type === "not_found") {
|
|
67
|
+
editor.setStatus(
|
|
68
|
+
`JSON LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
69
|
+
);
|
|
70
|
+
} else {
|
|
71
|
+
editor.setStatus(`JSON LSP error: ${data.message}`);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Register hook for LSP server errors
|
|
76
|
+
editor.on("lsp_server_error", "on_json_lsp_server_error");
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Handle status bar click when there's a JSON LSP error
|
|
80
|
+
*/
|
|
81
|
+
globalThis.on_json_lsp_status_clicked = function (
|
|
82
|
+
data: LspStatusClickedData
|
|
83
|
+
): void {
|
|
84
|
+
// Only handle JSON language clicks when there's an error
|
|
85
|
+
if (data.language !== "json" || !jsonLspError) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
editor.debug("json-lsp: Status clicked, showing help popup");
|
|
90
|
+
|
|
91
|
+
// Show action popup with install options
|
|
92
|
+
editor.showActionPopup({
|
|
93
|
+
id: "json-lsp-help",
|
|
94
|
+
title: "JSON Language Server Not Found",
|
|
95
|
+
message: `"${jsonLspError.serverCommand}" provides code completion, validation, and formatting for JSON files. Copy the command below to install it.`,
|
|
96
|
+
actions: [
|
|
97
|
+
{ id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
|
|
98
|
+
{ id: "disable", label: "Disable JSON LSP" },
|
|
99
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
100
|
+
],
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Register hook for status bar clicks
|
|
105
|
+
editor.on("lsp_status_clicked", "on_json_lsp_status_clicked");
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Handle action popup results for JSON LSP help
|
|
109
|
+
*/
|
|
110
|
+
globalThis.on_json_lsp_action_result = function (
|
|
111
|
+
data: ActionPopupResultData
|
|
112
|
+
): void {
|
|
113
|
+
// Only handle our popup
|
|
114
|
+
if (data.popup_id !== "json-lsp-help") {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
editor.debug(`json-lsp: Action selected - ${data.action_id}`);
|
|
119
|
+
|
|
120
|
+
switch (data.action_id) {
|
|
121
|
+
case "copy_npm":
|
|
122
|
+
editor.setClipboard(INSTALL_COMMANDS.npm);
|
|
123
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.npm);
|
|
124
|
+
break;
|
|
125
|
+
|
|
126
|
+
case "disable":
|
|
127
|
+
editor.disableLspForLanguage("json");
|
|
128
|
+
editor.setStatus("JSON LSP disabled");
|
|
129
|
+
jsonLspError = null;
|
|
130
|
+
break;
|
|
131
|
+
|
|
132
|
+
case "dismiss":
|
|
133
|
+
case "dismissed":
|
|
134
|
+
// Just close the popup without action
|
|
135
|
+
break;
|
|
136
|
+
|
|
137
|
+
default:
|
|
138
|
+
editor.debug(`json-lsp: Unknown action: ${data.action_id}`);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// Register hook for action popup results
|
|
143
|
+
editor.on("action_popup_result", "on_json_lsp_action_result");
|
|
144
|
+
|
|
145
|
+
editor.debug("json-lsp: Plugin loaded");
|
package/plugins/lib/fresh.d.ts
CHANGED
|
@@ -254,6 +254,8 @@ interface CreateVirtualBufferOptions {
|
|
|
254
254
|
show_cursors?: boolean | null;
|
|
255
255
|
/** Disable all editing commands (default: false) */
|
|
256
256
|
editing_disabled?: boolean | null;
|
|
257
|
+
/** Enable/disable line wrapping (None = use global setting) */
|
|
258
|
+
line_wrap?: boolean | null;
|
|
257
259
|
}
|
|
258
260
|
|
|
259
261
|
/** Options for creating a virtual buffer in an existing split */
|
|
@@ -274,6 +276,8 @@ interface CreateVirtualBufferInExistingSplitOptions {
|
|
|
274
276
|
show_cursors?: boolean | null;
|
|
275
277
|
/** Whether editing is disabled for this buffer (default false) */
|
|
276
278
|
editing_disabled?: boolean | null;
|
|
279
|
+
/** Enable/disable line wrapping (None = use global setting) */
|
|
280
|
+
line_wrap?: boolean | null;
|
|
277
281
|
}
|
|
278
282
|
|
|
279
283
|
/** Options for creating a virtual buffer in the current split as a new tab */
|
|
@@ -294,6 +298,26 @@ interface CreateVirtualBufferInCurrentSplitOptions {
|
|
|
294
298
|
editing_disabled?: boolean | null;
|
|
295
299
|
}
|
|
296
300
|
|
|
301
|
+
/** JavaScript representation of ActionSpec (with optional count) */
|
|
302
|
+
interface ActionSpecJs {
|
|
303
|
+
action: string;
|
|
304
|
+
count?: number | null;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** TypeScript struct for action popup action */
|
|
308
|
+
interface TsActionPopupAction {
|
|
309
|
+
id: string;
|
|
310
|
+
label: string;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** TypeScript struct for action popup options */
|
|
314
|
+
interface TsActionPopupOptions {
|
|
315
|
+
id: string;
|
|
316
|
+
title: string;
|
|
317
|
+
message: string;
|
|
318
|
+
actions: TsActionPopupAction[];
|
|
319
|
+
}
|
|
320
|
+
|
|
297
321
|
/**
|
|
298
322
|
* Main editor API interface
|
|
299
323
|
*/
|
|
@@ -308,9 +332,9 @@ interface EditorAPI {
|
|
|
308
332
|
*/
|
|
309
333
|
setStatus(message: string): void;
|
|
310
334
|
/**
|
|
311
|
-
* Log a debug message
|
|
335
|
+
* Log a debug message from a plugin
|
|
312
336
|
*
|
|
313
|
-
* Messages appear in
|
|
337
|
+
* Messages appear in log file when running with RUST_LOG=debug.
|
|
314
338
|
* Useful for plugin development and troubleshooting.
|
|
315
339
|
* @param message - Debug message; include context like function name and relevant values
|
|
316
340
|
*/
|
|
@@ -374,6 +398,8 @@ interface EditorAPI {
|
|
|
374
398
|
* @param buffer_id - Target buffer ID
|
|
375
399
|
*/
|
|
376
400
|
isBufferModified(buffer_id: number): boolean;
|
|
401
|
+
/** Get the currently active locale */
|
|
402
|
+
getCurrentLocale(): string;
|
|
377
403
|
/**
|
|
378
404
|
* Get the ID of the focused split pane
|
|
379
405
|
*
|
|
@@ -402,6 +428,8 @@ interface EditorAPI {
|
|
|
402
428
|
* @returns true if process is running, false if not found or exited
|
|
403
429
|
*/
|
|
404
430
|
isProcessRunning(#[bigint] process_id: number): boolean;
|
|
431
|
+
/** Compute syntax highlighting for a buffer range */
|
|
432
|
+
getHighlights(buffer_id: number, start: number, end: number): Promise<TsHighlightSpan[]>;
|
|
405
433
|
/** Get diff vs last saved snapshot for a buffer */
|
|
406
434
|
getBufferSavedDiff(buffer_id: number): TsBufferSavedDiff | null;
|
|
407
435
|
/**
|
|
@@ -409,6 +437,22 @@ interface EditorAPI {
|
|
|
409
437
|
* @returns Array of Diagnostic objects with file URI, severity, message, and range
|
|
410
438
|
*/
|
|
411
439
|
getAllDiagnostics(): TsDiagnostic[];
|
|
440
|
+
/**
|
|
441
|
+
* Get text from a buffer range
|
|
442
|
+
*
|
|
443
|
+
* Used by vi mode plugin for yank operations - reads text without deleting.
|
|
444
|
+
* @param buffer_id - Buffer ID
|
|
445
|
+
* @param start - Start byte offset
|
|
446
|
+
* @param end - End byte offset
|
|
447
|
+
* @returns Text content of the range, or empty string on error
|
|
448
|
+
*/
|
|
449
|
+
getBufferText(buffer_id: number, start: number, end: number): Promise<string>;
|
|
450
|
+
/**
|
|
451
|
+
* Get the current global editor mode
|
|
452
|
+
*
|
|
453
|
+
* @returns Current mode name or null if no mode is active
|
|
454
|
+
*/
|
|
455
|
+
getEditorMode(): string;
|
|
412
456
|
|
|
413
457
|
// === Buffer Info Queries ===
|
|
414
458
|
/**
|
|
@@ -470,6 +514,30 @@ interface EditorAPI {
|
|
|
470
514
|
* stay in sync with the saved config.
|
|
471
515
|
*/
|
|
472
516
|
reloadConfig(): void;
|
|
517
|
+
/**
|
|
518
|
+
* Log an error message from a plugin
|
|
519
|
+
*
|
|
520
|
+
* Messages appear in log file when running with RUST_LOG=error.
|
|
521
|
+
* Use for critical errors that need attention.
|
|
522
|
+
* @param message - Error message
|
|
523
|
+
*/
|
|
524
|
+
error(message: string): void;
|
|
525
|
+
/**
|
|
526
|
+
* Log a warning message from a plugin
|
|
527
|
+
*
|
|
528
|
+
* Messages appear in log file when running with RUST_LOG=warn.
|
|
529
|
+
* Use for warnings that don't prevent operation but indicate issues.
|
|
530
|
+
* @param message - Warning message
|
|
531
|
+
*/
|
|
532
|
+
warn(message: string): void;
|
|
533
|
+
/**
|
|
534
|
+
* Log an info message from a plugin
|
|
535
|
+
*
|
|
536
|
+
* Messages appear in log file when running with RUST_LOG=info.
|
|
537
|
+
* Use for important operational messages.
|
|
538
|
+
* @param message - Info message
|
|
539
|
+
*/
|
|
540
|
+
info(message: string): void;
|
|
473
541
|
/**
|
|
474
542
|
* Copy text to the system clipboard
|
|
475
543
|
*
|
|
@@ -574,16 +642,9 @@ interface EditorAPI {
|
|
|
574
642
|
* @returns true if insertion succeeded
|
|
575
643
|
*/
|
|
576
644
|
insertAtCursor(text: string): boolean;
|
|
577
|
-
/**
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
* @param description - Human-readable description
|
|
581
|
-
* @param action - JavaScript function name to call when command is triggered
|
|
582
|
-
* @param contexts - Comma-separated list of contexts, including both built-in (normal, prompt, popup,
|
|
583
|
-
* fileexplorer, menu) and custom plugin-defined contexts (e.g., "normal,config-editor")
|
|
584
|
-
* @param source - Plugin source name (empty string for builtin)
|
|
585
|
-
* @returns true if command was registered
|
|
586
|
-
*/
|
|
645
|
+
/** Translate a string for a plugin using the current locale */
|
|
646
|
+
pluginTranslate(plugin_name: string, key: string, args: Record<string, unknown>): string;
|
|
647
|
+
/** Register a custom command that can be triggered by keybindings or the command palette */
|
|
587
648
|
registerCommand(name: string, description: string, action: string, contexts: string, source: string): boolean;
|
|
588
649
|
/**
|
|
589
650
|
* Unregister a custom command by name
|
|
@@ -661,6 +722,8 @@ interface EditorAPI {
|
|
|
661
722
|
* await editor.delay(100); // Wait 100ms
|
|
662
723
|
*/
|
|
663
724
|
delay(#[bigint] ms: number): Promise<[]>;
|
|
725
|
+
/** Find a buffer ID by its file path */
|
|
726
|
+
findBufferByPath(path: string): number;
|
|
664
727
|
/**
|
|
665
728
|
* Start a prompt with pre-filled initial value
|
|
666
729
|
* @param label - Label to display (e.g., "Git grep: ")
|
|
@@ -677,6 +740,13 @@ interface EditorAPI {
|
|
|
677
740
|
* @returns Promise resolving to the JSON response value
|
|
678
741
|
*/
|
|
679
742
|
sendLspRequest(language: string, method: string, params?: unknown | null): Promise<unknown>;
|
|
743
|
+
/**
|
|
744
|
+
* Set the scroll position of a specific split
|
|
745
|
+
* @param split_id - The split ID
|
|
746
|
+
* @param top_byte - The byte offset of the top visible line
|
|
747
|
+
* @returns true if successful
|
|
748
|
+
*/
|
|
749
|
+
setSplitScroll(split_id: number, top_byte: number): boolean;
|
|
680
750
|
/**
|
|
681
751
|
* Set the ratio of a split container
|
|
682
752
|
* @param split_id - ID of the split
|
|
@@ -697,6 +767,71 @@ interface EditorAPI {
|
|
|
697
767
|
* @returns true if the command was sent successfully
|
|
698
768
|
*/
|
|
699
769
|
setBufferCursor(buffer_id: number, position: number): boolean;
|
|
770
|
+
/**
|
|
771
|
+
* Execute a built-in editor action by name
|
|
772
|
+
*
|
|
773
|
+
* This is used by vi mode plugin to run motions and then check cursor position.
|
|
774
|
+
* For example, to implement "dw" (delete word), the plugin:
|
|
775
|
+
* 1. Saves current cursor position
|
|
776
|
+
* 2. Calls executeAction("move_word_right") - cursor moves
|
|
777
|
+
* 3. Gets new cursor position
|
|
778
|
+
* 4. Deletes from old to new position
|
|
779
|
+
*
|
|
780
|
+
* @param action_name - Action name (e.g., "move_word_right", "move_line_end")
|
|
781
|
+
* @returns true if action was sent successfully
|
|
782
|
+
*/
|
|
783
|
+
executeAction(action_name: string): boolean;
|
|
784
|
+
/**
|
|
785
|
+
* Execute multiple actions in sequence, each with an optional repeat count
|
|
786
|
+
*
|
|
787
|
+
* Used by vi mode for count prefix (e.g., "3dw" = delete 3 words).
|
|
788
|
+
* All actions execute atomically with no plugin roundtrips between them.
|
|
789
|
+
*
|
|
790
|
+
* @param actions - Array of {action: string, count?: number} objects
|
|
791
|
+
* @returns true if actions were sent successfully
|
|
792
|
+
*/
|
|
793
|
+
executeActions(actions: ActionSpecJs[]): boolean;
|
|
794
|
+
/**
|
|
795
|
+
* Set the global editor mode (for modal editing like vi mode)
|
|
796
|
+
*
|
|
797
|
+
* When a mode is set, its keybindings take precedence over normal key handling.
|
|
798
|
+
* Pass null/undefined to clear the mode and return to normal editing.
|
|
799
|
+
*
|
|
800
|
+
* @param mode - Mode name (e.g., "vi-normal") or null to clear
|
|
801
|
+
* @returns true if command was sent successfully
|
|
802
|
+
*/
|
|
803
|
+
setEditorMode(mode?: string | null): boolean;
|
|
804
|
+
/**
|
|
805
|
+
* Show an action popup with buttons for user interaction
|
|
806
|
+
*
|
|
807
|
+
* When the user selects an action, the ActionPopupResult hook is fired.
|
|
808
|
+
* @param options - Popup configuration with id, title, message, and actions
|
|
809
|
+
*/
|
|
810
|
+
showActionPopup(options: TsActionPopupOptions): boolean;
|
|
811
|
+
/**
|
|
812
|
+
* Disable LSP for a specific language and persist to config
|
|
813
|
+
*
|
|
814
|
+
* This is used by LSP helper plugins to let users disable LSP for languages
|
|
815
|
+
* where the server is not available or not working.
|
|
816
|
+
* @param language - The language to disable LSP for (e.g., "python", "rust")
|
|
817
|
+
*/
|
|
818
|
+
disableLspForLanguage(language: string): boolean;
|
|
819
|
+
/**
|
|
820
|
+
* Create a scroll sync group for anchor-based synchronized scrolling
|
|
821
|
+
*
|
|
822
|
+
* Used for side-by-side diff views where two panes need to scroll together.
|
|
823
|
+
* The plugin provides the group ID (must be unique per plugin).
|
|
824
|
+
*/
|
|
825
|
+
createScrollSyncGroup(group_id: number, left_split: number, right_split: number): boolean;
|
|
826
|
+
/**
|
|
827
|
+
* Set sync anchors for a scroll sync group
|
|
828
|
+
*
|
|
829
|
+
* Anchors map corresponding line numbers between left and right buffers.
|
|
830
|
+
* Each anchor is a tuple of (left_line, right_line).
|
|
831
|
+
*/
|
|
832
|
+
setScrollSyncAnchors(group_id: number, anchors: Vec<(usize, usize): boolean;
|
|
833
|
+
/** Remove a scroll sync group */
|
|
834
|
+
removeScrollSyncGroup(group_id: number): boolean;
|
|
700
835
|
|
|
701
836
|
/**
|
|
702
837
|
* Spawn an external process and return a cancellable handle
|
|
@@ -734,9 +869,10 @@ interface EditorAPI {
|
|
|
734
869
|
* @param underline - Add underline decoration
|
|
735
870
|
* @param bold - Use bold text
|
|
736
871
|
* @param italic - Use italic text
|
|
872
|
+
* @param extend_to_line_end - Extend background to end of visual line
|
|
737
873
|
* @returns true if overlay was added
|
|
738
874
|
*/
|
|
739
|
-
addOverlay(buffer_id: number, namespace: string, start: number, end: number, r: number, g: number, b: number, underline: boolean, bold: boolean, italic: boolean): boolean;
|
|
875
|
+
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;
|
|
740
876
|
/**
|
|
741
877
|
* Remove a specific overlay by its handle
|
|
742
878
|
* @param buffer_id - The buffer ID
|
|
@@ -1011,7 +1147,7 @@ interface EditorAPI {
|
|
|
1011
1147
|
* ["q", "close_buffer"]
|
|
1012
1148
|
* ], true);
|
|
1013
1149
|
*/
|
|
1014
|
-
defineMode(name: string, parent
|
|
1150
|
+
defineMode(name: string, parent: string, bindings: Vec<(String, String): boolean;
|
|
1015
1151
|
/**
|
|
1016
1152
|
* Switch the current split to display a buffer
|
|
1017
1153
|
* @param buffer_id - ID of the buffer to show
|
package/plugins/lib/index.ts
CHANGED
|
@@ -20,5 +20,5 @@ export { PanelManager } from "./panel-manager.ts";
|
|
|
20
20
|
export { NavigationController } from "./navigation-controller.ts";
|
|
21
21
|
|
|
22
22
|
// Buffer Creation
|
|
23
|
-
export {
|
|
23
|
+
export { createVirtualBufferFactory } from "./virtual-buffer-factory.ts";
|
|
24
24
|
export type { VirtualBufferOptions, SplitBufferOptions } from "./virtual-buffer-factory.ts";
|
|
@@ -33,7 +33,7 @@ export class NavigationController<T> {
|
|
|
33
33
|
private currentIndex: number = 0;
|
|
34
34
|
private options: NavigationOptions<T>;
|
|
35
35
|
|
|
36
|
-
constructor(options: NavigationOptions<T> = {}) {
|
|
36
|
+
constructor(private readonly editor: EditorAPI, options: NavigationOptions<T> = {}) {
|
|
37
37
|
this.options = {
|
|
38
38
|
itemLabel: "Item",
|
|
39
39
|
wrap: false,
|
|
@@ -168,13 +168,13 @@ export class NavigationController<T> {
|
|
|
168
168
|
*/
|
|
169
169
|
showStatus(customMessage?: string): void {
|
|
170
170
|
if (this.items.length === 0) {
|
|
171
|
-
editor.setStatus(`No ${this.options.itemLabel}s`);
|
|
171
|
+
this.editor.setStatus(`No ${this.options.itemLabel}s`);
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
const message = customMessage ||
|
|
176
176
|
`${this.options.itemLabel} ${this.currentIndex + 1}/${this.items.length}`;
|
|
177
|
-
editor.setStatus(message);
|
|
177
|
+
this.editor.setStatus(message);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
/**
|
|
@@ -40,10 +40,12 @@ export class PanelManager {
|
|
|
40
40
|
/**
|
|
41
41
|
* Create a new PanelManager
|
|
42
42
|
*
|
|
43
|
+
* @param editor - The editor API instance
|
|
43
44
|
* @param panelName - Display name for the panel (e.g., "*Diagnostics*")
|
|
44
45
|
* @param modeName - Mode name for keybindings (e.g., "diagnostics-list")
|
|
45
46
|
*/
|
|
46
47
|
constructor(
|
|
48
|
+
private readonly editor: EditorAPI,
|
|
47
49
|
private readonly panelName: string,
|
|
48
50
|
private readonly modeName: string
|
|
49
51
|
) {}
|
|
@@ -101,11 +103,11 @@ export class PanelManager {
|
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
// Save current context
|
|
104
|
-
this.state.sourceSplitId = editor.getActiveSplitId();
|
|
105
|
-
this.state.sourceBufferId = editor.getActiveBufferId();
|
|
106
|
+
this.state.sourceSplitId = this.editor.getActiveSplitId();
|
|
107
|
+
this.state.sourceBufferId = this.editor.getActiveBufferId();
|
|
106
108
|
|
|
107
109
|
// Create virtual buffer in split
|
|
108
|
-
const bufferId = await editor.createVirtualBufferInSplit({
|
|
110
|
+
const bufferId = await this.editor.createVirtualBufferInSplit({
|
|
109
111
|
name: this.panelName,
|
|
110
112
|
mode: this.modeName,
|
|
111
113
|
read_only: true,
|
|
@@ -118,7 +120,7 @@ export class PanelManager {
|
|
|
118
120
|
|
|
119
121
|
// Track state
|
|
120
122
|
this.state.bufferId = bufferId;
|
|
121
|
-
this.state.splitId = editor.getActiveSplitId();
|
|
123
|
+
this.state.splitId = this.editor.getActiveSplitId();
|
|
122
124
|
this.state.isOpen = true;
|
|
123
125
|
|
|
124
126
|
return bufferId;
|
|
@@ -134,12 +136,12 @@ export class PanelManager {
|
|
|
134
136
|
|
|
135
137
|
// Close the split containing the panel
|
|
136
138
|
if (this.state.splitId !== null) {
|
|
137
|
-
editor.closeSplit(this.state.splitId);
|
|
139
|
+
this.editor.closeSplit(this.state.splitId);
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
// Focus back on source split
|
|
141
143
|
if (this.state.sourceSplitId !== null) {
|
|
142
|
-
editor.focusSplit(this.state.sourceSplitId);
|
|
144
|
+
this.editor.focusSplit(this.state.sourceSplitId);
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
// Reset state
|
|
@@ -156,7 +158,7 @@ export class PanelManager {
|
|
|
156
158
|
return;
|
|
157
159
|
}
|
|
158
160
|
|
|
159
|
-
editor.setVirtualBufferContent(this.state.bufferId, entries);
|
|
161
|
+
this.editor.setVirtualBufferContent(this.state.bufferId, entries);
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
/**
|
|
@@ -177,7 +179,7 @@ export class PanelManager {
|
|
|
177
179
|
*/
|
|
178
180
|
focusSource(): void {
|
|
179
181
|
if (this.state.sourceSplitId !== null) {
|
|
180
|
-
editor.focusSplit(this.state.sourceSplitId);
|
|
182
|
+
this.editor.focusSplit(this.state.sourceSplitId);
|
|
181
183
|
}
|
|
182
184
|
}
|
|
183
185
|
|
|
@@ -186,7 +188,7 @@ export class PanelManager {
|
|
|
186
188
|
*/
|
|
187
189
|
focusPanel(): void {
|
|
188
190
|
if (this.state.splitId !== null) {
|
|
189
|
-
editor.focusSplit(this.state.splitId);
|
|
191
|
+
this.editor.focusSplit(this.state.splitId);
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
194
|
|
|
@@ -203,13 +205,13 @@ export class PanelManager {
|
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
// Focus source split and open file
|
|
206
|
-
editor.focusSplit(this.state.sourceSplitId);
|
|
207
|
-
await editor.openFile(filePath);
|
|
208
|
+
this.editor.focusSplit(this.state.sourceSplitId);
|
|
209
|
+
await this.editor.openFile(filePath);
|
|
208
210
|
|
|
209
211
|
// Jump to location
|
|
210
|
-
editor.gotoLine(line);
|
|
212
|
+
this.editor.gotoLine(line);
|
|
211
213
|
if (column > 1) {
|
|
212
|
-
editor.gotoColumn(column);
|
|
214
|
+
this.editor.gotoColumn(column);
|
|
213
215
|
}
|
|
214
216
|
|
|
215
217
|
// Focus back on panel
|