@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,166 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* C/C++ LSP Helper Plugin
|
|
5
|
+
*
|
|
6
|
+
* Provides user-friendly error handling for C/C++ LSP server issues.
|
|
7
|
+
* When clangd fails to start, this plugin shows an actionable
|
|
8
|
+
* popup with installation instructions.
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Detects C/C++ LSP server errors (clangd)
|
|
12
|
+
* - Shows popup with install commands (apt, brew, etc.)
|
|
13
|
+
* - Allows copying install commands to clipboard
|
|
14
|
+
* - Provides option to disable C/C++ 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 C/C++ LSP server (clangd)
|
|
35
|
+
// See: https://clangd.llvm.org/installation
|
|
36
|
+
const INSTALL_COMMANDS = {
|
|
37
|
+
apt: "sudo apt install clangd",
|
|
38
|
+
brew: "brew install llvm",
|
|
39
|
+
pacman: "sudo pacman -S clang",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Languages handled by this plugin
|
|
43
|
+
const HANDLED_LANGUAGES = ["c", "cpp"];
|
|
44
|
+
|
|
45
|
+
// Track error state for C/C++ LSP
|
|
46
|
+
let clangdLspError: {
|
|
47
|
+
serverCommand: string;
|
|
48
|
+
message: string;
|
|
49
|
+
language: string;
|
|
50
|
+
} | null = null;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Handle LSP server errors for C/C++
|
|
54
|
+
*/
|
|
55
|
+
globalThis.on_clangd_lsp_server_error = function (
|
|
56
|
+
data: LspServerErrorData
|
|
57
|
+
): void {
|
|
58
|
+
// Only handle C/C++ language errors
|
|
59
|
+
if (!HANDLED_LANGUAGES.includes(data.language)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
editor.debug(`clangd-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
64
|
+
|
|
65
|
+
// Store error state for later reference
|
|
66
|
+
clangdLspError = {
|
|
67
|
+
serverCommand: data.server_command,
|
|
68
|
+
message: data.message,
|
|
69
|
+
language: data.language,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Show a status message for immediate feedback
|
|
73
|
+
if (data.error_type === "not_found") {
|
|
74
|
+
editor.setStatus(
|
|
75
|
+
`C/C++ LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
76
|
+
);
|
|
77
|
+
} else {
|
|
78
|
+
editor.setStatus(`C/C++ LSP error: ${data.message}`);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// Register hook for LSP server errors
|
|
83
|
+
editor.on("lsp_server_error", "on_clangd_lsp_server_error");
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Handle status bar click when there's a C/C++ LSP error
|
|
87
|
+
*/
|
|
88
|
+
globalThis.on_clangd_lsp_status_clicked = function (
|
|
89
|
+
data: LspStatusClickedData
|
|
90
|
+
): void {
|
|
91
|
+
// Only handle C/C++ language clicks when there's an error
|
|
92
|
+
if (!HANDLED_LANGUAGES.includes(data.language) || !clangdLspError) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
editor.debug("clangd-lsp: Status clicked, showing help popup");
|
|
97
|
+
|
|
98
|
+
// Show action popup with install options
|
|
99
|
+
editor.showActionPopup({
|
|
100
|
+
id: "clangd-lsp-help",
|
|
101
|
+
title: "C/C++ Language Server Not Found",
|
|
102
|
+
message: `"${clangdLspError.serverCommand}" provides code completion, diagnostics, and navigation for C/C++ files. Copy a command below to install it for your platform.`,
|
|
103
|
+
actions: [
|
|
104
|
+
{ id: "copy_apt", label: `Copy: ${INSTALL_COMMANDS.apt}` },
|
|
105
|
+
{ id: "copy_brew", label: `Copy: ${INSTALL_COMMANDS.brew}` },
|
|
106
|
+
{ id: "copy_pacman", label: `Copy: ${INSTALL_COMMANDS.pacman}` },
|
|
107
|
+
{ id: "disable", label: "Disable C/C++ LSP" },
|
|
108
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
109
|
+
],
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// Register hook for status bar clicks
|
|
114
|
+
editor.on("lsp_status_clicked", "on_clangd_lsp_status_clicked");
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Handle action popup results for C/C++ LSP help
|
|
118
|
+
*/
|
|
119
|
+
globalThis.on_clangd_lsp_action_result = function (
|
|
120
|
+
data: ActionPopupResultData
|
|
121
|
+
): void {
|
|
122
|
+
// Only handle our popup
|
|
123
|
+
if (data.popup_id !== "clangd-lsp-help") {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
editor.debug(`clangd-lsp: Action selected - ${data.action_id}`);
|
|
128
|
+
|
|
129
|
+
switch (data.action_id) {
|
|
130
|
+
case "copy_apt":
|
|
131
|
+
editor.setClipboard(INSTALL_COMMANDS.apt);
|
|
132
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.apt);
|
|
133
|
+
break;
|
|
134
|
+
|
|
135
|
+
case "copy_brew":
|
|
136
|
+
editor.setClipboard(INSTALL_COMMANDS.brew);
|
|
137
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.brew);
|
|
138
|
+
break;
|
|
139
|
+
|
|
140
|
+
case "copy_pacman":
|
|
141
|
+
editor.setClipboard(INSTALL_COMMANDS.pacman);
|
|
142
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.pacman);
|
|
143
|
+
break;
|
|
144
|
+
|
|
145
|
+
case "disable":
|
|
146
|
+
// Disable for both C and C++
|
|
147
|
+
editor.disableLspForLanguage("c");
|
|
148
|
+
editor.disableLspForLanguage("cpp");
|
|
149
|
+
editor.setStatus("C/C++ LSP disabled");
|
|
150
|
+
clangdLspError = null;
|
|
151
|
+
break;
|
|
152
|
+
|
|
153
|
+
case "dismiss":
|
|
154
|
+
case "dismissed":
|
|
155
|
+
// Just close the popup without action
|
|
156
|
+
break;
|
|
157
|
+
|
|
158
|
+
default:
|
|
159
|
+
editor.debug(`clangd-lsp: Unknown action: ${data.action_id}`);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// Register hook for action popup results
|
|
164
|
+
editor.on("action_popup_result", "on_clangd_lsp_action_result");
|
|
165
|
+
|
|
166
|
+
editor.debug("clangd-lsp: Plugin loaded");
|
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
"description": "Main configuration structure",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|
|
7
|
+
"version": {
|
|
8
|
+
"description": "Configuration version (for migration support)\nConfigs without this field are treated as version 0",
|
|
9
|
+
"type": "integer",
|
|
10
|
+
"format": "uint32",
|
|
11
|
+
"minimum": 0,
|
|
12
|
+
"default": 0
|
|
13
|
+
},
|
|
7
14
|
"theme": {
|
|
8
15
|
"description": "Color theme name",
|
|
9
16
|
"$ref": "#/$defs/ThemeOptions",
|
|
@@ -37,7 +44,9 @@
|
|
|
37
44
|
"mouse_hover_delay_ms": 500,
|
|
38
45
|
"double_click_time_ms": 500,
|
|
39
46
|
"auto_revert_poll_interval_ms": 2000,
|
|
40
|
-
"file_tree_poll_interval_ms": 3000
|
|
47
|
+
"file_tree_poll_interval_ms": 3000,
|
|
48
|
+
"default_line_ending": "lf",
|
|
49
|
+
"cursor_style": "default"
|
|
41
50
|
}
|
|
42
51
|
},
|
|
43
52
|
"file_explorer": {
|
|
@@ -51,6 +60,13 @@
|
|
|
51
60
|
"width": 0.30000001192092896
|
|
52
61
|
}
|
|
53
62
|
},
|
|
63
|
+
"file_browser": {
|
|
64
|
+
"description": "File browser settings (Open File dialog)",
|
|
65
|
+
"$ref": "#/$defs/FileBrowserConfig",
|
|
66
|
+
"default": {
|
|
67
|
+
"show_hidden": false
|
|
68
|
+
}
|
|
69
|
+
},
|
|
54
70
|
"terminal": {
|
|
55
71
|
"description": "Terminal settings",
|
|
56
72
|
"$ref": "#/$defs/TerminalConfig",
|
|
@@ -98,6 +114,13 @@
|
|
|
98
114
|
"menu": {
|
|
99
115
|
"description": "Menu bar configuration",
|
|
100
116
|
"$ref": "#/$defs/MenuConfig"
|
|
117
|
+
},
|
|
118
|
+
"warnings": {
|
|
119
|
+
"description": "Warning notification settings",
|
|
120
|
+
"$ref": "#/$defs/WarningsConfig",
|
|
121
|
+
"default": {
|
|
122
|
+
"show_status_indicator": true
|
|
123
|
+
}
|
|
101
124
|
}
|
|
102
125
|
},
|
|
103
126
|
"$defs": {
|
|
@@ -128,7 +151,7 @@
|
|
|
128
151
|
"default": true
|
|
129
152
|
},
|
|
130
153
|
"line_numbers": {
|
|
131
|
-
"description": "Show line numbers in the gutter",
|
|
154
|
+
"description": "Show line numbers in the gutter (default for new buffers)",
|
|
132
155
|
"type": "boolean",
|
|
133
156
|
"default": true
|
|
134
157
|
},
|
|
@@ -150,7 +173,7 @@
|
|
|
150
173
|
"default": true
|
|
151
174
|
},
|
|
152
175
|
"line_wrap": {
|
|
153
|
-
"description": "Wrap long lines to fit the window width",
|
|
176
|
+
"description": "Wrap long lines to fit the window width (default for new views)",
|
|
154
177
|
"type": "boolean",
|
|
155
178
|
"default": true
|
|
156
179
|
},
|
|
@@ -238,9 +261,42 @@
|
|
|
238
261
|
"format": "uint64",
|
|
239
262
|
"minimum": 0,
|
|
240
263
|
"default": 3000
|
|
264
|
+
},
|
|
265
|
+
"default_line_ending": {
|
|
266
|
+
"description": "Default line ending format for new files.\nFiles loaded from disk will use their detected line ending format.\nOptions: \"lf\" (Unix/Linux/macOS), \"crlf\" (Windows), \"cr\" (Classic Mac)\nDefault: \"lf\"",
|
|
267
|
+
"$ref": "#/$defs/LineEndingOption",
|
|
268
|
+
"default": "lf"
|
|
269
|
+
},
|
|
270
|
+
"cursor_style": {
|
|
271
|
+
"description": "Cursor style for the terminal cursor.\nOptions: blinking_block, steady_block, blinking_bar, steady_bar, blinking_underline, steady_underline\nDefault: blinking_block",
|
|
272
|
+
"$ref": "#/$defs/CursorStyle",
|
|
273
|
+
"default": "default"
|
|
241
274
|
}
|
|
242
275
|
}
|
|
243
276
|
},
|
|
277
|
+
"LineEndingOption": {
|
|
278
|
+
"description": "Default line ending format for new files",
|
|
279
|
+
"type": "string",
|
|
280
|
+
"enum": [
|
|
281
|
+
"lf",
|
|
282
|
+
"crlf",
|
|
283
|
+
"cr"
|
|
284
|
+
],
|
|
285
|
+
"default": "lf"
|
|
286
|
+
},
|
|
287
|
+
"CursorStyle": {
|
|
288
|
+
"description": "Terminal cursor style",
|
|
289
|
+
"type": "string",
|
|
290
|
+
"enum": [
|
|
291
|
+
"default",
|
|
292
|
+
"blinking_block",
|
|
293
|
+
"steady_block",
|
|
294
|
+
"blinking_bar",
|
|
295
|
+
"steady_bar",
|
|
296
|
+
"blinking_underline",
|
|
297
|
+
"steady_underline"
|
|
298
|
+
]
|
|
299
|
+
},
|
|
244
300
|
"FileExplorerConfig": {
|
|
245
301
|
"description": "File explorer configuration",
|
|
246
302
|
"type": "object",
|
|
@@ -276,6 +332,17 @@
|
|
|
276
332
|
}
|
|
277
333
|
}
|
|
278
334
|
},
|
|
335
|
+
"FileBrowserConfig": {
|
|
336
|
+
"description": "File browser configuration (for Open File dialog)",
|
|
337
|
+
"type": "object",
|
|
338
|
+
"properties": {
|
|
339
|
+
"show_hidden": {
|
|
340
|
+
"description": "Whether to show hidden files (starting with .) by default in Open File dialog",
|
|
341
|
+
"type": "boolean",
|
|
342
|
+
"default": false
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
},
|
|
279
346
|
"TerminalConfig": {
|
|
280
347
|
"description": "Terminal configuration",
|
|
281
348
|
"type": "object",
|
|
@@ -456,8 +523,25 @@
|
|
|
456
523
|
"minimum": 0,
|
|
457
524
|
"default": null
|
|
458
525
|
},
|
|
526
|
+
"formatter": {
|
|
527
|
+
"description": "The formatter for this language (used by format_buffer command)",
|
|
528
|
+
"anyOf": [
|
|
529
|
+
{
|
|
530
|
+
"$ref": "#/$defs/FormatterConfig"
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
"type": "null"
|
|
534
|
+
}
|
|
535
|
+
],
|
|
536
|
+
"default": null
|
|
537
|
+
},
|
|
538
|
+
"format_on_save": {
|
|
539
|
+
"description": "Whether to automatically format on save (uses the formatter above)",
|
|
540
|
+
"type": "boolean",
|
|
541
|
+
"default": false
|
|
542
|
+
},
|
|
459
543
|
"on_save": {
|
|
460
|
-
"description": "Actions to run when a file of this language is saved\nActions are run in order; if any fails (non-zero exit), subsequent actions don't run",
|
|
544
|
+
"description": "Actions to run when a file of this language is saved (linters, etc.)\nActions are run in order; if any fails (non-zero exit), subsequent actions don't run\nNote: Use `formatter` + `format_on_save` for formatting, not on_save",
|
|
461
545
|
"type": "array",
|
|
462
546
|
"items": {
|
|
463
547
|
"$ref": "#/$defs/OnSaveAction"
|
|
@@ -487,8 +571,42 @@
|
|
|
487
571
|
}
|
|
488
572
|
]
|
|
489
573
|
},
|
|
574
|
+
"FormatterConfig": {
|
|
575
|
+
"description": "Formatter configuration for a language",
|
|
576
|
+
"type": "object",
|
|
577
|
+
"properties": {
|
|
578
|
+
"command": {
|
|
579
|
+
"description": "The formatter command to run (e.g., \"rustfmt\", \"prettier\")",
|
|
580
|
+
"type": "string"
|
|
581
|
+
},
|
|
582
|
+
"args": {
|
|
583
|
+
"description": "Arguments to pass to the formatter\nUse \"$FILE\" to include the file path",
|
|
584
|
+
"type": "array",
|
|
585
|
+
"items": {
|
|
586
|
+
"type": "string"
|
|
587
|
+
},
|
|
588
|
+
"default": []
|
|
589
|
+
},
|
|
590
|
+
"stdin": {
|
|
591
|
+
"description": "Whether to pass buffer content via stdin (default: true)\nMost formatters read from stdin and write to stdout",
|
|
592
|
+
"type": "boolean",
|
|
593
|
+
"default": true
|
|
594
|
+
},
|
|
595
|
+
"timeout_ms": {
|
|
596
|
+
"description": "Timeout in milliseconds (default: 10000)",
|
|
597
|
+
"type": "integer",
|
|
598
|
+
"format": "uint64",
|
|
599
|
+
"minimum": 0,
|
|
600
|
+
"default": 10000
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
"required": [
|
|
604
|
+
"command"
|
|
605
|
+
],
|
|
606
|
+
"x-display-field": "/command"
|
|
607
|
+
},
|
|
490
608
|
"OnSaveAction": {
|
|
491
|
-
"description": "Action to run when a file is saved",
|
|
609
|
+
"description": "Action to run when a file is saved (for linters, etc.)",
|
|
492
610
|
"type": "object",
|
|
493
611
|
"properties": {
|
|
494
612
|
"command": {
|
|
@@ -516,11 +634,6 @@
|
|
|
516
634
|
"type": "boolean",
|
|
517
635
|
"default": false
|
|
518
636
|
},
|
|
519
|
-
"replace_buffer": {
|
|
520
|
-
"description": "Whether to replace the buffer with the command's stdout\nUseful for formatters",
|
|
521
|
-
"type": "boolean",
|
|
522
|
-
"default": false
|
|
523
|
-
},
|
|
524
637
|
"timeout_ms": {
|
|
525
638
|
"description": "Timeout in milliseconds (default: 10000)",
|
|
526
639
|
"type": "integer",
|
|
@@ -528,11 +641,6 @@
|
|
|
528
641
|
"minimum": 0,
|
|
529
642
|
"default": 10000
|
|
530
643
|
},
|
|
531
|
-
"optional": {
|
|
532
|
-
"description": "Whether this action is optional (won't error if command not found)\nUseful for default formatters that may not be installed\nWhen true, shows a status message instead of an error if command is missing",
|
|
533
|
-
"type": "boolean",
|
|
534
|
-
"default": false
|
|
535
|
-
},
|
|
536
644
|
"enabled": {
|
|
537
645
|
"description": "Whether this action is enabled (default: true)\nSet to false to disable an action without removing it from config",
|
|
538
646
|
"type": "boolean",
|
|
@@ -754,6 +862,17 @@
|
|
|
754
862
|
]
|
|
755
863
|
}
|
|
756
864
|
]
|
|
865
|
+
},
|
|
866
|
+
"WarningsConfig": {
|
|
867
|
+
"description": "Warning notification configuration",
|
|
868
|
+
"type": "object",
|
|
869
|
+
"properties": {
|
|
870
|
+
"show_status_indicator": {
|
|
871
|
+
"description": "Show warning/error indicators in the status bar (default: true)\nWhen enabled, displays a colored indicator for LSP errors and other warnings",
|
|
872
|
+
"type": "boolean",
|
|
873
|
+
"default": true
|
|
874
|
+
}
|
|
875
|
+
}
|
|
757
876
|
}
|
|
758
877
|
}
|
|
759
878
|
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* C# LSP Helper Plugin
|
|
5
|
+
*
|
|
6
|
+
* Provides user-friendly error handling for C# LSP server issues.
|
|
7
|
+
* When csharp-ls fails to start, this plugin shows an actionable
|
|
8
|
+
* popup with installation instructions.
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Detects C# LSP server errors (csharp-ls)
|
|
12
|
+
* - Shows popup with install commands (dotnet tool)
|
|
13
|
+
* - Allows copying install commands to clipboard
|
|
14
|
+
* - Provides option to disable C# 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 C# LSP server (csharp-ls)
|
|
35
|
+
// Requires .NET SDK to be installed
|
|
36
|
+
// See: https://github.com/razzmatazz/csharp-language-server
|
|
37
|
+
const INSTALL_COMMANDS = {
|
|
38
|
+
dotnet: "dotnet tool install --global csharp-ls",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Track error state for C# LSP
|
|
42
|
+
let csharpLspError: { serverCommand: string; message: string } | null = null;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Handle LSP server errors for C#
|
|
46
|
+
*/
|
|
47
|
+
globalThis.on_csharp_lsp_server_error = function (
|
|
48
|
+
data: LspServerErrorData
|
|
49
|
+
): void {
|
|
50
|
+
// Only handle C# language errors
|
|
51
|
+
if (data.language !== "csharp") {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
editor.debug(
|
|
56
|
+
`csharp-lsp: Server error - ${data.error_type}: ${data.message}`
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
// Store error state for later reference
|
|
60
|
+
csharpLspError = {
|
|
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
|
+
`C# LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
69
|
+
);
|
|
70
|
+
} else {
|
|
71
|
+
editor.setStatus(`C# LSP error: ${data.message}`);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Register hook for LSP server errors
|
|
76
|
+
editor.on("lsp_server_error", "on_csharp_lsp_server_error");
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Handle status bar click when there's a C# LSP error
|
|
80
|
+
*/
|
|
81
|
+
globalThis.on_csharp_lsp_status_clicked = function (
|
|
82
|
+
data: LspStatusClickedData
|
|
83
|
+
): void {
|
|
84
|
+
// Only handle C# language clicks when there's an error
|
|
85
|
+
if (data.language !== "csharp" || !csharpLspError) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
editor.debug("csharp-lsp: Status clicked, showing help popup");
|
|
90
|
+
|
|
91
|
+
// Show action popup with install options
|
|
92
|
+
editor.showActionPopup({
|
|
93
|
+
id: "csharp-lsp-help",
|
|
94
|
+
title: "C# Language Server Not Found",
|
|
95
|
+
message: `"${csharpLspError.serverCommand}" provides code completion, diagnostics, and navigation for C# files. Requires .NET SDK. Copy the command below to install it.`,
|
|
96
|
+
actions: [
|
|
97
|
+
{ id: "copy_dotnet", label: `Copy: ${INSTALL_COMMANDS.dotnet}` },
|
|
98
|
+
{ id: "disable", label: "Disable C# 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_csharp_lsp_status_clicked");
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Handle action popup results for C# LSP help
|
|
109
|
+
*/
|
|
110
|
+
globalThis.on_csharp_lsp_action_result = function (
|
|
111
|
+
data: ActionPopupResultData
|
|
112
|
+
): void {
|
|
113
|
+
// Only handle our popup
|
|
114
|
+
if (data.popup_id !== "csharp-lsp-help") {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
editor.debug(`csharp-lsp: Action selected - ${data.action_id}`);
|
|
119
|
+
|
|
120
|
+
switch (data.action_id) {
|
|
121
|
+
case "copy_dotnet":
|
|
122
|
+
editor.setClipboard(INSTALL_COMMANDS.dotnet);
|
|
123
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.dotnet);
|
|
124
|
+
break;
|
|
125
|
+
|
|
126
|
+
case "disable":
|
|
127
|
+
editor.disableLspForLanguage("csharp");
|
|
128
|
+
editor.setStatus("C# LSP disabled");
|
|
129
|
+
csharpLspError = 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(`csharp-lsp: Unknown action: ${data.action_id}`);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// Register hook for action popup results
|
|
143
|
+
editor.on("action_popup_result", "on_csharp_lsp_action_result");
|
|
144
|
+
|
|
145
|
+
editor.debug("csharp-lsp: Plugin loaded");
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CSS LSP Helper Plugin
|
|
5
|
+
*
|
|
6
|
+
* Provides user-friendly error handling for CSS LSP server issues.
|
|
7
|
+
* When the CSS language server fails to start, this plugin shows an
|
|
8
|
+
* actionable popup with installation instructions.
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Detects CSS LSP server errors
|
|
12
|
+
* - Shows popup with install commands (npm)
|
|
13
|
+
* - Allows copying install commands to clipboard
|
|
14
|
+
* - Provides option to disable CSS 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 CSS 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 CSS LSP
|
|
42
|
+
let cssLspError: { serverCommand: string; message: string } | null = null;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Handle LSP server errors for CSS
|
|
46
|
+
*/
|
|
47
|
+
globalThis.on_css_lsp_server_error = function (data: LspServerErrorData): void {
|
|
48
|
+
// Only handle CSS language errors
|
|
49
|
+
if (data.language !== "css") {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
editor.debug(`css-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
54
|
+
|
|
55
|
+
// Store error state for later reference
|
|
56
|
+
cssLspError = {
|
|
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
|
+
`CSS LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
editor.setStatus(`CSS LSP error: ${data.message}`);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Register hook for LSP server errors
|
|
72
|
+
editor.on("lsp_server_error", "on_css_lsp_server_error");
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Handle status bar click when there's a CSS LSP error
|
|
76
|
+
*/
|
|
77
|
+
globalThis.on_css_lsp_status_clicked = function (
|
|
78
|
+
data: LspStatusClickedData
|
|
79
|
+
): void {
|
|
80
|
+
// Only handle CSS language clicks when there's an error
|
|
81
|
+
if (data.language !== "css" || !cssLspError) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
editor.debug("css-lsp: Status clicked, showing help popup");
|
|
86
|
+
|
|
87
|
+
// Show action popup with install options
|
|
88
|
+
editor.showActionPopup({
|
|
89
|
+
id: "css-lsp-help",
|
|
90
|
+
title: "CSS Language Server Not Found",
|
|
91
|
+
message: `"${cssLspError.serverCommand}" provides code completion, diagnostics, and formatting for CSS files. Copy the command below to install it.`,
|
|
92
|
+
actions: [
|
|
93
|
+
{ id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
|
|
94
|
+
{ id: "disable", label: "Disable CSS 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_css_lsp_status_clicked");
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Handle action popup results for CSS LSP help
|
|
105
|
+
*/
|
|
106
|
+
globalThis.on_css_lsp_action_result = function (
|
|
107
|
+
data: ActionPopupResultData
|
|
108
|
+
): void {
|
|
109
|
+
// Only handle our popup
|
|
110
|
+
if (data.popup_id !== "css-lsp-help") {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
editor.debug(`css-lsp: Action selected - ${data.action_id}`);
|
|
115
|
+
|
|
116
|
+
switch (data.action_id) {
|
|
117
|
+
case "copy_npm":
|
|
118
|
+
editor.setClipboard(INSTALL_COMMANDS.npm);
|
|
119
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.npm);
|
|
120
|
+
break;
|
|
121
|
+
|
|
122
|
+
case "disable":
|
|
123
|
+
editor.disableLspForLanguage("css");
|
|
124
|
+
editor.setStatus("CSS LSP disabled");
|
|
125
|
+
cssLspError = 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(`css-lsp: Unknown action: ${data.action_id}`);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// Register hook for action popup results
|
|
139
|
+
editor.on("action_popup_result", "on_css_lsp_action_result");
|
|
140
|
+
|
|
141
|
+
editor.debug("css-lsp: Plugin loaded");
|