@fresh-editor/fresh-editor 0.2.16 → 0.2.18

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 (41) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/package.json +1 -1
  3. package/plugins/astro-lsp.ts +118 -0
  4. package/plugins/bash-lsp.ts +161 -0
  5. package/plugins/clojure-lsp.ts +125 -0
  6. package/plugins/cmake-lsp.ts +138 -0
  7. package/plugins/config-schema.json +33 -4
  8. package/plugins/dart-lsp.ts +144 -0
  9. package/plugins/elixir-lsp.ts +120 -0
  10. package/plugins/erlang-lsp.ts +121 -0
  11. package/plugins/fsharp-lsp.ts +125 -0
  12. package/plugins/gleam-lsp.ts +124 -0
  13. package/plugins/graphql-lsp.ts +139 -0
  14. package/plugins/haskell-lsp.ts +125 -0
  15. package/plugins/julia-lsp.ts +111 -0
  16. package/plugins/kotlin-lsp.ts +162 -0
  17. package/plugins/lib/fresh.d.ts +25 -0
  18. package/plugins/lua-lsp.ts +161 -0
  19. package/plugins/nim-lsp.ts +118 -0
  20. package/plugins/nix-lsp.ts +125 -0
  21. package/plugins/nushell-lsp.ts +144 -0
  22. package/plugins/ocaml-lsp.ts +119 -0
  23. package/plugins/perl-lsp.ts +118 -0
  24. package/plugins/php-lsp.ts +165 -0
  25. package/plugins/pkg.ts +33 -47
  26. package/plugins/protobuf-lsp.ts +144 -0
  27. package/plugins/r-lsp.ts +118 -0
  28. package/plugins/ruby-lsp.ts +165 -0
  29. package/plugins/scala-lsp.ts +119 -0
  30. package/plugins/solidity-lsp.ts +130 -0
  31. package/plugins/sql-lsp.ts +129 -0
  32. package/plugins/svelte-lsp.ts +119 -0
  33. package/plugins/swift-lsp.ts +120 -0
  34. package/plugins/tailwindcss-lsp.ts +119 -0
  35. package/plugins/terraform-lsp.ts +144 -0
  36. package/plugins/theme_editor.i18n.json +70 -14
  37. package/plugins/theme_editor.ts +71 -39
  38. package/plugins/toml-lsp.ts +162 -0
  39. package/plugins/typst-lsp.ts +165 -0
  40. package/plugins/vue-lsp.ts +118 -0
  41. package/plugins/yaml-lsp.ts +163 -0
@@ -0,0 +1,163 @@
1
+ /// <reference path="./lib/fresh.d.ts" />
2
+ const editor = getEditor();
3
+
4
+ /**
5
+ * YAML LSP Helper Plugin
6
+ *
7
+ * Provides user-friendly error handling for YAML LSP server issues.
8
+ * When yaml-language-server fails to start, this plugin shows an actionable
9
+ * popup with installation instructions.
10
+ *
11
+ * Features:
12
+ * - Detects YAML LSP server errors (yaml-language-server)
13
+ * - Shows popup with install commands (npm, yarn, pnpm)
14
+ * - Allows copying install commands to clipboard
15
+ * - Provides option to disable YAML LSP
16
+ *
17
+ * Notes:
18
+ * - yaml-language-server supports JSON Schema validation via modeline comments
19
+ * e.g. # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
20
+ * - Built-in Kubernetes schema support
21
+ */
22
+
23
+ interface LspServerErrorData {
24
+ language: string;
25
+ server_command: string;
26
+ error_type: string;
27
+ message: string;
28
+ }
29
+
30
+ interface LspStatusClickedData {
31
+ language: string;
32
+ has_error: boolean;
33
+ }
34
+
35
+ interface ActionPopupResultData {
36
+ popup_id: string;
37
+ action_id: string;
38
+ }
39
+
40
+ // Install commands for YAML LSP server (yaml-language-server)
41
+ // See: https://github.com/redhat-developer/yaml-language-server
42
+ const INSTALL_COMMANDS = {
43
+ npm: "npm i -g yaml-language-server",
44
+ yarn: "yarn global add yaml-language-server",
45
+ pnpm: "pnpm add -g yaml-language-server",
46
+ };
47
+
48
+ // Track error state for YAML LSP
49
+ let yamlLspError: { serverCommand: string; message: string } | null = null;
50
+
51
+ /**
52
+ * Handle LSP server errors for YAML
53
+ */
54
+ function on_yaml_lsp_server_error(data: LspServerErrorData): void {
55
+ // Only handle YAML language errors
56
+ if (data.language !== "yaml") {
57
+ return;
58
+ }
59
+
60
+ editor.debug(`yaml-lsp: Server error - ${data.error_type}: ${data.message}`);
61
+
62
+ // Store error state for later reference
63
+ yamlLspError = {
64
+ serverCommand: data.server_command,
65
+ message: data.message,
66
+ };
67
+
68
+ // Show a status message for immediate feedback
69
+ if (data.error_type === "not_found") {
70
+ editor.setStatus(
71
+ `YAML LSP server '${data.server_command}' not found. Click status bar for help.`
72
+ );
73
+ } else {
74
+ editor.setStatus(`YAML LSP error: ${data.message}`);
75
+ }
76
+ }
77
+ registerHandler("on_yaml_lsp_server_error", on_yaml_lsp_server_error);
78
+
79
+ // Register hook for LSP server errors
80
+ editor.on("lsp_server_error", "on_yaml_lsp_server_error");
81
+
82
+ /**
83
+ * Handle status bar click when there's a YAML LSP error
84
+ */
85
+ function on_yaml_lsp_status_clicked(
86
+ data: LspStatusClickedData
87
+ ): void {
88
+ // Only handle YAML language clicks when there's an error
89
+ if (data.language !== "yaml" || !yamlLspError) {
90
+ return;
91
+ }
92
+
93
+ editor.debug("yaml-lsp: Status clicked, showing help popup");
94
+
95
+ // Show action popup with install options
96
+ editor.showActionPopup({
97
+ id: "yaml-lsp-help",
98
+ title: "YAML Language Server Not Found",
99
+ message: `"${yamlLspError.serverCommand}" provides code completion, validation, and schema support for YAML files. Requires Node.js. Supports JSON Schema validation and built-in Kubernetes schemas. Copy a command below to install it, or visit https://github.com/redhat-developer/yaml-language-server for details.`,
100
+ actions: [
101
+ { id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
102
+ { id: "copy_yarn", label: `Copy: ${INSTALL_COMMANDS.yarn}` },
103
+ { id: "copy_pnpm", label: `Copy: ${INSTALL_COMMANDS.pnpm}` },
104
+ { id: "disable", label: "Disable YAML LSP" },
105
+ { id: "dismiss", label: "Dismiss (ESC)" },
106
+ ],
107
+ });
108
+ }
109
+ registerHandler("on_yaml_lsp_status_clicked", on_yaml_lsp_status_clicked);
110
+
111
+ // Register hook for status bar clicks
112
+ editor.on("lsp_status_clicked", "on_yaml_lsp_status_clicked");
113
+
114
+ /**
115
+ * Handle action popup results for YAML LSP help
116
+ */
117
+ function on_yaml_lsp_action_result(
118
+ data: ActionPopupResultData
119
+ ): void {
120
+ // Only handle our popup
121
+ if (data.popup_id !== "yaml-lsp-help") {
122
+ return;
123
+ }
124
+
125
+ editor.debug(`yaml-lsp: Action selected - ${data.action_id}`);
126
+
127
+ switch (data.action_id) {
128
+ case "copy_npm":
129
+ editor.setClipboard(INSTALL_COMMANDS.npm);
130
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.npm);
131
+ break;
132
+
133
+ case "copy_yarn":
134
+ editor.setClipboard(INSTALL_COMMANDS.yarn);
135
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.yarn);
136
+ break;
137
+
138
+ case "copy_pnpm":
139
+ editor.setClipboard(INSTALL_COMMANDS.pnpm);
140
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.pnpm);
141
+ break;
142
+
143
+ case "disable":
144
+ editor.disableLspForLanguage("yaml");
145
+ editor.setStatus("YAML LSP disabled");
146
+ yamlLspError = null;
147
+ break;
148
+
149
+ case "dismiss":
150
+ case "dismissed":
151
+ // Just close the popup without action
152
+ break;
153
+
154
+ default:
155
+ editor.debug(`yaml-lsp: Unknown action: ${data.action_id}`);
156
+ }
157
+ }
158
+ registerHandler("on_yaml_lsp_action_result", on_yaml_lsp_action_result);
159
+
160
+ // Register hook for action popup results
161
+ editor.on("action_popup_result", "on_yaml_lsp_action_result");
162
+
163
+ editor.debug("yaml-lsp: Plugin loaded");