@fresh-editor/fresh-editor 0.1.63 → 0.1.67
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 +74 -0
- package/README.md +2 -2
- package/package.json +1 -1
- package/plugins/audit_mode.ts +1045 -0
- package/plugins/clangd-lsp.ts +166 -0
- package/plugins/config-schema.json +134 -15
- package/plugins/csharp-lsp.ts +145 -0
- package/plugins/css-lsp.ts +141 -0
- package/plugins/go-lsp.ts +141 -0
- package/plugins/html-lsp.ts +143 -0
- package/plugins/json-lsp.ts +143 -0
- package/plugins/lib/fresh.d.ts +98 -2
- package/plugins/python-lsp.ts +160 -0
- package/plugins/rust-lsp.ts +164 -0
- package/plugins/typescript-lsp.ts +165 -0
- package/plugins/vi_mode.ts +1630 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Go LSP Helper Plugin
|
|
5
|
+
*
|
|
6
|
+
* Provides user-friendly error handling for Go LSP server issues.
|
|
7
|
+
* When gopls fails to start, this plugin shows an actionable
|
|
8
|
+
* popup with installation instructions.
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Detects Go LSP server errors (gopls)
|
|
12
|
+
* - Shows popup with install commands
|
|
13
|
+
* - Allows copying install commands to clipboard
|
|
14
|
+
* - Provides option to disable Go LSP
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
interface LspServerErrorData {
|
|
18
|
+
language: string;
|
|
19
|
+
server_command: string;
|
|
20
|
+
error_type: string;
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface LspStatusClickedData {
|
|
25
|
+
language: string;
|
|
26
|
+
has_error: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface ActionPopupResultData {
|
|
30
|
+
popup_id: string;
|
|
31
|
+
action_id: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Install commands for Go LSP server (gopls)
|
|
35
|
+
// go install is the official recommended method
|
|
36
|
+
// See: https://pkg.go.dev/golang.org/x/tools/gopls
|
|
37
|
+
const INSTALL_COMMANDS = {
|
|
38
|
+
go: "go install golang.org/x/tools/gopls@latest",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Track error state for Go LSP
|
|
42
|
+
let goLspError: { serverCommand: string; message: string } | null = null;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Handle LSP server errors for Go
|
|
46
|
+
*/
|
|
47
|
+
globalThis.on_go_lsp_server_error = function (data: LspServerErrorData): void {
|
|
48
|
+
// Only handle Go language errors
|
|
49
|
+
if (data.language !== "go") {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
editor.debug(`go-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
54
|
+
|
|
55
|
+
// Store error state for later reference
|
|
56
|
+
goLspError = {
|
|
57
|
+
serverCommand: data.server_command,
|
|
58
|
+
message: data.message,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// Show a status message for immediate feedback
|
|
62
|
+
if (data.error_type === "not_found") {
|
|
63
|
+
editor.setStatus(
|
|
64
|
+
`Go LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
editor.setStatus(`Go LSP error: ${data.message}`);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Register hook for LSP server errors
|
|
72
|
+
editor.on("lsp_server_error", "on_go_lsp_server_error");
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Handle status bar click when there's a Go LSP error
|
|
76
|
+
*/
|
|
77
|
+
globalThis.on_go_lsp_status_clicked = function (
|
|
78
|
+
data: LspStatusClickedData
|
|
79
|
+
): void {
|
|
80
|
+
// Only handle Go language clicks when there's an error
|
|
81
|
+
if (data.language !== "go" || !goLspError) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
editor.debug("go-lsp: Status clicked, showing help popup");
|
|
86
|
+
|
|
87
|
+
// Show action popup with install options
|
|
88
|
+
editor.showActionPopup({
|
|
89
|
+
id: "go-lsp-help",
|
|
90
|
+
title: "Go Language Server Not Found",
|
|
91
|
+
message: `"${goLspError.serverCommand}" provides code completion, diagnostics, and navigation for Go files. Copy the command below to install it.`,
|
|
92
|
+
actions: [
|
|
93
|
+
{ id: "copy_go", label: `Copy: ${INSTALL_COMMANDS.go}` },
|
|
94
|
+
{ id: "disable", label: "Disable Go LSP" },
|
|
95
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
96
|
+
],
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Register hook for status bar clicks
|
|
101
|
+
editor.on("lsp_status_clicked", "on_go_lsp_status_clicked");
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Handle action popup results for Go LSP help
|
|
105
|
+
*/
|
|
106
|
+
globalThis.on_go_lsp_action_result = function (
|
|
107
|
+
data: ActionPopupResultData
|
|
108
|
+
): void {
|
|
109
|
+
// Only handle our popup
|
|
110
|
+
if (data.popup_id !== "go-lsp-help") {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
editor.debug(`go-lsp: Action selected - ${data.action_id}`);
|
|
115
|
+
|
|
116
|
+
switch (data.action_id) {
|
|
117
|
+
case "copy_go":
|
|
118
|
+
editor.setClipboard(INSTALL_COMMANDS.go);
|
|
119
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.go);
|
|
120
|
+
break;
|
|
121
|
+
|
|
122
|
+
case "disable":
|
|
123
|
+
editor.disableLspForLanguage("go");
|
|
124
|
+
editor.setStatus("Go LSP disabled");
|
|
125
|
+
goLspError = null;
|
|
126
|
+
break;
|
|
127
|
+
|
|
128
|
+
case "dismiss":
|
|
129
|
+
case "dismissed":
|
|
130
|
+
// Just close the popup without action
|
|
131
|
+
break;
|
|
132
|
+
|
|
133
|
+
default:
|
|
134
|
+
editor.debug(`go-lsp: Unknown action: ${data.action_id}`);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// Register hook for action popup results
|
|
139
|
+
editor.on("action_popup_result", "on_go_lsp_action_result");
|
|
140
|
+
|
|
141
|
+
editor.debug("go-lsp: Plugin loaded");
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* HTML LSP Helper Plugin
|
|
5
|
+
*
|
|
6
|
+
* Provides user-friendly error handling for HTML LSP server issues.
|
|
7
|
+
* When the HTML language server fails to start, this plugin shows an
|
|
8
|
+
* actionable popup with installation instructions.
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Detects HTML LSP server errors
|
|
12
|
+
* - Shows popup with install commands (npm)
|
|
13
|
+
* - Allows copying install commands to clipboard
|
|
14
|
+
* - Provides option to disable HTML LSP
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
interface LspServerErrorData {
|
|
18
|
+
language: string;
|
|
19
|
+
server_command: string;
|
|
20
|
+
error_type: string;
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface LspStatusClickedData {
|
|
25
|
+
language: string;
|
|
26
|
+
has_error: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface ActionPopupResultData {
|
|
30
|
+
popup_id: string;
|
|
31
|
+
action_id: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Install commands for HTML LSP server
|
|
35
|
+
// vscode-langservers-extracted provides HTML, CSS, and JSON language servers
|
|
36
|
+
// See: https://www.npmjs.com/package/vscode-langservers-extracted
|
|
37
|
+
const INSTALL_COMMANDS = {
|
|
38
|
+
npm: "npm install -g vscode-langservers-extracted",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Track error state for HTML LSP
|
|
42
|
+
let htmlLspError: { serverCommand: string; message: string } | null = null;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Handle LSP server errors for HTML
|
|
46
|
+
*/
|
|
47
|
+
globalThis.on_html_lsp_server_error = function (
|
|
48
|
+
data: LspServerErrorData
|
|
49
|
+
): void {
|
|
50
|
+
// Only handle HTML language errors
|
|
51
|
+
if (data.language !== "html") {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
editor.debug(`html-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
56
|
+
|
|
57
|
+
// Store error state for later reference
|
|
58
|
+
htmlLspError = {
|
|
59
|
+
serverCommand: data.server_command,
|
|
60
|
+
message: data.message,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Show a status message for immediate feedback
|
|
64
|
+
if (data.error_type === "not_found") {
|
|
65
|
+
editor.setStatus(
|
|
66
|
+
`HTML LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
67
|
+
);
|
|
68
|
+
} else {
|
|
69
|
+
editor.setStatus(`HTML LSP error: ${data.message}`);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// Register hook for LSP server errors
|
|
74
|
+
editor.on("lsp_server_error", "on_html_lsp_server_error");
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Handle status bar click when there's an HTML LSP error
|
|
78
|
+
*/
|
|
79
|
+
globalThis.on_html_lsp_status_clicked = function (
|
|
80
|
+
data: LspStatusClickedData
|
|
81
|
+
): void {
|
|
82
|
+
// Only handle HTML language clicks when there's an error
|
|
83
|
+
if (data.language !== "html" || !htmlLspError) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
editor.debug("html-lsp: Status clicked, showing help popup");
|
|
88
|
+
|
|
89
|
+
// Show action popup with install options
|
|
90
|
+
editor.showActionPopup({
|
|
91
|
+
id: "html-lsp-help",
|
|
92
|
+
title: "HTML Language Server Not Found",
|
|
93
|
+
message: `"${htmlLspError.serverCommand}" provides code completion, diagnostics, and formatting for HTML files. Copy the command below to install it.`,
|
|
94
|
+
actions: [
|
|
95
|
+
{ id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
|
|
96
|
+
{ id: "disable", label: "Disable HTML LSP" },
|
|
97
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
98
|
+
],
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Register hook for status bar clicks
|
|
103
|
+
editor.on("lsp_status_clicked", "on_html_lsp_status_clicked");
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Handle action popup results for HTML LSP help
|
|
107
|
+
*/
|
|
108
|
+
globalThis.on_html_lsp_action_result = function (
|
|
109
|
+
data: ActionPopupResultData
|
|
110
|
+
): void {
|
|
111
|
+
// Only handle our popup
|
|
112
|
+
if (data.popup_id !== "html-lsp-help") {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
editor.debug(`html-lsp: Action selected - ${data.action_id}`);
|
|
117
|
+
|
|
118
|
+
switch (data.action_id) {
|
|
119
|
+
case "copy_npm":
|
|
120
|
+
editor.setClipboard(INSTALL_COMMANDS.npm);
|
|
121
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.npm);
|
|
122
|
+
break;
|
|
123
|
+
|
|
124
|
+
case "disable":
|
|
125
|
+
editor.disableLspForLanguage("html");
|
|
126
|
+
editor.setStatus("HTML LSP disabled");
|
|
127
|
+
htmlLspError = null;
|
|
128
|
+
break;
|
|
129
|
+
|
|
130
|
+
case "dismiss":
|
|
131
|
+
case "dismissed":
|
|
132
|
+
// Just close the popup without action
|
|
133
|
+
break;
|
|
134
|
+
|
|
135
|
+
default:
|
|
136
|
+
editor.debug(`html-lsp: Unknown action: ${data.action_id}`);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// Register hook for action popup results
|
|
141
|
+
editor.on("action_popup_result", "on_html_lsp_action_result");
|
|
142
|
+
|
|
143
|
+
editor.debug("html-lsp: Plugin loaded");
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* JSON LSP Helper Plugin
|
|
5
|
+
*
|
|
6
|
+
* Provides user-friendly error handling for JSON LSP server issues.
|
|
7
|
+
* When the JSON language server fails to start, this plugin shows an
|
|
8
|
+
* actionable popup with installation instructions.
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Detects JSON LSP server errors
|
|
12
|
+
* - Shows popup with install commands (npm)
|
|
13
|
+
* - Allows copying install commands to clipboard
|
|
14
|
+
* - Provides option to disable JSON LSP
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
interface LspServerErrorData {
|
|
18
|
+
language: string;
|
|
19
|
+
server_command: string;
|
|
20
|
+
error_type: string;
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface LspStatusClickedData {
|
|
25
|
+
language: string;
|
|
26
|
+
has_error: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface ActionPopupResultData {
|
|
30
|
+
popup_id: string;
|
|
31
|
+
action_id: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Install commands for JSON LSP server
|
|
35
|
+
// vscode-langservers-extracted provides HTML, CSS, and JSON language servers
|
|
36
|
+
// See: https://www.npmjs.com/package/vscode-langservers-extracted
|
|
37
|
+
const INSTALL_COMMANDS = {
|
|
38
|
+
npm: "npm install -g vscode-langservers-extracted",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Track error state for JSON LSP
|
|
42
|
+
let jsonLspError: { serverCommand: string; message: string } | null = null;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Handle LSP server errors for JSON
|
|
46
|
+
*/
|
|
47
|
+
globalThis.on_json_lsp_server_error = function (
|
|
48
|
+
data: LspServerErrorData
|
|
49
|
+
): void {
|
|
50
|
+
// Only handle JSON language errors
|
|
51
|
+
if (data.language !== "json") {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
editor.debug(`json-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
56
|
+
|
|
57
|
+
// Store error state for later reference
|
|
58
|
+
jsonLspError = {
|
|
59
|
+
serverCommand: data.server_command,
|
|
60
|
+
message: data.message,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Show a status message for immediate feedback
|
|
64
|
+
if (data.error_type === "not_found") {
|
|
65
|
+
editor.setStatus(
|
|
66
|
+
`JSON LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
67
|
+
);
|
|
68
|
+
} else {
|
|
69
|
+
editor.setStatus(`JSON LSP error: ${data.message}`);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// Register hook for LSP server errors
|
|
74
|
+
editor.on("lsp_server_error", "on_json_lsp_server_error");
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Handle status bar click when there's a JSON LSP error
|
|
78
|
+
*/
|
|
79
|
+
globalThis.on_json_lsp_status_clicked = function (
|
|
80
|
+
data: LspStatusClickedData
|
|
81
|
+
): void {
|
|
82
|
+
// Only handle JSON language clicks when there's an error
|
|
83
|
+
if (data.language !== "json" || !jsonLspError) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
editor.debug("json-lsp: Status clicked, showing help popup");
|
|
88
|
+
|
|
89
|
+
// Show action popup with install options
|
|
90
|
+
editor.showActionPopup({
|
|
91
|
+
id: "json-lsp-help",
|
|
92
|
+
title: "JSON Language Server Not Found",
|
|
93
|
+
message: `"${jsonLspError.serverCommand}" provides code completion, validation, and formatting for JSON files. Copy the command below to install it.`,
|
|
94
|
+
actions: [
|
|
95
|
+
{ id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
|
|
96
|
+
{ id: "disable", label: "Disable JSON LSP" },
|
|
97
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
98
|
+
],
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Register hook for status bar clicks
|
|
103
|
+
editor.on("lsp_status_clicked", "on_json_lsp_status_clicked");
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Handle action popup results for JSON LSP help
|
|
107
|
+
*/
|
|
108
|
+
globalThis.on_json_lsp_action_result = function (
|
|
109
|
+
data: ActionPopupResultData
|
|
110
|
+
): void {
|
|
111
|
+
// Only handle our popup
|
|
112
|
+
if (data.popup_id !== "json-lsp-help") {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
editor.debug(`json-lsp: Action selected - ${data.action_id}`);
|
|
117
|
+
|
|
118
|
+
switch (data.action_id) {
|
|
119
|
+
case "copy_npm":
|
|
120
|
+
editor.setClipboard(INSTALL_COMMANDS.npm);
|
|
121
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.npm);
|
|
122
|
+
break;
|
|
123
|
+
|
|
124
|
+
case "disable":
|
|
125
|
+
editor.disableLspForLanguage("json");
|
|
126
|
+
editor.setStatus("JSON LSP disabled");
|
|
127
|
+
jsonLspError = null;
|
|
128
|
+
break;
|
|
129
|
+
|
|
130
|
+
case "dismiss":
|
|
131
|
+
case "dismissed":
|
|
132
|
+
// Just close the popup without action
|
|
133
|
+
break;
|
|
134
|
+
|
|
135
|
+
default:
|
|
136
|
+
editor.debug(`json-lsp: Unknown action: ${data.action_id}`);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// Register hook for action popup results
|
|
141
|
+
editor.on("action_popup_result", "on_json_lsp_action_result");
|
|
142
|
+
|
|
143
|
+
editor.debug("json-lsp: Plugin loaded");
|
package/plugins/lib/fresh.d.ts
CHANGED
|
@@ -294,6 +294,26 @@ interface CreateVirtualBufferInCurrentSplitOptions {
|
|
|
294
294
|
editing_disabled?: boolean | null;
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
/** JavaScript representation of ActionSpec (with optional count) */
|
|
298
|
+
interface ActionSpecJs {
|
|
299
|
+
action: string;
|
|
300
|
+
count?: number | null;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** TypeScript struct for action popup action */
|
|
304
|
+
interface TsActionPopupAction {
|
|
305
|
+
id: string;
|
|
306
|
+
label: string;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** TypeScript struct for action popup options */
|
|
310
|
+
interface TsActionPopupOptions {
|
|
311
|
+
id: string;
|
|
312
|
+
title: string;
|
|
313
|
+
message: string;
|
|
314
|
+
actions: TsActionPopupAction[];
|
|
315
|
+
}
|
|
316
|
+
|
|
297
317
|
/**
|
|
298
318
|
* Main editor API interface
|
|
299
319
|
*/
|
|
@@ -402,6 +422,8 @@ interface EditorAPI {
|
|
|
402
422
|
* @returns true if process is running, false if not found or exited
|
|
403
423
|
*/
|
|
404
424
|
isProcessRunning(#[bigint] process_id: number): boolean;
|
|
425
|
+
/** Compute syntax highlighting for a buffer range */
|
|
426
|
+
getHighlights(buffer_id: number, start: number, end: number): Promise<TsHighlightSpan[]>;
|
|
405
427
|
/** Get diff vs last saved snapshot for a buffer */
|
|
406
428
|
getBufferSavedDiff(buffer_id: number): TsBufferSavedDiff | null;
|
|
407
429
|
/**
|
|
@@ -409,6 +431,22 @@ interface EditorAPI {
|
|
|
409
431
|
* @returns Array of Diagnostic objects with file URI, severity, message, and range
|
|
410
432
|
*/
|
|
411
433
|
getAllDiagnostics(): TsDiagnostic[];
|
|
434
|
+
/**
|
|
435
|
+
* Get text from a buffer range
|
|
436
|
+
*
|
|
437
|
+
* Used by vi mode plugin for yank operations - reads text without deleting.
|
|
438
|
+
* @param buffer_id - Buffer ID
|
|
439
|
+
* @param start - Start byte offset
|
|
440
|
+
* @param end - End byte offset
|
|
441
|
+
* @returns Text content of the range, or empty string on error
|
|
442
|
+
*/
|
|
443
|
+
getBufferText(buffer_id: number, start: number, end: number): Promise<string>;
|
|
444
|
+
/**
|
|
445
|
+
* Get the current global editor mode
|
|
446
|
+
*
|
|
447
|
+
* @returns Current mode name or null if no mode is active
|
|
448
|
+
*/
|
|
449
|
+
getEditorMode(): string;
|
|
412
450
|
|
|
413
451
|
// === Buffer Info Queries ===
|
|
414
452
|
/**
|
|
@@ -661,6 +699,8 @@ interface EditorAPI {
|
|
|
661
699
|
* await editor.delay(100); // Wait 100ms
|
|
662
700
|
*/
|
|
663
701
|
delay(#[bigint] ms: number): Promise<[]>;
|
|
702
|
+
/** Find a buffer ID by its file path */
|
|
703
|
+
findBufferByPath(path: string): number;
|
|
664
704
|
/**
|
|
665
705
|
* Start a prompt with pre-filled initial value
|
|
666
706
|
* @param label - Label to display (e.g., "Git grep: ")
|
|
@@ -677,6 +717,13 @@ interface EditorAPI {
|
|
|
677
717
|
* @returns Promise resolving to the JSON response value
|
|
678
718
|
*/
|
|
679
719
|
sendLspRequest(language: string, method: string, params?: unknown | null): Promise<unknown>;
|
|
720
|
+
/**
|
|
721
|
+
* Set the scroll position of a specific split
|
|
722
|
+
* @param split_id - The split ID
|
|
723
|
+
* @param top_byte - The byte offset of the top visible line
|
|
724
|
+
* @returns true if successful
|
|
725
|
+
*/
|
|
726
|
+
setSplitScroll(split_id: number, top_byte: number): boolean;
|
|
680
727
|
/**
|
|
681
728
|
* Set the ratio of a split container
|
|
682
729
|
* @param split_id - ID of the split
|
|
@@ -697,6 +744,55 @@ interface EditorAPI {
|
|
|
697
744
|
* @returns true if the command was sent successfully
|
|
698
745
|
*/
|
|
699
746
|
setBufferCursor(buffer_id: number, position: number): boolean;
|
|
747
|
+
/**
|
|
748
|
+
* Execute a built-in editor action by name
|
|
749
|
+
*
|
|
750
|
+
* This is used by vi mode plugin to run motions and then check cursor position.
|
|
751
|
+
* For example, to implement "dw" (delete word), the plugin:
|
|
752
|
+
* 1. Saves current cursor position
|
|
753
|
+
* 2. Calls executeAction("move_word_right") - cursor moves
|
|
754
|
+
* 3. Gets new cursor position
|
|
755
|
+
* 4. Deletes from old to new position
|
|
756
|
+
*
|
|
757
|
+
* @param action_name - Action name (e.g., "move_word_right", "move_line_end")
|
|
758
|
+
* @returns true if action was sent successfully
|
|
759
|
+
*/
|
|
760
|
+
executeAction(action_name: string): boolean;
|
|
761
|
+
/**
|
|
762
|
+
* Execute multiple actions in sequence, each with an optional repeat count
|
|
763
|
+
*
|
|
764
|
+
* Used by vi mode for count prefix (e.g., "3dw" = delete 3 words).
|
|
765
|
+
* All actions execute atomically with no plugin roundtrips between them.
|
|
766
|
+
*
|
|
767
|
+
* @param actions - Array of {action: string, count?: number} objects
|
|
768
|
+
* @returns true if actions were sent successfully
|
|
769
|
+
*/
|
|
770
|
+
executeActions(actions: ActionSpecJs[]): boolean;
|
|
771
|
+
/**
|
|
772
|
+
* Set the global editor mode (for modal editing like vi mode)
|
|
773
|
+
*
|
|
774
|
+
* When a mode is set, its keybindings take precedence over normal key handling.
|
|
775
|
+
* Pass null/undefined to clear the mode and return to normal editing.
|
|
776
|
+
*
|
|
777
|
+
* @param mode - Mode name (e.g., "vi-normal") or null to clear
|
|
778
|
+
* @returns true if command was sent successfully
|
|
779
|
+
*/
|
|
780
|
+
setEditorMode(mode?: string | null): boolean;
|
|
781
|
+
/**
|
|
782
|
+
* Show an action popup with buttons for user interaction
|
|
783
|
+
*
|
|
784
|
+
* When the user selects an action, the ActionPopupResult hook is fired.
|
|
785
|
+
* @param options - Popup configuration with id, title, message, and actions
|
|
786
|
+
*/
|
|
787
|
+
showActionPopup(options: TsActionPopupOptions): boolean;
|
|
788
|
+
/**
|
|
789
|
+
* Disable LSP for a specific language and persist to config
|
|
790
|
+
*
|
|
791
|
+
* This is used by LSP helper plugins to let users disable LSP for languages
|
|
792
|
+
* where the server is not available or not working.
|
|
793
|
+
* @param language - The language to disable LSP for (e.g., "python", "rust")
|
|
794
|
+
*/
|
|
795
|
+
disableLspForLanguage(language: string): boolean;
|
|
700
796
|
|
|
701
797
|
/**
|
|
702
798
|
* Spawn an external process and return a cancellable handle
|
|
@@ -736,7 +832,7 @@ interface EditorAPI {
|
|
|
736
832
|
* @param italic - Use italic text
|
|
737
833
|
* @returns true if overlay was added
|
|
738
834
|
*/
|
|
739
|
-
addOverlay(buffer_id: number, namespace: string, start: number, end: number, r: number, g: number, b: number, underline: boolean, bold: boolean, italic: boolean): boolean;
|
|
835
|
+
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): boolean;
|
|
740
836
|
/**
|
|
741
837
|
* Remove a specific overlay by its handle
|
|
742
838
|
* @param buffer_id - The buffer ID
|
|
@@ -1011,7 +1107,7 @@ interface EditorAPI {
|
|
|
1011
1107
|
* ["q", "close_buffer"]
|
|
1012
1108
|
* ], true);
|
|
1013
1109
|
*/
|
|
1014
|
-
defineMode(name: string, parent
|
|
1110
|
+
defineMode(name: string, parent: string, bindings: Vec<(String, String): boolean;
|
|
1015
1111
|
/**
|
|
1016
1112
|
* Switch the current split to display a buffer
|
|
1017
1113
|
* @param buffer_id - ID of the buffer to show
|