@fresh-editor/fresh-editor 0.1.65 → 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 +48 -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 +54 -1
- 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,164 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Rust LSP Helper Plugin
|
|
5
|
+
*
|
|
6
|
+
* Provides user-friendly error handling for Rust LSP server issues.
|
|
7
|
+
* When rust-analyzer fails to start, this plugin shows an actionable
|
|
8
|
+
* popup with installation instructions.
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Detects Rust LSP server errors (rust-analyzer)
|
|
12
|
+
* - Shows popup with install commands (rustup, brew)
|
|
13
|
+
* - Allows copying install commands to clipboard
|
|
14
|
+
* - Provides option to disable Rust 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 Rust LSP server
|
|
35
|
+
// rustup is the official recommended method
|
|
36
|
+
// brew is a good alternative for macOS users
|
|
37
|
+
// See: https://rust-analyzer.github.io/book/installation.html
|
|
38
|
+
const INSTALL_COMMANDS = {
|
|
39
|
+
rustup: "rustup component add rust-analyzer",
|
|
40
|
+
brew: "brew install rust-analyzer",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Track error state for Rust LSP
|
|
44
|
+
let rustLspError: { serverCommand: string; message: string } | null = null;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Handle LSP server errors for Rust
|
|
48
|
+
*/
|
|
49
|
+
globalThis.on_rust_lsp_server_error = function (
|
|
50
|
+
data: LspServerErrorData
|
|
51
|
+
): void {
|
|
52
|
+
// Only handle Rust language errors
|
|
53
|
+
if (data.language !== "rust") {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
editor.debug(`rust-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
58
|
+
|
|
59
|
+
// Store error state for later reference
|
|
60
|
+
rustLspError = {
|
|
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
|
+
`Rust LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
69
|
+
);
|
|
70
|
+
} else {
|
|
71
|
+
editor.setStatus(`Rust LSP error: ${data.message}`);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Register hook for LSP server errors
|
|
76
|
+
editor.on("lsp_server_error", "on_rust_lsp_server_error");
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Handle status bar click when there's a Rust LSP error
|
|
80
|
+
*/
|
|
81
|
+
globalThis.on_rust_lsp_status_clicked = function (
|
|
82
|
+
data: LspStatusClickedData
|
|
83
|
+
): void {
|
|
84
|
+
editor.debug(
|
|
85
|
+
`rust-lsp: lsp_status_clicked hook received - language=${data.language}, has_error=${data.has_error}, rustLspError=${rustLspError ? "SET" : "NULL"}`
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// Only handle Rust language clicks when there's an error
|
|
89
|
+
if (data.language !== "rust" || !rustLspError) {
|
|
90
|
+
editor.debug(
|
|
91
|
+
`rust-lsp: Skipping - language check=${data.language !== "rust"}, error check=${!rustLspError}`
|
|
92
|
+
);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
editor.debug("rust-lsp: Status clicked, showing help popup");
|
|
97
|
+
|
|
98
|
+
// Show action popup with install options
|
|
99
|
+
const result = editor.showActionPopup({
|
|
100
|
+
id: "rust-lsp-help",
|
|
101
|
+
title: "Rust Language Server Not Found",
|
|
102
|
+
message: `"${rustLspError.serverCommand}" provides code completion, diagnostics, and navigation for Rust files. Copy a command below to install it, or search online for your platform.`,
|
|
103
|
+
actions: [
|
|
104
|
+
{ id: "copy_rustup", label: `Copy: ${INSTALL_COMMANDS.rustup}` },
|
|
105
|
+
{ id: "copy_brew", label: `Copy: ${INSTALL_COMMANDS.brew}` },
|
|
106
|
+
{ id: "disable", label: "Disable Rust LSP" },
|
|
107
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
108
|
+
],
|
|
109
|
+
});
|
|
110
|
+
editor.debug(`rust-lsp: showActionPopup returned ${result}`);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// Register hook for status bar clicks
|
|
114
|
+
editor.on("lsp_status_clicked", "on_rust_lsp_status_clicked");
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Handle action popup results for Rust LSP help
|
|
118
|
+
*/
|
|
119
|
+
globalThis.on_rust_lsp_action_result = function (
|
|
120
|
+
data: ActionPopupResultData
|
|
121
|
+
): void {
|
|
122
|
+
editor.debug(
|
|
123
|
+
`rust-lsp: action_popup_result received - popup_id=${data.popup_id}, action_id=${data.action_id}`
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
// Only handle our popup
|
|
127
|
+
if (data.popup_id !== "rust-lsp-help") {
|
|
128
|
+
editor.debug("rust-lsp: Not our popup, skipping");
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
editor.debug(`rust-lsp: Action selected - ${data.action_id}, rustLspError will remain SET`);
|
|
133
|
+
|
|
134
|
+
switch (data.action_id) {
|
|
135
|
+
case "copy_rustup":
|
|
136
|
+
editor.setClipboard(INSTALL_COMMANDS.rustup);
|
|
137
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.rustup);
|
|
138
|
+
break;
|
|
139
|
+
|
|
140
|
+
case "copy_brew":
|
|
141
|
+
editor.setClipboard(INSTALL_COMMANDS.brew);
|
|
142
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.brew);
|
|
143
|
+
break;
|
|
144
|
+
|
|
145
|
+
case "disable":
|
|
146
|
+
editor.disableLspForLanguage("rust");
|
|
147
|
+
editor.setStatus("Rust LSP disabled");
|
|
148
|
+
rustLspError = null;
|
|
149
|
+
break;
|
|
150
|
+
|
|
151
|
+
case "dismiss":
|
|
152
|
+
case "dismissed":
|
|
153
|
+
// Just close the popup without action
|
|
154
|
+
break;
|
|
155
|
+
|
|
156
|
+
default:
|
|
157
|
+
editor.debug(`rust-lsp: Unknown action: ${data.action_id}`);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// Register hook for action popup results
|
|
162
|
+
editor.on("action_popup_result", "on_rust_lsp_action_result");
|
|
163
|
+
|
|
164
|
+
editor.debug("rust-lsp: Plugin loaded");
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TypeScript/JavaScript LSP Helper Plugin
|
|
5
|
+
*
|
|
6
|
+
* Provides user-friendly error handling for TypeScript/JavaScript LSP server issues.
|
|
7
|
+
* When typescript-language-server fails to start, this plugin shows an actionable
|
|
8
|
+
* popup with installation instructions.
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Detects TypeScript LSP server errors (typescript-language-server, tsserver)
|
|
12
|
+
* - Shows popup with install commands (npm, yarn, pnpm)
|
|
13
|
+
* - Allows copying install commands to clipboard
|
|
14
|
+
* - Provides option to disable TypeScript 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 TypeScript LSP server
|
|
35
|
+
// Both typescript-language-server AND typescript packages are required
|
|
36
|
+
// See: https://github.com/typescript-language-server/typescript-language-server
|
|
37
|
+
const INSTALL_COMMANDS = {
|
|
38
|
+
npm: "npm install -g typescript-language-server typescript",
|
|
39
|
+
yarn: "yarn global add typescript-language-server typescript",
|
|
40
|
+
pnpm: "pnpm add -g typescript-language-server typescript",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Languages handled by this plugin
|
|
44
|
+
const HANDLED_LANGUAGES = ["typescript", "javascript", "typescriptreact", "javascriptreact"];
|
|
45
|
+
|
|
46
|
+
// Track error state for TypeScript LSP
|
|
47
|
+
let tsLspError: { serverCommand: string; message: string; language: string } | null = null;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Handle LSP server errors for TypeScript/JavaScript
|
|
51
|
+
*/
|
|
52
|
+
globalThis.on_typescript_lsp_server_error = function (
|
|
53
|
+
data: LspServerErrorData
|
|
54
|
+
): void {
|
|
55
|
+
// Only handle TypeScript/JavaScript language errors
|
|
56
|
+
if (!HANDLED_LANGUAGES.includes(data.language)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
editor.debug(
|
|
61
|
+
`typescript-lsp: Server error - ${data.error_type}: ${data.message}`
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// Store error state for later reference
|
|
65
|
+
tsLspError = {
|
|
66
|
+
serverCommand: data.server_command,
|
|
67
|
+
message: data.message,
|
|
68
|
+
language: data.language,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Show a status message for immediate feedback
|
|
72
|
+
if (data.error_type === "not_found") {
|
|
73
|
+
editor.setStatus(
|
|
74
|
+
`TypeScript LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
75
|
+
);
|
|
76
|
+
} else {
|
|
77
|
+
editor.setStatus(`TypeScript LSP error: ${data.message}`);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Register hook for LSP server errors
|
|
82
|
+
editor.on("lsp_server_error", "on_typescript_lsp_server_error");
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Handle status bar click when there's a TypeScript LSP error
|
|
86
|
+
*/
|
|
87
|
+
globalThis.on_typescript_lsp_status_clicked = function (
|
|
88
|
+
data: LspStatusClickedData
|
|
89
|
+
): void {
|
|
90
|
+
// Only handle TypeScript/JavaScript language clicks when there's an error
|
|
91
|
+
if (!HANDLED_LANGUAGES.includes(data.language) || !tsLspError) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
editor.debug("typescript-lsp: Status clicked, showing help popup");
|
|
96
|
+
|
|
97
|
+
// Show action popup with install options
|
|
98
|
+
editor.showActionPopup({
|
|
99
|
+
id: "typescript-lsp-help",
|
|
100
|
+
title: "TypeScript Language Server Not Found",
|
|
101
|
+
message: `"${tsLspError.serverCommand}" provides code completion, diagnostics, and navigation for TypeScript/JavaScript files. Copy a command below to install it, or search online for your platform.`,
|
|
102
|
+
actions: [
|
|
103
|
+
{ id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
|
|
104
|
+
{ id: "copy_yarn", label: `Copy: ${INSTALL_COMMANDS.yarn}` },
|
|
105
|
+
{ id: "copy_pnpm", label: `Copy: ${INSTALL_COMMANDS.pnpm}` },
|
|
106
|
+
{ id: "disable", label: "Disable TypeScript LSP" },
|
|
107
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
108
|
+
],
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Register hook for status bar clicks
|
|
113
|
+
editor.on("lsp_status_clicked", "on_typescript_lsp_status_clicked");
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Handle action popup results for TypeScript LSP help
|
|
117
|
+
*/
|
|
118
|
+
globalThis.on_typescript_lsp_action_result = function (
|
|
119
|
+
data: ActionPopupResultData
|
|
120
|
+
): void {
|
|
121
|
+
// Only handle our popup
|
|
122
|
+
if (data.popup_id !== "typescript-lsp-help") {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
editor.debug(`typescript-lsp: Action selected - ${data.action_id}`);
|
|
127
|
+
|
|
128
|
+
switch (data.action_id) {
|
|
129
|
+
case "copy_npm":
|
|
130
|
+
editor.setClipboard(INSTALL_COMMANDS.npm);
|
|
131
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.npm);
|
|
132
|
+
break;
|
|
133
|
+
|
|
134
|
+
case "copy_yarn":
|
|
135
|
+
editor.setClipboard(INSTALL_COMMANDS.yarn);
|
|
136
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.yarn);
|
|
137
|
+
break;
|
|
138
|
+
|
|
139
|
+
case "copy_pnpm":
|
|
140
|
+
editor.setClipboard(INSTALL_COMMANDS.pnpm);
|
|
141
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.pnpm);
|
|
142
|
+
break;
|
|
143
|
+
|
|
144
|
+
case "disable":
|
|
145
|
+
// Disable for all TypeScript/JavaScript variants
|
|
146
|
+
editor.disableLspForLanguage("typescript");
|
|
147
|
+
editor.disableLspForLanguage("javascript");
|
|
148
|
+
editor.setStatus("TypeScript/JavaScript LSP disabled");
|
|
149
|
+
tsLspError = null;
|
|
150
|
+
break;
|
|
151
|
+
|
|
152
|
+
case "dismiss":
|
|
153
|
+
case "dismissed":
|
|
154
|
+
// Just close the popup without action
|
|
155
|
+
break;
|
|
156
|
+
|
|
157
|
+
default:
|
|
158
|
+
editor.debug(`typescript-lsp: Unknown action: ${data.action_id}`);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// Register hook for action popup results
|
|
163
|
+
editor.on("action_popup_result", "on_typescript_lsp_action_result");
|
|
164
|
+
|
|
165
|
+
editor.debug("typescript-lsp: Plugin loaded");
|