@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,147 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
const editor = getEditor();
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* C# LSP Helper Plugin
|
|
7
|
+
*
|
|
8
|
+
* Provides user-friendly error handling for C# LSP server issues.
|
|
9
|
+
* When csharp-ls fails to start, this plugin shows an actionable
|
|
10
|
+
* popup with installation instructions.
|
|
11
|
+
*
|
|
12
|
+
* Features:
|
|
13
|
+
* - Detects C# LSP server errors (csharp-ls)
|
|
14
|
+
* - Shows popup with install commands (dotnet tool)
|
|
15
|
+
* - Allows copying install commands to clipboard
|
|
16
|
+
* - Provides option to disable C# 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 C# LSP server (csharp-ls)
|
|
37
|
+
// Requires .NET SDK to be installed
|
|
38
|
+
// See: https://github.com/razzmatazz/csharp-language-server
|
|
39
|
+
const INSTALL_COMMANDS = {
|
|
40
|
+
dotnet: "dotnet tool install --global csharp-ls",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Track error state for C# LSP
|
|
44
|
+
let csharpLspError: { serverCommand: string; message: string } | null = null;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Handle LSP server errors for C#
|
|
48
|
+
*/
|
|
49
|
+
globalThis.on_csharp_lsp_server_error = function (
|
|
50
|
+
data: LspServerErrorData
|
|
51
|
+
): void {
|
|
52
|
+
// Only handle C# language errors
|
|
53
|
+
if (data.language !== "csharp") {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
editor.debug(
|
|
58
|
+
`csharp-lsp: Server error - ${data.error_type}: ${data.message}`
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
// Store error state for later reference
|
|
62
|
+
csharpLspError = {
|
|
63
|
+
serverCommand: data.server_command,
|
|
64
|
+
message: data.message,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Show a status message for immediate feedback
|
|
68
|
+
if (data.error_type === "not_found") {
|
|
69
|
+
editor.setStatus(
|
|
70
|
+
`C# LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
71
|
+
);
|
|
72
|
+
} else {
|
|
73
|
+
editor.setStatus(`C# LSP error: ${data.message}`);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// Register hook for LSP server errors
|
|
78
|
+
editor.on("lsp_server_error", "on_csharp_lsp_server_error");
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Handle status bar click when there's a C# LSP error
|
|
82
|
+
*/
|
|
83
|
+
globalThis.on_csharp_lsp_status_clicked = function (
|
|
84
|
+
data: LspStatusClickedData
|
|
85
|
+
): void {
|
|
86
|
+
// Only handle C# language clicks when there's an error
|
|
87
|
+
if (data.language !== "csharp" || !csharpLspError) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
editor.debug("csharp-lsp: Status clicked, showing help popup");
|
|
92
|
+
|
|
93
|
+
// Show action popup with install options
|
|
94
|
+
editor.showActionPopup({
|
|
95
|
+
id: "csharp-lsp-help",
|
|
96
|
+
title: "C# Language Server Not Found",
|
|
97
|
+
message: `"${csharpLspError.serverCommand}" provides code completion, diagnostics, and navigation for C# files. Requires .NET SDK. Copy the command below to install it.`,
|
|
98
|
+
actions: [
|
|
99
|
+
{ id: "copy_dotnet", label: `Copy: ${INSTALL_COMMANDS.dotnet}` },
|
|
100
|
+
{ id: "disable", label: "Disable C# LSP" },
|
|
101
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// Register hook for status bar clicks
|
|
107
|
+
editor.on("lsp_status_clicked", "on_csharp_lsp_status_clicked");
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Handle action popup results for C# LSP help
|
|
111
|
+
*/
|
|
112
|
+
globalThis.on_csharp_lsp_action_result = function (
|
|
113
|
+
data: ActionPopupResultData
|
|
114
|
+
): void {
|
|
115
|
+
// Only handle our popup
|
|
116
|
+
if (data.popup_id !== "csharp-lsp-help") {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
editor.debug(`csharp-lsp: Action selected - ${data.action_id}`);
|
|
121
|
+
|
|
122
|
+
switch (data.action_id) {
|
|
123
|
+
case "copy_dotnet":
|
|
124
|
+
editor.setClipboard(INSTALL_COMMANDS.dotnet);
|
|
125
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.dotnet);
|
|
126
|
+
break;
|
|
127
|
+
|
|
128
|
+
case "disable":
|
|
129
|
+
editor.disableLspForLanguage("csharp");
|
|
130
|
+
editor.setStatus("C# LSP disabled");
|
|
131
|
+
csharpLspError = null;
|
|
132
|
+
break;
|
|
133
|
+
|
|
134
|
+
case "dismiss":
|
|
135
|
+
case "dismissed":
|
|
136
|
+
// Just close the popup without action
|
|
137
|
+
break;
|
|
138
|
+
|
|
139
|
+
default:
|
|
140
|
+
editor.debug(`csharp-lsp: Unknown action: ${data.action_id}`);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// Register hook for action popup results
|
|
145
|
+
editor.on("action_popup_result", "on_csharp_lsp_action_result");
|
|
146
|
+
|
|
147
|
+
editor.debug("csharp-lsp: Plugin loaded");
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cs": {
|
|
3
|
+
"status.restoring_packages": "Obnovuji balicky NuGet pro {project}...",
|
|
4
|
+
"status.restore_completed": "Obnoveni NuGet dokonceno pro {project}",
|
|
5
|
+
"status.restore_failed": "Obnoveni NuGet selhalo: {error}",
|
|
6
|
+
"status.restore_error": "Chyba obnoveni NuGet: {error}"
|
|
7
|
+
},
|
|
8
|
+
"de": {
|
|
9
|
+
"status.restoring_packages": "NuGet-Pakete werden fur {project} wiederhergestellt...",
|
|
10
|
+
"status.restore_completed": "NuGet-Wiederherstellung fur {project} abgeschlossen",
|
|
11
|
+
"status.restore_failed": "NuGet-Wiederherstellung fehlgeschlagen: {error}",
|
|
12
|
+
"status.restore_error": "NuGet-Wiederherstellungsfehler: {error}"
|
|
13
|
+
},
|
|
14
|
+
"en": {
|
|
15
|
+
"status.restoring_packages": "Restoring NuGet packages for {project}...",
|
|
16
|
+
"status.restore_completed": "NuGet restore completed for {project}",
|
|
17
|
+
"status.restore_failed": "NuGet restore failed: {error}",
|
|
18
|
+
"status.restore_error": "NuGet restore error: {error}"
|
|
19
|
+
},
|
|
20
|
+
"es": {
|
|
21
|
+
"status.restoring_packages": "Restaurando paquetes NuGet para {project}...",
|
|
22
|
+
"status.restore_completed": "Restauracion de NuGet completada para {project}",
|
|
23
|
+
"status.restore_failed": "Restauracion de NuGet fallida: {error}",
|
|
24
|
+
"status.restore_error": "Error de restauracion de NuGet: {error}"
|
|
25
|
+
},
|
|
26
|
+
"fr": {
|
|
27
|
+
"status.restoring_packages": "Restauration des paquets NuGet pour {project}...",
|
|
28
|
+
"status.restore_completed": "Restauration NuGet terminee pour {project}",
|
|
29
|
+
"status.restore_failed": "Echec de la restauration NuGet: {error}",
|
|
30
|
+
"status.restore_error": "Erreur de restauration NuGet: {error}"
|
|
31
|
+
},
|
|
32
|
+
"it": {
|
|
33
|
+
"status.restoring_packages": "Ripristino pacchetti NuGet per {project}...",
|
|
34
|
+
"status.restore_completed": "Ripristino NuGet completato per {project}",
|
|
35
|
+
"status.restore_failed": "Ripristino NuGet fallito: {error}",
|
|
36
|
+
"status.restore_error": "Errore ripristino NuGet: {error}"
|
|
37
|
+
},
|
|
38
|
+
"ja": {
|
|
39
|
+
"status.restoring_packages": "{project}のNuGetパッケージを復元中...",
|
|
40
|
+
"status.restore_completed": "{project}のNuGet復元が完了しました",
|
|
41
|
+
"status.restore_failed": "NuGet復元に失敗しました: {error}",
|
|
42
|
+
"status.restore_error": "NuGet復元エラー: {error}"
|
|
43
|
+
},
|
|
44
|
+
"ko": {
|
|
45
|
+
"status.restoring_packages": "{project}의 NuGet 패키지 복원 중...",
|
|
46
|
+
"status.restore_completed": "{project}의 NuGet 복원이 완료되었습니다",
|
|
47
|
+
"status.restore_failed": "NuGet 복원 실패: {error}",
|
|
48
|
+
"status.restore_error": "NuGet 복원 오류: {error}"
|
|
49
|
+
},
|
|
50
|
+
"pt-BR": {
|
|
51
|
+
"status.restoring_packages": "Restaurando pacotes NuGet para {project}...",
|
|
52
|
+
"status.restore_completed": "Restauracao do NuGet concluida para {project}",
|
|
53
|
+
"status.restore_failed": "Restauracao do NuGet falhou: {error}",
|
|
54
|
+
"status.restore_error": "Erro na restauracao do NuGet: {error}"
|
|
55
|
+
},
|
|
56
|
+
"ru": {
|
|
57
|
+
"status.restoring_packages": "Восстановление пакетов NuGet для {project}...",
|
|
58
|
+
"status.restore_completed": "Восстановление NuGet завершено для {project}",
|
|
59
|
+
"status.restore_failed": "Ошибка восстановления NuGet: {error}",
|
|
60
|
+
"status.restore_error": "Ошибка восстановления NuGet: {error}"
|
|
61
|
+
},
|
|
62
|
+
"th": {
|
|
63
|
+
"status.restoring_packages": "กำลังกู้คืนแพ็คเกจ NuGet สำหรับ {project}...",
|
|
64
|
+
"status.restore_completed": "การกู้คืน NuGet สำหรับ {project} เสร็จสมบูรณ์",
|
|
65
|
+
"status.restore_failed": "การกู้คืน NuGet ล้มเหลว: {error}",
|
|
66
|
+
"status.restore_error": "ข้อผิดพลาดการกู้คืน NuGet: {error}"
|
|
67
|
+
},
|
|
68
|
+
"uk": {
|
|
69
|
+
"status.restoring_packages": "Відновлення пакетів NuGet для {project}...",
|
|
70
|
+
"status.restore_completed": "Відновлення NuGet завершено для {project}",
|
|
71
|
+
"status.restore_failed": "Помилка відновлення NuGet: {error}",
|
|
72
|
+
"status.restore_error": "Помилка відновлення NuGet: {error}"
|
|
73
|
+
},
|
|
74
|
+
"zh-CN": {
|
|
75
|
+
"status.restoring_packages": "正在为{project}恢复NuGet包...",
|
|
76
|
+
"status.restore_completed": "{project}的NuGet恢复已完成",
|
|
77
|
+
"status.restore_failed": "NuGet恢复失败: {error}",
|
|
78
|
+
"status.restore_error": "NuGet恢复错误: {error}"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
const editor = getEditor();
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* C# Language Server Support Plugin
|
|
7
|
+
*
|
|
8
|
+
* Handles LSP server requests from C# language servers like:
|
|
9
|
+
* - csharp-ls
|
|
10
|
+
* - csharp-language-server (Roslyn-based)
|
|
11
|
+
* - OmniSharp
|
|
12
|
+
*
|
|
13
|
+
* Features:
|
|
14
|
+
* - Auto-restore NuGet packages when opening C# files
|
|
15
|
+
* - Auto-restore NuGet packages when the server requests it
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
interface LspServerRequestData {
|
|
19
|
+
language: string;
|
|
20
|
+
method: string;
|
|
21
|
+
server_command: string;
|
|
22
|
+
params: string | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface ProjectNeedsRestoreParams {
|
|
26
|
+
projectFilePath: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface AfterFileOpenData {
|
|
30
|
+
path: string;
|
|
31
|
+
buffer_id: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Track which directories we've already restored to avoid repeated restores
|
|
35
|
+
const restoredDirectories = new Set<string>();
|
|
36
|
+
|
|
37
|
+
// Cache whether dotnet is available (null = not checked yet)
|
|
38
|
+
let dotnetAvailable: boolean | null = null;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Check if dotnet CLI is available
|
|
42
|
+
*/
|
|
43
|
+
async function isDotnetAvailable(): Promise<boolean> {
|
|
44
|
+
if (dotnetAvailable !== null) {
|
|
45
|
+
return dotnetAvailable;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const result = await editor.spawnProcess("dotnet", ["--version"]);
|
|
50
|
+
dotnetAvailable = result.exit_code === 0;
|
|
51
|
+
} catch {
|
|
52
|
+
dotnetAvailable = false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!dotnetAvailable) {
|
|
56
|
+
editor.debug("csharp_support: dotnet CLI not found, C# support will be limited");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return dotnetAvailable;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Run dotnet restore for a project
|
|
64
|
+
*/
|
|
65
|
+
async function restoreProject(projectPath: string): Promise<void> {
|
|
66
|
+
if (!await isDotnetAvailable()) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
editor.setStatus(editor.t("status.restoring_packages", { project: projectPath }));
|
|
71
|
+
editor.debug(`csharp_support: Running dotnet restore for ${projectPath}`);
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const result = await editor.spawnProcess("dotnet", ["restore", projectPath]);
|
|
75
|
+
|
|
76
|
+
if (result.exit_code === 0) {
|
|
77
|
+
editor.setStatus(editor.t("status.restore_completed", { project: projectPath }));
|
|
78
|
+
editor.debug(`csharp_support: dotnet restore succeeded`);
|
|
79
|
+
} else {
|
|
80
|
+
editor.setStatus(editor.t("status.restore_failed", { error: result.stderr }));
|
|
81
|
+
editor.debug(`csharp_support: dotnet restore failed: ${result.stderr}`);
|
|
82
|
+
}
|
|
83
|
+
} catch (e) {
|
|
84
|
+
const err = e instanceof Error ? e : new Error(String(e));
|
|
85
|
+
editor.setStatus(editor.t("status.restore_error", { error: err.message }));
|
|
86
|
+
editor.debug(`csharp_support: dotnet restore error: ${err.message}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Handle LSP server requests from C# language servers (Roslyn-based)
|
|
92
|
+
*/
|
|
93
|
+
globalThis.on_csharp_lsp_server_request = function (
|
|
94
|
+
data: LspServerRequestData
|
|
95
|
+
): void {
|
|
96
|
+
// Only handle requests from C# language servers
|
|
97
|
+
if (data.server_command !== "csharp-ls" && data.server_command !== "csharp-language-server") {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
editor.debug(
|
|
102
|
+
`csharp_support: Received LSP request ${data.method} from ${data.server_command}`
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
switch (data.method) {
|
|
106
|
+
case "workspace/_roslyn_projectNeedsRestore": {
|
|
107
|
+
// Roslyn LSP server is asking us to restore a project
|
|
108
|
+
if (data.params) {
|
|
109
|
+
try {
|
|
110
|
+
const params: ProjectNeedsRestoreParams = JSON.parse(data.params);
|
|
111
|
+
if (params.projectFilePath) {
|
|
112
|
+
restoreProject(params.projectFilePath);
|
|
113
|
+
}
|
|
114
|
+
} catch (e) {
|
|
115
|
+
editor.debug(`csharp_support: Failed to parse params: ${e}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
default:
|
|
122
|
+
// Log unhandled requests for debugging
|
|
123
|
+
editor.debug(
|
|
124
|
+
`csharp_support: Unhandled LSP request: ${data.method}`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// Register hook for LSP server requests
|
|
130
|
+
editor.on("lsp_server_request", "on_csharp_lsp_server_request");
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Get the directory containing the file
|
|
134
|
+
*/
|
|
135
|
+
function getDirectory(filePath: string): string {
|
|
136
|
+
const lastSlash = filePath.lastIndexOf("/");
|
|
137
|
+
if (lastSlash === -1) {
|
|
138
|
+
return ".";
|
|
139
|
+
}
|
|
140
|
+
return filePath.substring(0, lastSlash);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Proactively run dotnet restore when opening a C# file
|
|
145
|
+
* This ensures the LSP server has access to restored packages from the start
|
|
146
|
+
*/
|
|
147
|
+
globalThis.on_csharp_file_open = async function (
|
|
148
|
+
data: AfterFileOpenData
|
|
149
|
+
): Promise<void> {
|
|
150
|
+
// Only handle .cs files
|
|
151
|
+
if (!data.path.endsWith(".cs")) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const dir = getDirectory(data.path);
|
|
156
|
+
|
|
157
|
+
// Skip if we've already restored this directory
|
|
158
|
+
if (restoredDirectories.has(dir)) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Mark as restored (even before we try, to avoid repeated attempts)
|
|
163
|
+
restoredDirectories.add(dir);
|
|
164
|
+
|
|
165
|
+
editor.debug(`csharp_support: C# file opened, running dotnet restore in ${dir}`);
|
|
166
|
+
await restoreProject(dir);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// Register hook for file open
|
|
170
|
+
editor.on("after_file_open", "on_csharp_file_open");
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
const editor = getEditor();
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* CSS LSP Helper Plugin
|
|
7
|
+
*
|
|
8
|
+
* Provides user-friendly error handling for CSS LSP server issues.
|
|
9
|
+
* When the CSS language server fails to start, this plugin shows an
|
|
10
|
+
* actionable popup with installation instructions.
|
|
11
|
+
*
|
|
12
|
+
* Features:
|
|
13
|
+
* - Detects CSS LSP server errors
|
|
14
|
+
* - Shows popup with install commands (npm)
|
|
15
|
+
* - Allows copying install commands to clipboard
|
|
16
|
+
* - Provides option to disable CSS 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 CSS 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 CSS LSP
|
|
44
|
+
let cssLspError: { serverCommand: string; message: string } | null = null;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Handle LSP server errors for CSS
|
|
48
|
+
*/
|
|
49
|
+
globalThis.on_css_lsp_server_error = function (data: LspServerErrorData): void {
|
|
50
|
+
// Only handle CSS language errors
|
|
51
|
+
if (data.language !== "css") {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
editor.debug(`css-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
56
|
+
|
|
57
|
+
// Store error state for later reference
|
|
58
|
+
cssLspError = {
|
|
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
|
+
`CSS LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
67
|
+
);
|
|
68
|
+
} else {
|
|
69
|
+
editor.setStatus(`CSS LSP error: ${data.message}`);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// Register hook for LSP server errors
|
|
74
|
+
editor.on("lsp_server_error", "on_css_lsp_server_error");
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Handle status bar click when there's a CSS LSP error
|
|
78
|
+
*/
|
|
79
|
+
globalThis.on_css_lsp_status_clicked = function (
|
|
80
|
+
data: LspStatusClickedData
|
|
81
|
+
): void {
|
|
82
|
+
// Only handle CSS language clicks when there's an error
|
|
83
|
+
if (data.language !== "css" || !cssLspError) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
editor.debug("css-lsp: Status clicked, showing help popup");
|
|
88
|
+
|
|
89
|
+
// Show action popup with install options
|
|
90
|
+
editor.showActionPopup({
|
|
91
|
+
id: "css-lsp-help",
|
|
92
|
+
title: "CSS Language Server Not Found",
|
|
93
|
+
message: `"${cssLspError.serverCommand}" provides code completion, diagnostics, and formatting for CSS files. Copy the command below to install it.`,
|
|
94
|
+
actions: [
|
|
95
|
+
{ id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
|
|
96
|
+
{ id: "disable", label: "Disable CSS 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_css_lsp_status_clicked");
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Handle action popup results for CSS LSP help
|
|
107
|
+
*/
|
|
108
|
+
globalThis.on_css_lsp_action_result = function (
|
|
109
|
+
data: ActionPopupResultData
|
|
110
|
+
): void {
|
|
111
|
+
// Only handle our popup
|
|
112
|
+
if (data.popup_id !== "css-lsp-help") {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
editor.debug(`css-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("css");
|
|
126
|
+
editor.setStatus("CSS LSP disabled");
|
|
127
|
+
cssLspError = 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(`css-lsp: Unknown action: ${data.action_id}`);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// Register hook for action popup results
|
|
141
|
+
editor.on("action_popup_result", "on_css_lsp_action_result");
|
|
142
|
+
|
|
143
|
+
editor.debug("css-lsp: Plugin loaded");
|