@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,96 @@
1
1
  # Release Notes
2
2
 
3
+ ## 0.2.18
4
+
5
+ ### Features
6
+
7
+ * **Bracketed Paste on Windows & Input Overhaul**: Bracketed paste now works on Windows Terminal (reverted in v0.2.17 due to #1284), and keyboard issues are resolved (#1054). **Mouse hover is disabled by default on Windows** because reliable bracketed paste requires cell-motion tracking; enabling hover switches to all-motion tracking which can insert corrupt text under heavy mouse movement or slow CPU. Re-enable it in Settings UI under Editor → Mouse Hover Enabled. Under the hood, crossterm's Windows input handling is replaced with a new `fresh-winterm` crate using direct VT input reads, with corrupt mouse sequence detection, UTF-16 surrogate handling, and console mode heartbeat to counteract ConPTY drift.
8
+
9
+ * **30 New Syntax Grammars**: Dockerfile, CMake, INI, SCSS, LESS, PowerShell, Kotlin, Swift, Dart, Elixir, F#, Nix, Terraform/HCL, Protobuf, GraphQL, Julia, Nim, Gleam, V, Solidity, KDL, Nushell, Starlark, Justfile, Earthfile, Go Module, Vue, Svelte, Astro, Hyprlang (#1266). These grammars are preliminary — please report highlighting issues for your language so we can improve them.
10
+
11
+ * **Broad LSP Support**: Added LSP configs and helper plugins (with install instructions) for Nix, Kotlin, Swift, Scala, Elixir, Erlang, Haskell, OCaml, Clojure, R, Julia, Perl, Nim, Gleam, F#, Dart (#1252), Nushell (#1031), Solidity (#857), Vue, Svelte, Astro, Tailwind CSS, Terraform/HCL, CMake, Protobuf, GraphQL, SQL, Bash, Lua, Ruby, PHP, YAML, TOML, and Typst. LSP integration for these languages is early-stage — feedback from users of these languages is welcome.
12
+
13
+ * **Deno LSP Auto-Detection**: Automatically detects and uses the Deno language server for JS/TS projects (#1191).
14
+
15
+ * **`show_prompt_line` Setting**: New config option to auto-hide the prompt line. Applied immediately from Settings UI (#1273).
16
+
17
+ * **`use_tabs` Setting**: Global `editor.use_tabs` config option for default tab indentation (#1295).
18
+
19
+ ### Improvements
20
+
21
+ * **Plugin Commands in Keybinding Editor**: Plugin-registered commands are now shown and searchable in the keybinding editor.
22
+
23
+ * **Theme Editor ANSI Colors**: Named ANSI colors display as "terminal native" instead of misleading RGB values, with correct native color swatches (#1301).
24
+
25
+ * **Status Bar Language Info**: Shows "[syntax only]" when a language has no LSP config entry.
26
+
27
+ * **Fallback Language Config**: Undetected file types now get a fallback language configuration (#1219).
28
+
29
+ * **File Deletion Uses Trash**: `removePath` now uses the system trash instead of permanent deletion.
30
+
31
+ * **Package Manager Cross-Platform**: Plugin package manager uses cross-platform APIs instead of Unix-specific commands on Windows (#1215).
32
+
33
+ ### Bug Fixes
34
+
35
+ * Fixed arrow keys not working in `less`/`git log` in the embedded terminal, including `TERM` env var not being set on Unix.
36
+
37
+ * Fixed Tab key getting trapped in TextList editing mode in Settings UI.
38
+
39
+ * Fixed `{`, `}`, `;` highlighted as operators instead of punctuation in C/C++ (#1318, #1319).
40
+
41
+ * Fixed auto-dedent for languages without tree-sitter, e.g. Dart.
42
+
43
+ * Fixed auto-indent after closing brace in nested C++ blocks.
44
+
45
+ * Fixed mouse click selecting wrong item in scrolled settings list.
46
+
47
+ * Fixed keybindings for plugin-registered commands not executing (#1312).
48
+
49
+ * Fixed Find Next/Find Previous ignoring cursor position (#1305).
50
+
51
+ * Fixed Tab indent affecting lines outside selection (#1304).
52
+
53
+ * Fixed Shift+letter keybinding deletion not persisting (#1303).
54
+
55
+ * Fixed word selection not preserved when dragging after double-click (#1202, #1317).
56
+
57
+ * Fixed `removePath` failing on Windows due to UNC path mismatch.
58
+
59
+ * Fixed external files missing from tab bar after session restore.
60
+
61
+ * Fixed scroll wheel targeting focused split instead of split under pointer (#1270).
62
+
63
+ * Fixed wrap indent not working with tab indentation (#1283).
64
+
65
+ * Fixed LSP "no server configured" for Kotlin and 30+ other languages.
66
+
67
+ * Fixed Diff syntax highlighting scope-to-category mappings.
68
+
69
+ * Fixed extension mappings for `.cjs`, `.mjs`, `.mts`, `.cts`, `Jenkinsfile`, `Brewfile`.
70
+
71
+ * Fixed LSP initialization timeout too short (increased from 10s to 60s).
72
+
73
+ ### Internal
74
+
75
+ * Added syntax highlighting validation suite with 93 fixture files and e2e tests.
76
+
77
+ * Added e2e tests for Settings UI, keybinding editor, search/replace, and plugin commands.
78
+
79
+ * Fixed multiple flaky e2e tests (search/replace, plugin uninstall, Settings UI).
80
+
81
+ * Removed redundant `SIGUSR1` handler; relies on harness signal handler for backtraces.
82
+
83
+ * Cleaned up completed design docs.
84
+
85
+ ---
86
+
87
+ ## 0.2.17
88
+
89
+ ### Bug Fixes
90
+
91
+ * **Reverted Windows Bracketed Paste Fix**: Reverted the bracketed paste fix for Windows Terminal (#1218) as it broke mouse input (#1284). The fix enabled `ENABLE_VIRTUAL_TERMINAL_INPUT` which interfered with mouse event handling.
92
+
93
+ ---
3
94
  ## 0.2.16
4
95
 
5
96
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fresh-editor/fresh-editor",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
4
4
  "description": "A modern terminal-based text editor with plugin support",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,118 @@
1
+ /// <reference path="./lib/fresh.d.ts" />
2
+ const editor = getEditor();
3
+
4
+ /**
5
+ * Astro LSP Helper Plugin
6
+ *
7
+ * Server: @astrojs/language-server (binary: astro-ls)
8
+ * VS Code: "Astro" official extension
9
+ * Neovim: nvim-lspconfig astro
10
+ * Note: Powered by Volar; may need typescript.tsdk init option
11
+ */
12
+
13
+ interface LspServerErrorData {
14
+ language: string;
15
+ server_command: string;
16
+ error_type: string;
17
+ message: string;
18
+ }
19
+
20
+ interface LspStatusClickedData {
21
+ language: string;
22
+ has_error: boolean;
23
+ }
24
+
25
+ interface ActionPopupResultData {
26
+ popup_id: string;
27
+ action_id: string;
28
+ }
29
+
30
+ const INSTALL_COMMANDS = {
31
+ npm: "npm install -g @astrojs/language-server",
32
+ yarn: "yarn global add @astrojs/language-server",
33
+ pnpm: "pnpm add -g @astrojs/language-server",
34
+ };
35
+
36
+ let astroLspError: { serverCommand: string; message: string } | null = null;
37
+
38
+ function on_astro_lsp_server_error(data: LspServerErrorData): void {
39
+ if (data.language !== "astro") {
40
+ return;
41
+ }
42
+
43
+ editor.debug(`astro-lsp: Server error - ${data.error_type}: ${data.message}`);
44
+
45
+ astroLspError = {
46
+ serverCommand: data.server_command,
47
+ message: data.message,
48
+ };
49
+
50
+ if (data.error_type === "not_found") {
51
+ editor.setStatus(
52
+ `Astro LSP server '${data.server_command}' not found. Click status bar for help.`
53
+ );
54
+ } else {
55
+ editor.setStatus(`Astro LSP error: ${data.message}`);
56
+ }
57
+ }
58
+ registerHandler("on_astro_lsp_server_error", on_astro_lsp_server_error);
59
+ editor.on("lsp_server_error", "on_astro_lsp_server_error");
60
+
61
+ function on_astro_lsp_status_clicked(data: LspStatusClickedData): void {
62
+ if (data.language !== "astro" || !astroLspError) {
63
+ return;
64
+ }
65
+
66
+ editor.debug("astro-lsp: Status clicked, showing help popup");
67
+
68
+ editor.showActionPopup({
69
+ id: "astro-lsp-help",
70
+ title: "Astro Language Server Not Found",
71
+ message: `"${astroLspError.serverCommand}" provides completion, diagnostics, and formatting for Astro components. Powered by the Volar framework.\n\nRequires TypeScript to be installed in your project for full functionality.\nVS Code users: Install the official "Astro" extension.\nSee: https://github.com/withastro/language-tools`,
72
+ actions: [
73
+ { id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
74
+ { id: "copy_pnpm", label: `Copy: ${INSTALL_COMMANDS.pnpm}` },
75
+ { id: "disable", label: "Disable Astro LSP" },
76
+ { id: "dismiss", label: "Dismiss (ESC)" },
77
+ ],
78
+ });
79
+ }
80
+ registerHandler("on_astro_lsp_status_clicked", on_astro_lsp_status_clicked);
81
+ editor.on("lsp_status_clicked", "on_astro_lsp_status_clicked");
82
+
83
+ function on_astro_lsp_action_result(data: ActionPopupResultData): void {
84
+ if (data.popup_id !== "astro-lsp-help") {
85
+ return;
86
+ }
87
+
88
+ editor.debug(`astro-lsp: Action selected - ${data.action_id}`);
89
+
90
+ switch (data.action_id) {
91
+ case "copy_npm":
92
+ editor.setClipboard(INSTALL_COMMANDS.npm);
93
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.npm);
94
+ break;
95
+
96
+ case "copy_pnpm":
97
+ editor.setClipboard(INSTALL_COMMANDS.pnpm);
98
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.pnpm);
99
+ break;
100
+
101
+ case "disable":
102
+ editor.disableLspForLanguage("astro");
103
+ editor.setStatus("Astro LSP disabled");
104
+ astroLspError = null;
105
+ break;
106
+
107
+ case "dismiss":
108
+ case "dismissed":
109
+ break;
110
+
111
+ default:
112
+ editor.debug(`astro-lsp: Unknown action: ${data.action_id}`);
113
+ }
114
+ }
115
+ registerHandler("on_astro_lsp_action_result", on_astro_lsp_action_result);
116
+ editor.on("action_popup_result", "on_astro_lsp_action_result");
117
+
118
+ editor.debug("astro-lsp: Plugin loaded");
@@ -0,0 +1,161 @@
1
+ /// <reference path="./lib/fresh.d.ts" />
2
+ const editor = getEditor();
3
+
4
+ /**
5
+ * Bash/Shell LSP Helper Plugin
6
+ *
7
+ * Provides user-friendly error handling for Bash LSP server issues.
8
+ * When bash-language-server fails to start, this plugin shows an actionable
9
+ * popup with installation instructions.
10
+ *
11
+ * Features:
12
+ * - Detects Bash LSP server errors (bash-language-server)
13
+ * - Shows popup with install commands (npm, yarn, pnpm)
14
+ * - Allows copying install commands to clipboard
15
+ * - Provides option to disable Bash LSP
16
+ *
17
+ * Alternatives:
18
+ * - ShellCheck: Linting/static analysis for shell scripts (https://www.shellcheck.net/)
19
+ */
20
+
21
+ interface LspServerErrorData {
22
+ language: string;
23
+ server_command: string;
24
+ error_type: string;
25
+ message: string;
26
+ }
27
+
28
+ interface LspStatusClickedData {
29
+ language: string;
30
+ has_error: boolean;
31
+ }
32
+
33
+ interface ActionPopupResultData {
34
+ popup_id: string;
35
+ action_id: string;
36
+ }
37
+
38
+ // Install commands for Bash LSP server (bash-language-server)
39
+ // See: https://github.com/bash-lsp/bash-language-server
40
+ const INSTALL_COMMANDS = {
41
+ npm: "npm i -g bash-language-server",
42
+ yarn: "yarn global add bash-language-server",
43
+ pnpm: "pnpm add -g bash-language-server",
44
+ };
45
+
46
+ // Track error state for Bash LSP
47
+ let bashLspError: { serverCommand: string; message: string } | null = null;
48
+
49
+ /**
50
+ * Handle LSP server errors for Bash
51
+ */
52
+ function on_bash_lsp_server_error(data: LspServerErrorData): void {
53
+ // Only handle Bash language errors
54
+ if (data.language !== "bash") {
55
+ return;
56
+ }
57
+
58
+ editor.debug(`bash-lsp: Server error - ${data.error_type}: ${data.message}`);
59
+
60
+ // Store error state for later reference
61
+ bashLspError = {
62
+ serverCommand: data.server_command,
63
+ message: data.message,
64
+ };
65
+
66
+ // Show a status message for immediate feedback
67
+ if (data.error_type === "not_found") {
68
+ editor.setStatus(
69
+ `Bash LSP server '${data.server_command}' not found. Click status bar for help.`
70
+ );
71
+ } else {
72
+ editor.setStatus(`Bash LSP error: ${data.message}`);
73
+ }
74
+ }
75
+ registerHandler("on_bash_lsp_server_error", on_bash_lsp_server_error);
76
+
77
+ // Register hook for LSP server errors
78
+ editor.on("lsp_server_error", "on_bash_lsp_server_error");
79
+
80
+ /**
81
+ * Handle status bar click when there's a Bash LSP error
82
+ */
83
+ function on_bash_lsp_status_clicked(
84
+ data: LspStatusClickedData
85
+ ): void {
86
+ // Only handle Bash language clicks when there's an error
87
+ if (data.language !== "bash" || !bashLspError) {
88
+ return;
89
+ }
90
+
91
+ editor.debug("bash-lsp: Status clicked, showing help popup");
92
+
93
+ // Show action popup with install options
94
+ editor.showActionPopup({
95
+ id: "bash-lsp-help",
96
+ title: "Bash Language Server Not Found",
97
+ message: `"${bashLspError.serverCommand}" provides code completion, diagnostics, and navigation for shell scripts. Requires Node.js. Copy a command below to install it, or visit https://github.com/bash-lsp/bash-language-server for details. For linting, also consider ShellCheck (https://www.shellcheck.net/).`,
98
+ actions: [
99
+ { id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
100
+ { id: "copy_yarn", label: `Copy: ${INSTALL_COMMANDS.yarn}` },
101
+ { id: "copy_pnpm", label: `Copy: ${INSTALL_COMMANDS.pnpm}` },
102
+ { id: "disable", label: "Disable Bash LSP" },
103
+ { id: "dismiss", label: "Dismiss (ESC)" },
104
+ ],
105
+ });
106
+ }
107
+ registerHandler("on_bash_lsp_status_clicked", on_bash_lsp_status_clicked);
108
+
109
+ // Register hook for status bar clicks
110
+ editor.on("lsp_status_clicked", "on_bash_lsp_status_clicked");
111
+
112
+ /**
113
+ * Handle action popup results for Bash LSP help
114
+ */
115
+ function on_bash_lsp_action_result(
116
+ data: ActionPopupResultData
117
+ ): void {
118
+ // Only handle our popup
119
+ if (data.popup_id !== "bash-lsp-help") {
120
+ return;
121
+ }
122
+
123
+ editor.debug(`bash-lsp: Action selected - ${data.action_id}`);
124
+
125
+ switch (data.action_id) {
126
+ case "copy_npm":
127
+ editor.setClipboard(INSTALL_COMMANDS.npm);
128
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.npm);
129
+ break;
130
+
131
+ case "copy_yarn":
132
+ editor.setClipboard(INSTALL_COMMANDS.yarn);
133
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.yarn);
134
+ break;
135
+
136
+ case "copy_pnpm":
137
+ editor.setClipboard(INSTALL_COMMANDS.pnpm);
138
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.pnpm);
139
+ break;
140
+
141
+ case "disable":
142
+ editor.disableLspForLanguage("bash");
143
+ editor.setStatus("Bash LSP disabled");
144
+ bashLspError = null;
145
+ break;
146
+
147
+ case "dismiss":
148
+ case "dismissed":
149
+ // Just close the popup without action
150
+ break;
151
+
152
+ default:
153
+ editor.debug(`bash-lsp: Unknown action: ${data.action_id}`);
154
+ }
155
+ }
156
+ registerHandler("on_bash_lsp_action_result", on_bash_lsp_action_result);
157
+
158
+ // Register hook for action popup results
159
+ editor.on("action_popup_result", "on_bash_lsp_action_result");
160
+
161
+ editor.debug("bash-lsp: Plugin loaded");
@@ -0,0 +1,125 @@
1
+ /// <reference path="./lib/fresh.d.ts" />
2
+ const editor = getEditor();
3
+
4
+ /**
5
+ * Clojure LSP Helper Plugin
6
+ *
7
+ * Server: clojure-lsp (github.com/clojure-lsp/clojure-lsp)
8
+ * VS Code: "Calva" extension (bundles clojure-lsp)
9
+ * Neovim: nvim-lspconfig clojure_lsp
10
+ * Note: Works with Clojure, ClojureScript, and ClojureDart
11
+ * No project setup needed - analyzes classpath automatically
12
+ */
13
+
14
+ interface LspServerErrorData {
15
+ language: string;
16
+ server_command: string;
17
+ error_type: string;
18
+ message: string;
19
+ }
20
+
21
+ interface LspStatusClickedData {
22
+ language: string;
23
+ has_error: boolean;
24
+ }
25
+
26
+ interface ActionPopupResultData {
27
+ popup_id: string;
28
+ action_id: string;
29
+ }
30
+
31
+ const INSTALL_COMMANDS = {
32
+ brew: "brew install clojure-lsp/brew/clojure-lsp-native",
33
+ nix: "nix-shell -p clojure-lsp",
34
+ script: "sudo bash < <(curl -s https://raw.githubusercontent.com/clojure-lsp/clojure-lsp/master/install)",
35
+ };
36
+
37
+ let clojureLspError: { serverCommand: string; message: string } | null = null;
38
+
39
+ function on_clojure_lsp_server_error(data: LspServerErrorData): void {
40
+ if (data.language !== "clojure") {
41
+ return;
42
+ }
43
+
44
+ editor.debug(`clojure-lsp: Server error - ${data.error_type}: ${data.message}`);
45
+
46
+ clojureLspError = {
47
+ serverCommand: data.server_command,
48
+ message: data.message,
49
+ };
50
+
51
+ if (data.error_type === "not_found") {
52
+ editor.setStatus(
53
+ `Clojure LSP server '${data.server_command}' not found. Click status bar for help.`
54
+ );
55
+ } else {
56
+ editor.setStatus(`Clojure LSP error: ${data.message}`);
57
+ }
58
+ }
59
+ registerHandler("on_clojure_lsp_server_error", on_clojure_lsp_server_error);
60
+ editor.on("lsp_server_error", "on_clojure_lsp_server_error");
61
+
62
+ function on_clojure_lsp_status_clicked(data: LspStatusClickedData): void {
63
+ if (data.language !== "clojure" || !clojureLspError) {
64
+ return;
65
+ }
66
+
67
+ editor.debug("clojure-lsp: Status clicked, showing help popup");
68
+
69
+ editor.showActionPopup({
70
+ id: "clojure-lsp-help",
71
+ title: "Clojure Language Server Not Found",
72
+ message: `"${clojureLspError.serverCommand}" provides completion, diagnostics, refactoring, and navigation for Clojure/ClojureScript.\n\nNo special project setup needed - it analyzes classpath automatically.\nVS Code users: Install "Calva" (bundles clojure-lsp and nREPL client).\nSee: https://clojure-lsp.io`,
73
+ actions: [
74
+ { id: "copy_brew", label: `Copy: ${INSTALL_COMMANDS.brew}` },
75
+ { id: "copy_nix", label: `Copy: ${INSTALL_COMMANDS.nix}` },
76
+ { id: "copy_script", label: `Copy: install script (Linux/macOS)` },
77
+ { id: "disable", label: "Disable Clojure LSP" },
78
+ { id: "dismiss", label: "Dismiss (ESC)" },
79
+ ],
80
+ });
81
+ }
82
+ registerHandler("on_clojure_lsp_status_clicked", on_clojure_lsp_status_clicked);
83
+ editor.on("lsp_status_clicked", "on_clojure_lsp_status_clicked");
84
+
85
+ function on_clojure_lsp_action_result(data: ActionPopupResultData): void {
86
+ if (data.popup_id !== "clojure-lsp-help") {
87
+ return;
88
+ }
89
+
90
+ editor.debug(`clojure-lsp: Action selected - ${data.action_id}`);
91
+
92
+ switch (data.action_id) {
93
+ case "copy_brew":
94
+ editor.setClipboard(INSTALL_COMMANDS.brew);
95
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.brew);
96
+ break;
97
+
98
+ case "copy_nix":
99
+ editor.setClipboard(INSTALL_COMMANDS.nix);
100
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.nix);
101
+ break;
102
+
103
+ case "copy_script":
104
+ editor.setClipboard(INSTALL_COMMANDS.script);
105
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.script);
106
+ break;
107
+
108
+ case "disable":
109
+ editor.disableLspForLanguage("clojure");
110
+ editor.setStatus("Clojure LSP disabled");
111
+ clojureLspError = null;
112
+ break;
113
+
114
+ case "dismiss":
115
+ case "dismissed":
116
+ break;
117
+
118
+ default:
119
+ editor.debug(`clojure-lsp: Unknown action: ${data.action_id}`);
120
+ }
121
+ }
122
+ registerHandler("on_clojure_lsp_action_result", on_clojure_lsp_action_result);
123
+ editor.on("action_popup_result", "on_clojure_lsp_action_result");
124
+
125
+ editor.debug("clojure-lsp: Plugin loaded");
@@ -0,0 +1,138 @@
1
+ /// <reference path="./lib/fresh.d.ts" />
2
+ const editor = getEditor();
3
+
4
+ /**
5
+ * CMake LSP Helper Plugin
6
+ *
7
+ * Provides user-friendly error handling for CMake LSP server issues.
8
+ * When cmake-language-server fails to start, this plugin shows an actionable
9
+ * popup with installation instructions.
10
+ *
11
+ * Features:
12
+ * - Detects CMake LSP server errors (cmake-language-server)
13
+ * - Shows popup with install commands (pip, pipx)
14
+ * - Provides option to disable CMake LSP
15
+ *
16
+ * VS Code: CMake Tools extension (v1.20+ has basic built-in language services)
17
+ * Neovim: nvim-lspconfig cmake
18
+ * Alternative: neocmakelsp (more actively maintained, has linting/formatting)
19
+ * See: https://github.com/neocmakelsp/neocmakelsp
20
+ */
21
+
22
+ interface LspServerErrorData {
23
+ language: string;
24
+ server_command: string;
25
+ error_type: string;
26
+ message: string;
27
+ }
28
+
29
+ interface LspStatusClickedData {
30
+ language: string;
31
+ has_error: boolean;
32
+ }
33
+
34
+ interface ActionPopupResultData {
35
+ popup_id: string;
36
+ action_id: string;
37
+ }
38
+
39
+ // Install commands for CMake LSP server
40
+ // See: https://github.com/regen100/cmake-language-server
41
+ const INSTALL_COMMANDS = {
42
+ pip: "pip install cmake-language-server",
43
+ pipx: "pipx install cmake-language-server",
44
+ };
45
+
46
+ // Track error state for CMake LSP
47
+ let cmakeLspError: { serverCommand: string; message: string } | null = null;
48
+
49
+ /**
50
+ * Handle LSP server errors for CMake
51
+ */
52
+ function on_cmake_lsp_server_error(data: LspServerErrorData): void {
53
+ if (data.language !== "cmake") {
54
+ return;
55
+ }
56
+
57
+ editor.debug(`cmake-lsp: Server error - ${data.error_type}: ${data.message}`);
58
+
59
+ cmakeLspError = {
60
+ serverCommand: data.server_command,
61
+ message: data.message,
62
+ };
63
+
64
+ if (data.error_type === "not_found") {
65
+ editor.setStatus(
66
+ `CMake LSP server '${data.server_command}' not found. Click status bar for help.`
67
+ );
68
+ } else {
69
+ editor.setStatus(`CMake LSP error: ${data.message}`);
70
+ }
71
+ }
72
+ registerHandler("on_cmake_lsp_server_error", on_cmake_lsp_server_error);
73
+ editor.on("lsp_server_error", "on_cmake_lsp_server_error");
74
+
75
+ /**
76
+ * Handle status bar click when there's a CMake LSP error
77
+ */
78
+ function on_cmake_lsp_status_clicked(data: LspStatusClickedData): void {
79
+ if (data.language !== "cmake" || !cmakeLspError) {
80
+ return;
81
+ }
82
+
83
+ editor.debug("cmake-lsp: Status clicked, showing help popup");
84
+
85
+ editor.showActionPopup({
86
+ id: "cmake-lsp-help",
87
+ title: "CMake Language Server Not Found",
88
+ message: `"${cmakeLspError.serverCommand}" provides code completion, diagnostics, and navigation for CMakeLists.txt files. Requires Python. Copy a command below to install it, or visit https://github.com/regen100/cmake-language-server for details. Alternative: neocmakelsp (https://github.com/Decodetalkers/neocmakelsp).`,
89
+ actions: [
90
+ { id: "copy_pip", label: `Copy: ${INSTALL_COMMANDS.pip}` },
91
+ { id: "copy_pipx", label: `Copy: ${INSTALL_COMMANDS.pipx}` },
92
+ { id: "disable", label: "Disable CMake LSP" },
93
+ { id: "dismiss", label: "Dismiss (ESC)" },
94
+ ],
95
+ });
96
+ }
97
+ registerHandler("on_cmake_lsp_status_clicked", on_cmake_lsp_status_clicked);
98
+ editor.on("lsp_status_clicked", "on_cmake_lsp_status_clicked");
99
+
100
+ /**
101
+ * Handle action popup results for CMake LSP help
102
+ */
103
+ function on_cmake_lsp_action_result(data: ActionPopupResultData): void {
104
+ if (data.popup_id !== "cmake-lsp-help") {
105
+ return;
106
+ }
107
+
108
+ editor.debug(`cmake-lsp: Action selected - ${data.action_id}`);
109
+
110
+ switch (data.action_id) {
111
+ case "copy_pip":
112
+ editor.setClipboard(INSTALL_COMMANDS.pip);
113
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.pip);
114
+ break;
115
+
116
+ case "copy_pipx":
117
+ editor.setClipboard(INSTALL_COMMANDS.pipx);
118
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.pipx);
119
+ break;
120
+
121
+ case "disable":
122
+ editor.disableLspForLanguage("cmake");
123
+ editor.setStatus("CMake LSP disabled");
124
+ cmakeLspError = null;
125
+ break;
126
+
127
+ case "dismiss":
128
+ case "dismissed":
129
+ break;
130
+
131
+ default:
132
+ editor.debug(`cmake-lsp: Unknown action: ${data.action_id}`);
133
+ }
134
+ }
135
+ registerHandler("on_cmake_lsp_action_result", on_cmake_lsp_action_result);
136
+ editor.on("action_popup_result", "on_cmake_lsp_action_result");
137
+
138
+ editor.debug("cmake-lsp: Plugin loaded");