@fresh-editor/fresh-editor 0.2.17 → 0.2.20

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 (48) hide show
  1. package/CHANGELOG.md +144 -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 +275 -29
  8. package/plugins/dart-lsp.ts +144 -0
  9. package/plugins/diagnostics_panel.ts +4 -12
  10. package/plugins/diff_nav.i18n.json +128 -0
  11. package/plugins/diff_nav.ts +196 -0
  12. package/plugins/elixir-lsp.ts +120 -0
  13. package/plugins/erlang-lsp.ts +121 -0
  14. package/plugins/fsharp-lsp.ts +125 -0
  15. package/plugins/git_gutter.ts +5 -0
  16. package/plugins/gleam-lsp.ts +124 -0
  17. package/plugins/graphql-lsp.ts +139 -0
  18. package/plugins/haskell-lsp.ts +125 -0
  19. package/plugins/julia-lsp.ts +111 -0
  20. package/plugins/kotlin-lsp.ts +162 -0
  21. package/plugins/lib/finder.ts +19 -12
  22. package/plugins/lib/fresh.d.ts +30 -1
  23. package/plugins/lua-lsp.ts +161 -0
  24. package/plugins/nim-lsp.ts +118 -0
  25. package/plugins/nix-lsp.ts +125 -0
  26. package/plugins/nushell-lsp.ts +144 -0
  27. package/plugins/ocaml-lsp.ts +119 -0
  28. package/plugins/perl-lsp.ts +118 -0
  29. package/plugins/php-lsp.ts +165 -0
  30. package/plugins/pkg.ts +37 -76
  31. package/plugins/protobuf-lsp.ts +144 -0
  32. package/plugins/r-lsp.ts +118 -0
  33. package/plugins/ruby-lsp.ts +165 -0
  34. package/plugins/scala-lsp.ts +119 -0
  35. package/plugins/schemas/package.schema.json +437 -272
  36. package/plugins/schemas/theme.schema.json +18 -0
  37. package/plugins/solidity-lsp.ts +130 -0
  38. package/plugins/sql-lsp.ts +129 -0
  39. package/plugins/svelte-lsp.ts +119 -0
  40. package/plugins/swift-lsp.ts +120 -0
  41. package/plugins/tailwindcss-lsp.ts +119 -0
  42. package/plugins/terraform-lsp.ts +144 -0
  43. package/plugins/theme_editor.i18n.json +70 -14
  44. package/plugins/theme_editor.ts +71 -39
  45. package/plugins/toml-lsp.ts +162 -0
  46. package/plugins/typst-lsp.ts +165 -0
  47. package/plugins/vue-lsp.ts +118 -0
  48. package/plugins/yaml-lsp.ts +163 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,149 @@
1
1
  # Release Notes
2
2
 
3
+ ## 0.2.20
4
+
5
+ ### Features
6
+
7
+ * **Multi-LSP Server Support**: Configure multiple LSP servers per language (e.g., pylsp + pyright for Python). Servers are routed by feature using `only_features`/`except_features` filters, completions are merged from all eligible servers, and diagnostics are tracked per-server. Per-server status is shown in the status bar (#971).
8
+
9
+ * **Per-Language Editor Settings**: `line_wrap`, `wrap_column`, `page_view`, and `page_width` can now be configured per-language. For example, wrap Markdown at 80 columns while keeping code unwrapped (#1371).
10
+
11
+ * **Diff Chunk Navigation Plugin**: New built-in plugin for navigating between diff chunks, merging git and saved-diff sources.
12
+
13
+ ### Improvements
14
+
15
+ * **Faster Startup (~350ms → ~170ms)**: Syntax grammars are pre-compiled at build time, package loading moved from JavaScript to Rust, plugin I/O and transpilation run in parallel, and redundant grammar rebuilds are eliminated. Plugins can now declare dependencies via `import type` from `"fresh:plugin/..."` and are topologically sorted.
16
+
17
+ * **Settings UI Overhaul**: Modernized visual design with wider modal (160 cols), rounded corner borders, Nerd Font category icons, styled `[✓]` toggles, and reverse-video key hints. Keyboard navigation rewritten: Tab cycles sequentially through all fields and buttons, composite controls (Map, ObjectArray, TextList) support internal navigation, entry dialogs have section headers with explicit field ordering, PageDown/PageUp work in the main panel, and TextList edits auto-accept on navigation. Focus indicator now highlights per-row in composite controls.
18
+
19
+ * **Settings Deep Search**: Also in the Settings UI: Search now walks into Map entries, TextList items, and nested JSON values. Searching "python" finds the "python" key in language/LSP maps. Results show hierarchical breadcrumbs (e.g., "Languages > python") and auto-focus the matching entry.
20
+
21
+ * **Per-Language Workspace Root Detection**: New `root_markers` field on LSP server configs. The editor walks upward from the file's directory looking for configured markers (e.g., `Cargo.toml`, `package.json`), replacing the old cwd-based root (#1360).
22
+
23
+ * **Page View Mode**: "Compose" mode renamed to "Page View". Can now auto-activate per language via `page_view: true` in language config. Old keybinding names continue to work.
24
+
25
+ * **256-Color Contrast Enforcement**: When running in a 256-color terminal, foreground colors are automatically adjusted to meet WCAG 3.0:1 minimum contrast ratio against their background. Fixes illegible text in Solarized Dark, Nord, Dracula, and light themes under tmux without truecolor.
26
+
27
+ * **LSP in Library Files**: Files in library paths (site-packages, node_modules, .cargo) now keep LSP enabled for Goto Definition, Hover, and Find References while remaining read-only (#1344).
28
+
29
+ * **Goto Matching Bracket**: Works inside bracket bodies by searching backward for the nearest enclosing bracket, matching VS Code and JetBrains behavior. All bracket searches are bounded to prevent hangs on huge files (#1258).
30
+
31
+ * **LSP Head-of-Line Blocking Fix**: LSP notifications (didClose, didChange, shutdown) are no longer blocked behind pending request responses.
32
+
33
+ * **New Settings**: `show_tilde` to hide EOF tilde markers (#1290), `menu_bar_mnemonics` to disable Alt+key menu shortcuts (#1257).
34
+
35
+ * **`getPluginDir()` Plugin API**: Plugins can now locate their own package directory to find bundled scripts or install local dependencies.
36
+
37
+ ### Bug Fixes
38
+
39
+ * Fixed CSI u and xterm modifyOtherKeys key sequences inserted as literal text in terminal session mode (#1113).
40
+
41
+ * Fixed word selection (Ctrl+W) stopping at accented/Unicode characters (#1332).
42
+
43
+ * Fixed double-click backward drag losing the initial word selection (#1334).
44
+
45
+ * Fixed block cursor invisible in zellij due to double cursor-inversion (#1338).
46
+
47
+ * Fixed cursor visibility and command palette rendering in zellij (#1255).
48
+
49
+ * Fixed undo incorrectly clearing the modified flag after hot exit recovery, which could cause data loss.
50
+
51
+ * Fixed bulk edit (e.g., toggle comment) displacing inlay hints on subsequent lines (#1263). Displaced markers are now restored to exact positions on undo.
52
+
53
+ * Fixed large file syntax highlighting lost when revisiting a file, caused by checkpoint offset drift during partial cache updates.
54
+
55
+ * Fixed embedded language highlighting (e.g., CSS in HTML) breaking at large file offsets.
56
+
57
+ * Fixed Enter key leaking into the markdown buffer when the file explorer panel is focused.
58
+
59
+ * Fixed large file recovery saving the entire file as individual chunks instead of using the recovery format.
60
+
61
+ * Fixed read-only detection for files not owned by the current user (now checks effective uid/gid instead of file mode bits).
62
+
63
+ ## 0.2.18
64
+
65
+ ### Features
66
+
67
+ * **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.
68
+
69
+ * **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.
70
+
71
+ * **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.
72
+
73
+ * **Deno LSP Auto-Detection**: Automatically detects and uses the Deno language server for JS/TS projects (#1191).
74
+
75
+ * **`show_prompt_line` Setting**: New config option to auto-hide the prompt line. Applied immediately from Settings UI (#1273).
76
+
77
+ * **`use_tabs` Setting**: Global `editor.use_tabs` config option for default tab indentation (#1295).
78
+
79
+ ### Improvements
80
+
81
+ * **Plugin Commands in Keybinding Editor**: Plugin-registered commands are now shown and searchable in the keybinding editor.
82
+
83
+ * **Theme Editor ANSI Colors**: Named ANSI colors display as "terminal native" instead of misleading RGB values, with correct native color swatches (#1301).
84
+
85
+ * **Status Bar Language Info**: Shows "[syntax only]" when a language has no LSP config entry.
86
+
87
+ * **Fallback Language Config**: Undetected file types now get a fallback language configuration (#1219).
88
+
89
+ * **File Deletion Uses Trash**: `removePath` now uses the system trash instead of permanent deletion.
90
+
91
+ * **Package Manager Cross-Platform**: Plugin package manager uses cross-platform APIs instead of Unix-specific commands on Windows (#1215).
92
+
93
+ ### Bug Fixes
94
+
95
+ * Fixed arrow keys not working in `less`/`git log` in the embedded terminal, including `TERM` env var not being set on Unix.
96
+
97
+ * Fixed Tab key getting trapped in TextList editing mode in Settings UI.
98
+
99
+ * Fixed `{`, `}`, `;` highlighted as operators instead of punctuation in C/C++ (#1318, #1319).
100
+
101
+ * Fixed auto-dedent for languages without tree-sitter, e.g. Dart.
102
+
103
+ * Fixed auto-indent after closing brace in nested C++ blocks.
104
+
105
+ * Fixed mouse click selecting wrong item in scrolled settings list.
106
+
107
+ * Fixed keybindings for plugin-registered commands not executing (#1312).
108
+
109
+ * Fixed Find Next/Find Previous ignoring cursor position (#1305).
110
+
111
+ * Fixed Tab indent affecting lines outside selection (#1304).
112
+
113
+ * Fixed Shift+letter keybinding deletion not persisting (#1303).
114
+
115
+ * Fixed word selection not preserved when dragging after double-click (#1202, #1317).
116
+
117
+ * Fixed `removePath` failing on Windows due to UNC path mismatch.
118
+
119
+ * Fixed external files missing from tab bar after session restore.
120
+
121
+ * Fixed scroll wheel targeting focused split instead of split under pointer (#1270).
122
+
123
+ * Fixed wrap indent not working with tab indentation (#1283).
124
+
125
+ * Fixed LSP "no server configured" for Kotlin and 30+ other languages.
126
+
127
+ * Fixed Diff syntax highlighting scope-to-category mappings.
128
+
129
+ * Fixed extension mappings for `.cjs`, `.mjs`, `.mts`, `.cts`, `Jenkinsfile`, `Brewfile`.
130
+
131
+ * Fixed LSP initialization timeout too short (increased from 10s to 60s).
132
+
133
+ ### Internal
134
+
135
+ * Added syntax highlighting validation suite with 93 fixture files and e2e tests.
136
+
137
+ * Added e2e tests for Settings UI, keybinding editor, search/replace, and plugin commands.
138
+
139
+ * Fixed multiple flaky e2e tests (search/replace, plugin uninstall, Settings UI).
140
+
141
+ * Removed redundant `SIGUSR1` handler; relies on harness signal handler for backtraces.
142
+
143
+ * Cleaned up completed design docs.
144
+
145
+ ---
146
+
3
147
  ## 0.2.17
4
148
 
5
149
  ### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fresh-editor/fresh-editor",
3
- "version": "0.2.17",
3
+ "version": "0.2.20",
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");