@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.
- package/CHANGELOG.md +91 -0
- package/package.json +1 -1
- package/plugins/astro-lsp.ts +118 -0
- package/plugins/bash-lsp.ts +161 -0
- package/plugins/clojure-lsp.ts +125 -0
- package/plugins/cmake-lsp.ts +138 -0
- package/plugins/config-schema.json +33 -4
- package/plugins/dart-lsp.ts +144 -0
- package/plugins/elixir-lsp.ts +120 -0
- package/plugins/erlang-lsp.ts +121 -0
- package/plugins/fsharp-lsp.ts +125 -0
- package/plugins/gleam-lsp.ts +124 -0
- package/plugins/graphql-lsp.ts +139 -0
- package/plugins/haskell-lsp.ts +125 -0
- package/plugins/julia-lsp.ts +111 -0
- package/plugins/kotlin-lsp.ts +162 -0
- package/plugins/lib/fresh.d.ts +25 -0
- package/plugins/lua-lsp.ts +161 -0
- package/plugins/nim-lsp.ts +118 -0
- package/plugins/nix-lsp.ts +125 -0
- package/plugins/nushell-lsp.ts +144 -0
- package/plugins/ocaml-lsp.ts +119 -0
- package/plugins/perl-lsp.ts +118 -0
- package/plugins/php-lsp.ts +165 -0
- package/plugins/pkg.ts +33 -47
- package/plugins/protobuf-lsp.ts +144 -0
- package/plugins/r-lsp.ts +118 -0
- package/plugins/ruby-lsp.ts +165 -0
- package/plugins/scala-lsp.ts +119 -0
- package/plugins/solidity-lsp.ts +130 -0
- package/plugins/sql-lsp.ts +129 -0
- package/plugins/svelte-lsp.ts +119 -0
- package/plugins/swift-lsp.ts +120 -0
- package/plugins/tailwindcss-lsp.ts +119 -0
- package/plugins/terraform-lsp.ts +144 -0
- package/plugins/theme_editor.i18n.json +70 -14
- package/plugins/theme_editor.ts +71 -39
- package/plugins/toml-lsp.ts +162 -0
- package/plugins/typst-lsp.ts +165 -0
- package/plugins/vue-lsp.ts +118 -0
- package/plugins/yaml-lsp.ts +163 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
const editor = getEditor();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Gleam LSP Helper Plugin
|
|
6
|
+
*
|
|
7
|
+
* Server: Built into the Gleam compiler (gleam lsp)
|
|
8
|
+
* VS Code: "Gleam" extension
|
|
9
|
+
* Neovim: nvim-lspconfig gleam
|
|
10
|
+
* Note: LSP is bundled with the Gleam binary - install Gleam to get it
|
|
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
|
+
brew: "brew install gleam",
|
|
32
|
+
cargo: "cargo install gleam",
|
|
33
|
+
nix: "nix-env -iA nixpkgs.gleam",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
let gleamLspError: { serverCommand: string; message: string } | null = null;
|
|
37
|
+
|
|
38
|
+
function on_gleam_lsp_server_error(data: LspServerErrorData): void {
|
|
39
|
+
if (data.language !== "gleam") {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
editor.debug(`gleam-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
44
|
+
|
|
45
|
+
gleamLspError = {
|
|
46
|
+
serverCommand: data.server_command,
|
|
47
|
+
message: data.message,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
if (data.error_type === "not_found") {
|
|
51
|
+
editor.setStatus(
|
|
52
|
+
`Gleam LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
53
|
+
);
|
|
54
|
+
} else {
|
|
55
|
+
editor.setStatus(`Gleam LSP error: ${data.message}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
registerHandler("on_gleam_lsp_server_error", on_gleam_lsp_server_error);
|
|
59
|
+
editor.on("lsp_server_error", "on_gleam_lsp_server_error");
|
|
60
|
+
|
|
61
|
+
function on_gleam_lsp_status_clicked(data: LspStatusClickedData): void {
|
|
62
|
+
if (data.language !== "gleam" || !gleamLspError) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
editor.debug("gleam-lsp: Status clicked, showing help popup");
|
|
67
|
+
|
|
68
|
+
editor.showActionPopup({
|
|
69
|
+
id: "gleam-lsp-help",
|
|
70
|
+
title: "Gleam Language Server Not Found",
|
|
71
|
+
message: `The Gleam language server is built into the Gleam compiler binary. Install Gleam to get LSP support - no separate installation needed.\n\nProvides completion, diagnostics, hover, go-to-definition, and formatting.\nVS Code users: Install the "Gleam" extension.\nSee: https://gleam.run/getting-started/installing/`,
|
|
72
|
+
actions: [
|
|
73
|
+
{ id: "copy_brew", label: `Copy: ${INSTALL_COMMANDS.brew}` },
|
|
74
|
+
{ id: "copy_cargo", label: `Copy: ${INSTALL_COMMANDS.cargo}` },
|
|
75
|
+
{ id: "copy_nix", label: `Copy: ${INSTALL_COMMANDS.nix}` },
|
|
76
|
+
{ id: "disable", label: "Disable Gleam LSP" },
|
|
77
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
78
|
+
],
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
registerHandler("on_gleam_lsp_status_clicked", on_gleam_lsp_status_clicked);
|
|
82
|
+
editor.on("lsp_status_clicked", "on_gleam_lsp_status_clicked");
|
|
83
|
+
|
|
84
|
+
function on_gleam_lsp_action_result(data: ActionPopupResultData): void {
|
|
85
|
+
if (data.popup_id !== "gleam-lsp-help") {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
editor.debug(`gleam-lsp: Action selected - ${data.action_id}`);
|
|
90
|
+
|
|
91
|
+
switch (data.action_id) {
|
|
92
|
+
case "copy_brew":
|
|
93
|
+
editor.setClipboard(INSTALL_COMMANDS.brew);
|
|
94
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.brew);
|
|
95
|
+
break;
|
|
96
|
+
|
|
97
|
+
case "copy_cargo":
|
|
98
|
+
editor.setClipboard(INSTALL_COMMANDS.cargo);
|
|
99
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.cargo);
|
|
100
|
+
break;
|
|
101
|
+
|
|
102
|
+
case "copy_nix":
|
|
103
|
+
editor.setClipboard(INSTALL_COMMANDS.nix);
|
|
104
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.nix);
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
case "disable":
|
|
108
|
+
editor.disableLspForLanguage("gleam");
|
|
109
|
+
editor.setStatus("Gleam LSP disabled");
|
|
110
|
+
gleamLspError = null;
|
|
111
|
+
break;
|
|
112
|
+
|
|
113
|
+
case "dismiss":
|
|
114
|
+
case "dismissed":
|
|
115
|
+
break;
|
|
116
|
+
|
|
117
|
+
default:
|
|
118
|
+
editor.debug(`gleam-lsp: Unknown action: ${data.action_id}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
registerHandler("on_gleam_lsp_action_result", on_gleam_lsp_action_result);
|
|
122
|
+
editor.on("action_popup_result", "on_gleam_lsp_action_result");
|
|
123
|
+
|
|
124
|
+
editor.debug("gleam-lsp: Plugin loaded");
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
const editor = getEditor();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* GraphQL LSP Helper Plugin
|
|
6
|
+
*
|
|
7
|
+
* Provides user-friendly error handling for GraphQL LSP server issues.
|
|
8
|
+
* When graphql-lsp fails to start, this plugin shows an actionable
|
|
9
|
+
* popup with installation instructions.
|
|
10
|
+
*
|
|
11
|
+
* Features:
|
|
12
|
+
* - Detects GraphQL LSP server errors (graphql-lsp)
|
|
13
|
+
* - Shows popup with install commands (npm)
|
|
14
|
+
* - Provides option to disable GraphQL LSP
|
|
15
|
+
*
|
|
16
|
+
* VS Code: "GraphQL: Language Feature Support" extension
|
|
17
|
+
* Neovim: nvim-lspconfig graphql
|
|
18
|
+
* Note: Requires a graphql-config file (.graphqlrc, graphql.config.js, etc.)
|
|
19
|
+
* Alternative: Apollo GraphQL extension (for Apollo users)
|
|
20
|
+
* Config docs: https://the-guild.dev/graphql/config
|
|
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 GraphQL LSP server
|
|
41
|
+
// See: https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service-cli
|
|
42
|
+
const INSTALL_COMMANDS = {
|
|
43
|
+
npm: "npm i -g graphql-language-service-cli",
|
|
44
|
+
yarn: "yarn global add graphql-language-service-cli",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Track error state for GraphQL LSP
|
|
48
|
+
let graphqlLspError: { serverCommand: string; message: string } | null = null;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Handle LSP server errors for GraphQL
|
|
52
|
+
*/
|
|
53
|
+
function on_graphql_lsp_server_error(data: LspServerErrorData): void {
|
|
54
|
+
if (data.language !== "graphql") {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
editor.debug(`graphql-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
59
|
+
|
|
60
|
+
graphqlLspError = {
|
|
61
|
+
serverCommand: data.server_command,
|
|
62
|
+
message: data.message,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
if (data.error_type === "not_found") {
|
|
66
|
+
editor.setStatus(
|
|
67
|
+
`GraphQL LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
68
|
+
);
|
|
69
|
+
} else {
|
|
70
|
+
editor.setStatus(`GraphQL LSP error: ${data.message}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
registerHandler("on_graphql_lsp_server_error", on_graphql_lsp_server_error);
|
|
74
|
+
editor.on("lsp_server_error", "on_graphql_lsp_server_error");
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Handle status bar click when there's a GraphQL LSP error
|
|
78
|
+
*/
|
|
79
|
+
function on_graphql_lsp_status_clicked(data: LspStatusClickedData): void {
|
|
80
|
+
if (data.language !== "graphql" || !graphqlLspError) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
editor.debug("graphql-lsp: Status clicked, showing help popup");
|
|
85
|
+
|
|
86
|
+
editor.showActionPopup({
|
|
87
|
+
id: "graphql-lsp-help",
|
|
88
|
+
title: "GraphQL Language Server Not Found",
|
|
89
|
+
message: `"${graphqlLspError.serverCommand}" provides code completion, validation, and hover info for GraphQL schemas and queries. Requires Node.js and a .graphqlrc config. Copy a command below to install it, or visit https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service-cli for details.`,
|
|
90
|
+
actions: [
|
|
91
|
+
{ id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
|
|
92
|
+
{ id: "copy_yarn", label: `Copy: ${INSTALL_COMMANDS.yarn}` },
|
|
93
|
+
{ id: "disable", label: "Disable GraphQL LSP" },
|
|
94
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
registerHandler("on_graphql_lsp_status_clicked", on_graphql_lsp_status_clicked);
|
|
99
|
+
editor.on("lsp_status_clicked", "on_graphql_lsp_status_clicked");
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Handle action popup results for GraphQL LSP help
|
|
103
|
+
*/
|
|
104
|
+
function on_graphql_lsp_action_result(data: ActionPopupResultData): void {
|
|
105
|
+
if (data.popup_id !== "graphql-lsp-help") {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
editor.debug(`graphql-lsp: Action selected - ${data.action_id}`);
|
|
110
|
+
|
|
111
|
+
switch (data.action_id) {
|
|
112
|
+
case "copy_npm":
|
|
113
|
+
editor.setClipboard(INSTALL_COMMANDS.npm);
|
|
114
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.npm);
|
|
115
|
+
break;
|
|
116
|
+
|
|
117
|
+
case "copy_yarn":
|
|
118
|
+
editor.setClipboard(INSTALL_COMMANDS.yarn);
|
|
119
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.yarn);
|
|
120
|
+
break;
|
|
121
|
+
|
|
122
|
+
case "disable":
|
|
123
|
+
editor.disableLspForLanguage("graphql");
|
|
124
|
+
editor.setStatus("GraphQL LSP disabled");
|
|
125
|
+
graphqlLspError = null;
|
|
126
|
+
break;
|
|
127
|
+
|
|
128
|
+
case "dismiss":
|
|
129
|
+
case "dismissed":
|
|
130
|
+
break;
|
|
131
|
+
|
|
132
|
+
default:
|
|
133
|
+
editor.debug(`graphql-lsp: Unknown action: ${data.action_id}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
registerHandler("on_graphql_lsp_action_result", on_graphql_lsp_action_result);
|
|
137
|
+
editor.on("action_popup_result", "on_graphql_lsp_action_result");
|
|
138
|
+
|
|
139
|
+
editor.debug("graphql-lsp: Plugin loaded");
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
const editor = getEditor();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Haskell LSP Helper Plugin
|
|
6
|
+
*
|
|
7
|
+
* Server: haskell-language-server (HLS)
|
|
8
|
+
* VS Code: "Haskell" extension (installs HLS via GHCup)
|
|
9
|
+
* Neovim: nvim-lspconfig hls
|
|
10
|
+
* Install via: GHCup (recommended), brew, nix
|
|
11
|
+
* Note: HLS must match your GHC version
|
|
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
|
+
ghcup: "ghcup install hls",
|
|
33
|
+
brew: "brew install haskell-language-server",
|
|
34
|
+
nix: "nix-env -iA nixpkgs.haskell-language-server",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
let haskellLspError: { serverCommand: string; message: string } | null = null;
|
|
38
|
+
|
|
39
|
+
function on_haskell_lsp_server_error(data: LspServerErrorData): void {
|
|
40
|
+
if (data.language !== "haskell") {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
editor.debug(`haskell-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
45
|
+
|
|
46
|
+
haskellLspError = {
|
|
47
|
+
serverCommand: data.server_command,
|
|
48
|
+
message: data.message,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
if (data.error_type === "not_found") {
|
|
52
|
+
editor.setStatus(
|
|
53
|
+
`Haskell LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
54
|
+
);
|
|
55
|
+
} else {
|
|
56
|
+
editor.setStatus(`Haskell LSP error: ${data.message}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
registerHandler("on_haskell_lsp_server_error", on_haskell_lsp_server_error);
|
|
60
|
+
editor.on("lsp_server_error", "on_haskell_lsp_server_error");
|
|
61
|
+
|
|
62
|
+
function on_haskell_lsp_status_clicked(data: LspStatusClickedData): void {
|
|
63
|
+
if (data.language !== "haskell" || !haskellLspError) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
editor.debug("haskell-lsp: Status clicked, showing help popup");
|
|
68
|
+
|
|
69
|
+
editor.showActionPopup({
|
|
70
|
+
id: "haskell-lsp-help",
|
|
71
|
+
title: "Haskell Language Server Not Found",
|
|
72
|
+
message: `"${haskellLspError.serverCommand}" (HLS) provides completion, diagnostics, code actions, and refactoring for Haskell. HLS must match your GHC version.\n\nRecommended: Install via GHCup (manages GHC + HLS versions).\nInstall GHCup: curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh\nVS Code users: Install the "Haskell" extension (auto-installs HLS via GHCup).\nSee: https://haskell-language-server.readthedocs.io`,
|
|
73
|
+
actions: [
|
|
74
|
+
{ id: "copy_ghcup", label: `Copy: ${INSTALL_COMMANDS.ghcup}` },
|
|
75
|
+
{ id: "copy_brew", label: `Copy: ${INSTALL_COMMANDS.brew}` },
|
|
76
|
+
{ id: "copy_nix", label: `Copy: ${INSTALL_COMMANDS.nix}` },
|
|
77
|
+
{ id: "disable", label: "Disable Haskell LSP" },
|
|
78
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
registerHandler("on_haskell_lsp_status_clicked", on_haskell_lsp_status_clicked);
|
|
83
|
+
editor.on("lsp_status_clicked", "on_haskell_lsp_status_clicked");
|
|
84
|
+
|
|
85
|
+
function on_haskell_lsp_action_result(data: ActionPopupResultData): void {
|
|
86
|
+
if (data.popup_id !== "haskell-lsp-help") {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
editor.debug(`haskell-lsp: Action selected - ${data.action_id}`);
|
|
91
|
+
|
|
92
|
+
switch (data.action_id) {
|
|
93
|
+
case "copy_ghcup":
|
|
94
|
+
editor.setClipboard(INSTALL_COMMANDS.ghcup);
|
|
95
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.ghcup);
|
|
96
|
+
break;
|
|
97
|
+
|
|
98
|
+
case "copy_brew":
|
|
99
|
+
editor.setClipboard(INSTALL_COMMANDS.brew);
|
|
100
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.brew);
|
|
101
|
+
break;
|
|
102
|
+
|
|
103
|
+
case "copy_nix":
|
|
104
|
+
editor.setClipboard(INSTALL_COMMANDS.nix);
|
|
105
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.nix);
|
|
106
|
+
break;
|
|
107
|
+
|
|
108
|
+
case "disable":
|
|
109
|
+
editor.disableLspForLanguage("haskell");
|
|
110
|
+
editor.setStatus("Haskell LSP disabled");
|
|
111
|
+
haskellLspError = null;
|
|
112
|
+
break;
|
|
113
|
+
|
|
114
|
+
case "dismiss":
|
|
115
|
+
case "dismissed":
|
|
116
|
+
break;
|
|
117
|
+
|
|
118
|
+
default:
|
|
119
|
+
editor.debug(`haskell-lsp: Unknown action: ${data.action_id}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
registerHandler("on_haskell_lsp_action_result", on_haskell_lsp_action_result);
|
|
123
|
+
editor.on("action_popup_result", "on_haskell_lsp_action_result");
|
|
124
|
+
|
|
125
|
+
editor.debug("haskell-lsp: Plugin loaded");
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
const editor = getEditor();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Julia LSP Helper Plugin
|
|
6
|
+
*
|
|
7
|
+
* Server: LanguageServer.jl (Julia package)
|
|
8
|
+
* VS Code: "Julia" extension (bundles LanguageServer.jl)
|
|
9
|
+
* Neovim: nvim-lspconfig julials
|
|
10
|
+
* Install via: Julia's Pkg.add() - runs as a Julia script
|
|
11
|
+
* Note: First startup can be slow due to Julia compilation
|
|
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
|
+
julia: 'julia -e \'using Pkg; Pkg.add("LanguageServer")\'',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
let juliaLspError: { serverCommand: string; message: string } | null = null;
|
|
36
|
+
|
|
37
|
+
function on_julia_lsp_server_error(data: LspServerErrorData): void {
|
|
38
|
+
if (data.language !== "julia") {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
editor.debug(`julia-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
43
|
+
|
|
44
|
+
juliaLspError = {
|
|
45
|
+
serverCommand: data.server_command,
|
|
46
|
+
message: data.message,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (data.error_type === "not_found") {
|
|
50
|
+
editor.setStatus(
|
|
51
|
+
`Julia LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
52
|
+
);
|
|
53
|
+
} else {
|
|
54
|
+
editor.setStatus(`Julia LSP error: ${data.message}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
registerHandler("on_julia_lsp_server_error", on_julia_lsp_server_error);
|
|
58
|
+
editor.on("lsp_server_error", "on_julia_lsp_server_error");
|
|
59
|
+
|
|
60
|
+
function on_julia_lsp_status_clicked(data: LspStatusClickedData): void {
|
|
61
|
+
if (data.language !== "julia" || !juliaLspError) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
editor.debug("julia-lsp: Status clicked, showing help popup");
|
|
66
|
+
|
|
67
|
+
editor.showActionPopup({
|
|
68
|
+
id: "julia-lsp-help",
|
|
69
|
+
title: "Julia Language Server Not Found",
|
|
70
|
+
message: `The Julia language server (LanguageServer.jl) provides completion, diagnostics, formatting, and navigation for Julia. Julia must be installed.\n\nNote: First startup is slow due to Julia's compilation. Consider using PackageCompiler.jl for faster restarts.\nVS Code users: Install the "Julia" extension (auto-installs LanguageServer.jl).\nSee: https://github.com/julia-vscode/LanguageServer.jl`,
|
|
71
|
+
actions: [
|
|
72
|
+
{ id: "copy_julia", label: `Copy: ${INSTALL_COMMANDS.julia}` },
|
|
73
|
+
{ id: "disable", label: "Disable Julia LSP" },
|
|
74
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
75
|
+
],
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
registerHandler("on_julia_lsp_status_clicked", on_julia_lsp_status_clicked);
|
|
79
|
+
editor.on("lsp_status_clicked", "on_julia_lsp_status_clicked");
|
|
80
|
+
|
|
81
|
+
function on_julia_lsp_action_result(data: ActionPopupResultData): void {
|
|
82
|
+
if (data.popup_id !== "julia-lsp-help") {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
editor.debug(`julia-lsp: Action selected - ${data.action_id}`);
|
|
87
|
+
|
|
88
|
+
switch (data.action_id) {
|
|
89
|
+
case "copy_julia":
|
|
90
|
+
editor.setClipboard(INSTALL_COMMANDS.julia);
|
|
91
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.julia);
|
|
92
|
+
break;
|
|
93
|
+
|
|
94
|
+
case "disable":
|
|
95
|
+
editor.disableLspForLanguage("julia");
|
|
96
|
+
editor.setStatus("Julia LSP disabled");
|
|
97
|
+
juliaLspError = null;
|
|
98
|
+
break;
|
|
99
|
+
|
|
100
|
+
case "dismiss":
|
|
101
|
+
case "dismissed":
|
|
102
|
+
break;
|
|
103
|
+
|
|
104
|
+
default:
|
|
105
|
+
editor.debug(`julia-lsp: Unknown action: ${data.action_id}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
registerHandler("on_julia_lsp_action_result", on_julia_lsp_action_result);
|
|
109
|
+
editor.on("action_popup_result", "on_julia_lsp_action_result");
|
|
110
|
+
|
|
111
|
+
editor.debug("julia-lsp: Plugin loaded");
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
const editor = getEditor();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Kotlin LSP Helper Plugin
|
|
6
|
+
*
|
|
7
|
+
* Provides user-friendly error handling for Kotlin LSP server issues.
|
|
8
|
+
* When kotlin-language-server fails to start, this plugin shows an actionable
|
|
9
|
+
* popup with installation instructions.
|
|
10
|
+
*
|
|
11
|
+
* Features:
|
|
12
|
+
* - Detects Kotlin LSP server errors (kotlin-language-server)
|
|
13
|
+
* - Shows popup with install commands (brew, SDKMAN, snap)
|
|
14
|
+
* - Allows copying install commands to clipboard
|
|
15
|
+
* - Provides option to disable Kotlin LSP
|
|
16
|
+
*
|
|
17
|
+
* VS Code: "Kotlin" extension (fwcd.kotlin)
|
|
18
|
+
* Neovim: nvim-lspconfig kotlin_language_server
|
|
19
|
+
* Note: Requires JDK 11+. For full IDE support, consider IntelliJ IDEA
|
|
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 Kotlin LSP server (kotlin-language-server)
|
|
40
|
+
// See: https://github.com/fwcd/kotlin-language-server
|
|
41
|
+
const INSTALL_COMMANDS = {
|
|
42
|
+
brew: "brew install kotlin-language-server",
|
|
43
|
+
snap: "sudo snap install kotlin-language-server --classic",
|
|
44
|
+
nix: "nix-env -i kotlin-language-server",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Track error state for Kotlin LSP
|
|
48
|
+
let kotlinLspError: { serverCommand: string; message: string } | null = null;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Handle LSP server errors for Kotlin
|
|
52
|
+
*/
|
|
53
|
+
function on_kotlin_lsp_server_error(data: LspServerErrorData): void {
|
|
54
|
+
// Only handle Kotlin language errors
|
|
55
|
+
if (data.language !== "kotlin") {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
editor.debug(`kotlin-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
60
|
+
|
|
61
|
+
// Store error state for later reference
|
|
62
|
+
kotlinLspError = {
|
|
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
|
+
`Kotlin LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
71
|
+
);
|
|
72
|
+
} else {
|
|
73
|
+
editor.setStatus(`Kotlin LSP error: ${data.message}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
registerHandler("on_kotlin_lsp_server_error", on_kotlin_lsp_server_error);
|
|
77
|
+
|
|
78
|
+
// Register hook for LSP server errors
|
|
79
|
+
editor.on("lsp_server_error", "on_kotlin_lsp_server_error");
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Handle status bar click when there's a Kotlin LSP error
|
|
83
|
+
*/
|
|
84
|
+
function on_kotlin_lsp_status_clicked(
|
|
85
|
+
data: LspStatusClickedData
|
|
86
|
+
): void {
|
|
87
|
+
// Only handle Kotlin language clicks when there's an error
|
|
88
|
+
if (data.language !== "kotlin" || !kotlinLspError) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
editor.debug("kotlin-lsp: Status clicked, showing help popup");
|
|
93
|
+
|
|
94
|
+
// Show action popup with install options
|
|
95
|
+
editor.showActionPopup({
|
|
96
|
+
id: "kotlin-lsp-help",
|
|
97
|
+
title: "Kotlin Language Server Not Found",
|
|
98
|
+
message: `"${kotlinLspError.serverCommand}" provides code completion, diagnostics, and navigation for Kotlin files. Requires a JDK (Java 11+). Copy a command below to install it, or visit https://github.com/fwcd/kotlin-language-server for build instructions and releases. For full Kotlin IDE support, consider IntelliJ IDEA or Android Studio.`,
|
|
99
|
+
actions: [
|
|
100
|
+
{ id: "copy_brew", label: `Copy: ${INSTALL_COMMANDS.brew}` },
|
|
101
|
+
{ id: "copy_snap", label: `Copy: ${INSTALL_COMMANDS.snap}` },
|
|
102
|
+
{ id: "copy_nix", label: `Copy: ${INSTALL_COMMANDS.nix}` },
|
|
103
|
+
{ id: "disable", label: "Disable Kotlin LSP" },
|
|
104
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
105
|
+
],
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
registerHandler("on_kotlin_lsp_status_clicked", on_kotlin_lsp_status_clicked);
|
|
109
|
+
|
|
110
|
+
// Register hook for status bar clicks
|
|
111
|
+
editor.on("lsp_status_clicked", "on_kotlin_lsp_status_clicked");
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Handle action popup results for Kotlin LSP help
|
|
115
|
+
*/
|
|
116
|
+
function on_kotlin_lsp_action_result(
|
|
117
|
+
data: ActionPopupResultData
|
|
118
|
+
): void {
|
|
119
|
+
// Only handle our popup
|
|
120
|
+
if (data.popup_id !== "kotlin-lsp-help") {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
editor.debug(`kotlin-lsp: Action selected - ${data.action_id}`);
|
|
125
|
+
|
|
126
|
+
switch (data.action_id) {
|
|
127
|
+
case "copy_brew":
|
|
128
|
+
editor.setClipboard(INSTALL_COMMANDS.brew);
|
|
129
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.brew);
|
|
130
|
+
break;
|
|
131
|
+
|
|
132
|
+
case "copy_snap":
|
|
133
|
+
editor.setClipboard(INSTALL_COMMANDS.snap);
|
|
134
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.snap);
|
|
135
|
+
break;
|
|
136
|
+
|
|
137
|
+
case "copy_nix":
|
|
138
|
+
editor.setClipboard(INSTALL_COMMANDS.nix);
|
|
139
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.nix);
|
|
140
|
+
break;
|
|
141
|
+
|
|
142
|
+
case "disable":
|
|
143
|
+
editor.disableLspForLanguage("kotlin");
|
|
144
|
+
editor.setStatus("Kotlin LSP disabled");
|
|
145
|
+
kotlinLspError = null;
|
|
146
|
+
break;
|
|
147
|
+
|
|
148
|
+
case "dismiss":
|
|
149
|
+
case "dismissed":
|
|
150
|
+
// Just close the popup without action
|
|
151
|
+
break;
|
|
152
|
+
|
|
153
|
+
default:
|
|
154
|
+
editor.debug(`kotlin-lsp: Unknown action: ${data.action_id}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
registerHandler("on_kotlin_lsp_action_result", on_kotlin_lsp_action_result);
|
|
158
|
+
|
|
159
|
+
// Register hook for action popup results
|
|
160
|
+
editor.on("action_popup_result", "on_kotlin_lsp_action_result");
|
|
161
|
+
|
|
162
|
+
editor.debug("kotlin-lsp: Plugin loaded");
|
package/plugins/lib/fresh.d.ts
CHANGED
|
@@ -1031,6 +1031,31 @@ interface EditorAPI {
|
|
|
1031
1031
|
*/
|
|
1032
1032
|
readDir(path: string): DirEntry[];
|
|
1033
1033
|
/**
|
|
1034
|
+
* Create a directory (and all parent directories) recursively.
|
|
1035
|
+
* Returns true if the directory was created or already exists.
|
|
1036
|
+
*/
|
|
1037
|
+
createDir(path: string): boolean;
|
|
1038
|
+
/**
|
|
1039
|
+
* Remove a file or directory by moving it to the OS trash/recycle bin.
|
|
1040
|
+
* For safety, the path must be under the OS temp directory or the Fresh
|
|
1041
|
+
* config directory. Returns true on success.
|
|
1042
|
+
*/
|
|
1043
|
+
removePath(path: string): boolean;
|
|
1044
|
+
/**
|
|
1045
|
+
* Rename/move a file or directory. Returns true on success.
|
|
1046
|
+
* Falls back to copy then trash for cross-filesystem moves.
|
|
1047
|
+
*/
|
|
1048
|
+
renamePath(from: string, to: string): boolean;
|
|
1049
|
+
/**
|
|
1050
|
+
* Copy a file or directory recursively to a new location.
|
|
1051
|
+
* Returns true on success.
|
|
1052
|
+
*/
|
|
1053
|
+
copyPath(from: string, to: string): boolean;
|
|
1054
|
+
/**
|
|
1055
|
+
* Get the OS temporary directory path.
|
|
1056
|
+
*/
|
|
1057
|
+
getTempDir(): string;
|
|
1058
|
+
/**
|
|
1034
1059
|
* Get current config as JS object
|
|
1035
1060
|
*/
|
|
1036
1061
|
getConfig(): unknown;
|