@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.
Files changed (64) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/README.md +4 -2
  3. package/package.json +1 -1
  4. package/plugins/audit_mode.i18n.json +380 -0
  5. package/plugins/audit_mode.ts +1813 -0
  6. package/plugins/buffer_modified.i18n.json +32 -0
  7. package/plugins/buffer_modified.ts +5 -3
  8. package/plugins/calculator.i18n.json +44 -0
  9. package/plugins/calculator.ts +6 -4
  10. package/plugins/clangd-lsp.ts +168 -0
  11. package/plugins/clangd_support.i18n.json +104 -0
  12. package/plugins/clangd_support.ts +18 -16
  13. package/plugins/color_highlighter.i18n.json +68 -0
  14. package/plugins/color_highlighter.ts +12 -10
  15. package/plugins/config-schema.json +79 -141
  16. package/plugins/csharp-lsp.ts +147 -0
  17. package/plugins/csharp_support.i18n.json +38 -0
  18. package/plugins/csharp_support.ts +6 -4
  19. package/plugins/css-lsp.ts +143 -0
  20. package/plugins/diagnostics_panel.i18n.json +110 -0
  21. package/plugins/diagnostics_panel.ts +19 -17
  22. package/plugins/find_references.i18n.json +128 -0
  23. package/plugins/find_references.ts +22 -20
  24. package/plugins/git_blame.i18n.json +230 -0
  25. package/plugins/git_blame.ts +39 -37
  26. package/plugins/git_find_file.i18n.json +146 -0
  27. package/plugins/git_find_file.ts +24 -22
  28. package/plugins/git_grep.i18n.json +80 -0
  29. package/plugins/git_grep.ts +15 -13
  30. package/plugins/git_gutter.i18n.json +44 -0
  31. package/plugins/git_gutter.ts +7 -5
  32. package/plugins/git_log.i18n.json +224 -0
  33. package/plugins/git_log.ts +41 -39
  34. package/plugins/go-lsp.ts +143 -0
  35. package/plugins/html-lsp.ts +145 -0
  36. package/plugins/json-lsp.ts +145 -0
  37. package/plugins/lib/fresh.d.ts +150 -14
  38. package/plugins/lib/index.ts +1 -1
  39. package/plugins/lib/navigation-controller.ts +3 -3
  40. package/plugins/lib/panel-manager.ts +15 -13
  41. package/plugins/lib/virtual-buffer-factory.ts +84 -112
  42. package/plugins/live_grep.i18n.json +80 -0
  43. package/plugins/live_grep.ts +15 -13
  44. package/plugins/markdown_compose.i18n.json +104 -0
  45. package/plugins/markdown_compose.ts +17 -15
  46. package/plugins/merge_conflict.i18n.json +380 -0
  47. package/plugins/merge_conflict.ts +72 -73
  48. package/plugins/path_complete.i18n.json +38 -0
  49. package/plugins/path_complete.ts +6 -4
  50. package/plugins/python-lsp.ts +162 -0
  51. package/plugins/rust-lsp.ts +166 -0
  52. package/plugins/search_replace.i18n.json +188 -0
  53. package/plugins/search_replace.ts +31 -29
  54. package/plugins/test_i18n.i18n.json +12 -0
  55. package/plugins/test_i18n.ts +18 -0
  56. package/plugins/theme_editor.i18n.json +1417 -0
  57. package/plugins/theme_editor.ts +73 -69
  58. package/plugins/todo_highlighter.i18n.json +86 -0
  59. package/plugins/todo_highlighter.ts +15 -13
  60. package/plugins/typescript-lsp.ts +167 -0
  61. package/plugins/vi_mode.i18n.json +716 -0
  62. package/plugins/vi_mode.ts +2747 -0
  63. package/plugins/welcome.i18n.json +110 -0
  64. package/plugins/welcome.ts +18 -16
@@ -0,0 +1,167 @@
1
+ /// <reference path="./lib/fresh.d.ts" />
2
+ const editor = getEditor();
3
+
4
+
5
+ /**
6
+ * TypeScript/JavaScript LSP Helper Plugin
7
+ *
8
+ * Provides user-friendly error handling for TypeScript/JavaScript LSP server issues.
9
+ * When typescript-language-server fails to start, this plugin shows an actionable
10
+ * popup with installation instructions.
11
+ *
12
+ * Features:
13
+ * - Detects TypeScript LSP server errors (typescript-language-server, tsserver)
14
+ * - Shows popup with install commands (npm, yarn, pnpm)
15
+ * - Allows copying install commands to clipboard
16
+ * - Provides option to disable TypeScript 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 TypeScript LSP server
37
+ // Both typescript-language-server AND typescript packages are required
38
+ // See: https://github.com/typescript-language-server/typescript-language-server
39
+ const INSTALL_COMMANDS = {
40
+ npm: "npm install -g typescript-language-server typescript",
41
+ yarn: "yarn global add typescript-language-server typescript",
42
+ pnpm: "pnpm add -g typescript-language-server typescript",
43
+ };
44
+
45
+ // Languages handled by this plugin
46
+ const HANDLED_LANGUAGES = ["typescript", "javascript", "typescriptreact", "javascriptreact"];
47
+
48
+ // Track error state for TypeScript LSP
49
+ let tsLspError: { serverCommand: string; message: string; language: string } | null = null;
50
+
51
+ /**
52
+ * Handle LSP server errors for TypeScript/JavaScript
53
+ */
54
+ globalThis.on_typescript_lsp_server_error = function (
55
+ data: LspServerErrorData
56
+ ): void {
57
+ // Only handle TypeScript/JavaScript language errors
58
+ if (!HANDLED_LANGUAGES.includes(data.language)) {
59
+ return;
60
+ }
61
+
62
+ editor.debug(
63
+ `typescript-lsp: Server error - ${data.error_type}: ${data.message}`
64
+ );
65
+
66
+ // Store error state for later reference
67
+ tsLspError = {
68
+ serverCommand: data.server_command,
69
+ message: data.message,
70
+ language: data.language,
71
+ };
72
+
73
+ // Show a status message for immediate feedback
74
+ if (data.error_type === "not_found") {
75
+ editor.setStatus(
76
+ `TypeScript LSP server '${data.server_command}' not found. Click status bar for help.`
77
+ );
78
+ } else {
79
+ editor.setStatus(`TypeScript LSP error: ${data.message}`);
80
+ }
81
+ };
82
+
83
+ // Register hook for LSP server errors
84
+ editor.on("lsp_server_error", "on_typescript_lsp_server_error");
85
+
86
+ /**
87
+ * Handle status bar click when there's a TypeScript LSP error
88
+ */
89
+ globalThis.on_typescript_lsp_status_clicked = function (
90
+ data: LspStatusClickedData
91
+ ): void {
92
+ // Only handle TypeScript/JavaScript language clicks when there's an error
93
+ if (!HANDLED_LANGUAGES.includes(data.language) || !tsLspError) {
94
+ return;
95
+ }
96
+
97
+ editor.debug("typescript-lsp: Status clicked, showing help popup");
98
+
99
+ // Show action popup with install options
100
+ editor.showActionPopup({
101
+ id: "typescript-lsp-help",
102
+ title: "TypeScript Language Server Not Found",
103
+ 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.`,
104
+ actions: [
105
+ { id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
106
+ { id: "copy_yarn", label: `Copy: ${INSTALL_COMMANDS.yarn}` },
107
+ { id: "copy_pnpm", label: `Copy: ${INSTALL_COMMANDS.pnpm}` },
108
+ { id: "disable", label: "Disable TypeScript LSP" },
109
+ { id: "dismiss", label: "Dismiss (ESC)" },
110
+ ],
111
+ });
112
+ };
113
+
114
+ // Register hook for status bar clicks
115
+ editor.on("lsp_status_clicked", "on_typescript_lsp_status_clicked");
116
+
117
+ /**
118
+ * Handle action popup results for TypeScript LSP help
119
+ */
120
+ globalThis.on_typescript_lsp_action_result = function (
121
+ data: ActionPopupResultData
122
+ ): void {
123
+ // Only handle our popup
124
+ if (data.popup_id !== "typescript-lsp-help") {
125
+ return;
126
+ }
127
+
128
+ editor.debug(`typescript-lsp: Action selected - ${data.action_id}`);
129
+
130
+ switch (data.action_id) {
131
+ case "copy_npm":
132
+ editor.setClipboard(INSTALL_COMMANDS.npm);
133
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.npm);
134
+ break;
135
+
136
+ case "copy_yarn":
137
+ editor.setClipboard(INSTALL_COMMANDS.yarn);
138
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.yarn);
139
+ break;
140
+
141
+ case "copy_pnpm":
142
+ editor.setClipboard(INSTALL_COMMANDS.pnpm);
143
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.pnpm);
144
+ break;
145
+
146
+ case "disable":
147
+ // Disable for all TypeScript/JavaScript variants
148
+ editor.disableLspForLanguage("typescript");
149
+ editor.disableLspForLanguage("javascript");
150
+ editor.setStatus("TypeScript/JavaScript LSP disabled");
151
+ tsLspError = null;
152
+ break;
153
+
154
+ case "dismiss":
155
+ case "dismissed":
156
+ // Just close the popup without action
157
+ break;
158
+
159
+ default:
160
+ editor.debug(`typescript-lsp: Unknown action: ${data.action_id}`);
161
+ }
162
+ };
163
+
164
+ // Register hook for action popup results
165
+ editor.on("action_popup_result", "on_typescript_lsp_action_result");
166
+
167
+ editor.debug("typescript-lsp: Plugin loaded");