@fresh-editor/fresh-editor 0.2.17 → 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 +84 -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
package/plugins/r-lsp.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
const editor = getEditor();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* R LSP Helper Plugin
|
|
6
|
+
*
|
|
7
|
+
* Server: languageserver (R package)
|
|
8
|
+
* VS Code: "R" extension by REditorSupport (uses languageserver)
|
|
9
|
+
* Neovim: nvim-lspconfig r_language_server
|
|
10
|
+
* Install via: R's install.packages() - runs as an R script
|
|
11
|
+
* Note: Also install httpgd for plot viewer support
|
|
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
|
+
r: 'R -e \'install.packages("languageserver")\'',
|
|
33
|
+
conda: "conda install -c conda-forge r-languageserver",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
let rLspError: { serverCommand: string; message: string } | null = null;
|
|
37
|
+
|
|
38
|
+
function on_r_lsp_server_error(data: LspServerErrorData): void {
|
|
39
|
+
if (data.language !== "r") {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
editor.debug(`r-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
44
|
+
|
|
45
|
+
rLspError = {
|
|
46
|
+
serverCommand: data.server_command,
|
|
47
|
+
message: data.message,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
if (data.error_type === "not_found") {
|
|
51
|
+
editor.setStatus(
|
|
52
|
+
`R LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
53
|
+
);
|
|
54
|
+
} else {
|
|
55
|
+
editor.setStatus(`R LSP error: ${data.message}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
registerHandler("on_r_lsp_server_error", on_r_lsp_server_error);
|
|
59
|
+
editor.on("lsp_server_error", "on_r_lsp_server_error");
|
|
60
|
+
|
|
61
|
+
function on_r_lsp_status_clicked(data: LspStatusClickedData): void {
|
|
62
|
+
if (data.language !== "r" || !rLspError) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
editor.debug("r-lsp: Status clicked, showing help popup");
|
|
67
|
+
|
|
68
|
+
editor.showActionPopup({
|
|
69
|
+
id: "r-lsp-help",
|
|
70
|
+
title: "R Language Server Not Found",
|
|
71
|
+
message: `The R language server provides completion, diagnostics, hover, formatting, and go-to-definition for R files. It runs as an R script, so R must be installed.\n\nInstall the languageserver R package, then the server runs via: R --vanilla -e 'languageserver::run()'\nVS Code users: Install the "R" extension by REditorSupport.\nSee: https://github.com/REditorSupport/languageserver`,
|
|
72
|
+
actions: [
|
|
73
|
+
{ id: "copy_r", label: `Copy: ${INSTALL_COMMANDS.r}` },
|
|
74
|
+
{ id: "copy_conda", label: `Copy: ${INSTALL_COMMANDS.conda}` },
|
|
75
|
+
{ id: "disable", label: "Disable R LSP" },
|
|
76
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
77
|
+
],
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
registerHandler("on_r_lsp_status_clicked", on_r_lsp_status_clicked);
|
|
81
|
+
editor.on("lsp_status_clicked", "on_r_lsp_status_clicked");
|
|
82
|
+
|
|
83
|
+
function on_r_lsp_action_result(data: ActionPopupResultData): void {
|
|
84
|
+
if (data.popup_id !== "r-lsp-help") {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
editor.debug(`r-lsp: Action selected - ${data.action_id}`);
|
|
89
|
+
|
|
90
|
+
switch (data.action_id) {
|
|
91
|
+
case "copy_r":
|
|
92
|
+
editor.setClipboard(INSTALL_COMMANDS.r);
|
|
93
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.r);
|
|
94
|
+
break;
|
|
95
|
+
|
|
96
|
+
case "copy_conda":
|
|
97
|
+
editor.setClipboard(INSTALL_COMMANDS.conda);
|
|
98
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.conda);
|
|
99
|
+
break;
|
|
100
|
+
|
|
101
|
+
case "disable":
|
|
102
|
+
editor.disableLspForLanguage("r");
|
|
103
|
+
editor.setStatus("R LSP disabled");
|
|
104
|
+
rLspError = null;
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
case "dismiss":
|
|
108
|
+
case "dismissed":
|
|
109
|
+
break;
|
|
110
|
+
|
|
111
|
+
default:
|
|
112
|
+
editor.debug(`r-lsp: Unknown action: ${data.action_id}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
registerHandler("on_r_lsp_action_result", on_r_lsp_action_result);
|
|
116
|
+
editor.on("action_popup_result", "on_r_lsp_action_result");
|
|
117
|
+
|
|
118
|
+
editor.debug("r-lsp: Plugin loaded");
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
const editor = getEditor();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Ruby LSP Helper Plugin
|
|
6
|
+
*
|
|
7
|
+
* Provides user-friendly error handling for Ruby LSP server issues.
|
|
8
|
+
* When solargraph fails to start, this plugin shows an actionable
|
|
9
|
+
* popup with installation instructions.
|
|
10
|
+
*
|
|
11
|
+
* Features:
|
|
12
|
+
* - Detects Ruby LSP server errors (solargraph)
|
|
13
|
+
* - Shows popup with install commands (gem)
|
|
14
|
+
* - Allows copying install commands to clipboard
|
|
15
|
+
* - Provides option to disable Ruby LSP
|
|
16
|
+
*
|
|
17
|
+
* Alternatives:
|
|
18
|
+
* - ruby-lsp (Shopify): Modern Ruby LSP - gem install ruby-lsp (https://github.com/Shopify/ruby-lsp)
|
|
19
|
+
* - Steep: Ruby type checker with LSP support (https://github.com/soutaro/steep)
|
|
20
|
+
* - Sorbet: Gradual type checker for Ruby (https://sorbet.org/)
|
|
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 Ruby LSP server (solargraph)
|
|
41
|
+
// See: https://solargraph.org/guides/getting-started
|
|
42
|
+
const INSTALL_COMMANDS = {
|
|
43
|
+
gem: "gem install solargraph",
|
|
44
|
+
bundler: "bundle add solargraph --group development",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Alternative LSP server
|
|
48
|
+
const ALT_INSTALL = "gem install ruby-lsp";
|
|
49
|
+
|
|
50
|
+
// Track error state for Ruby LSP
|
|
51
|
+
let rubyLspError: { serverCommand: string; message: string } | null = null;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Handle LSP server errors for Ruby
|
|
55
|
+
*/
|
|
56
|
+
function on_ruby_lsp_server_error(data: LspServerErrorData): void {
|
|
57
|
+
// Only handle Ruby language errors
|
|
58
|
+
if (data.language !== "ruby") {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
editor.debug(`ruby-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
63
|
+
|
|
64
|
+
// Store error state for later reference
|
|
65
|
+
rubyLspError = {
|
|
66
|
+
serverCommand: data.server_command,
|
|
67
|
+
message: data.message,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// Show a status message for immediate feedback
|
|
71
|
+
if (data.error_type === "not_found") {
|
|
72
|
+
editor.setStatus(
|
|
73
|
+
`Ruby LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
74
|
+
);
|
|
75
|
+
} else {
|
|
76
|
+
editor.setStatus(`Ruby LSP error: ${data.message}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
registerHandler("on_ruby_lsp_server_error", on_ruby_lsp_server_error);
|
|
80
|
+
|
|
81
|
+
// Register hook for LSP server errors
|
|
82
|
+
editor.on("lsp_server_error", "on_ruby_lsp_server_error");
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Handle status bar click when there's a Ruby LSP error
|
|
86
|
+
*/
|
|
87
|
+
function on_ruby_lsp_status_clicked(
|
|
88
|
+
data: LspStatusClickedData
|
|
89
|
+
): void {
|
|
90
|
+
// Only handle Ruby language clicks when there's an error
|
|
91
|
+
if (data.language !== "ruby" || !rubyLspError) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
editor.debug("ruby-lsp: Status clicked, showing help popup");
|
|
96
|
+
|
|
97
|
+
// Show action popup with install options
|
|
98
|
+
editor.showActionPopup({
|
|
99
|
+
id: "ruby-lsp-help",
|
|
100
|
+
title: "Ruby Language Server Not Found",
|
|
101
|
+
message: `"${rubyLspError.serverCommand}" provides code completion, diagnostics, and navigation for Ruby files. Requires Ruby/RubyGems. Copy a command below to install it, or visit https://solargraph.org/guides/getting-started for details. Alternative: Shopify's ruby-lsp (https://github.com/Shopify/ruby-lsp).`,
|
|
102
|
+
actions: [
|
|
103
|
+
{ id: "copy_gem", label: `Copy: ${INSTALL_COMMANDS.gem}` },
|
|
104
|
+
{ id: "copy_bundler", label: `Copy: ${INSTALL_COMMANDS.bundler}` },
|
|
105
|
+
{ id: "copy_alt", label: `Alternative: ${ALT_INSTALL}` },
|
|
106
|
+
{ id: "disable", label: "Disable Ruby LSP" },
|
|
107
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
108
|
+
],
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
registerHandler("on_ruby_lsp_status_clicked", on_ruby_lsp_status_clicked);
|
|
112
|
+
|
|
113
|
+
// Register hook for status bar clicks
|
|
114
|
+
editor.on("lsp_status_clicked", "on_ruby_lsp_status_clicked");
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Handle action popup results for Ruby LSP help
|
|
118
|
+
*/
|
|
119
|
+
function on_ruby_lsp_action_result(
|
|
120
|
+
data: ActionPopupResultData
|
|
121
|
+
): void {
|
|
122
|
+
// Only handle our popup
|
|
123
|
+
if (data.popup_id !== "ruby-lsp-help") {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
editor.debug(`ruby-lsp: Action selected - ${data.action_id}`);
|
|
128
|
+
|
|
129
|
+
switch (data.action_id) {
|
|
130
|
+
case "copy_gem":
|
|
131
|
+
editor.setClipboard(INSTALL_COMMANDS.gem);
|
|
132
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.gem);
|
|
133
|
+
break;
|
|
134
|
+
|
|
135
|
+
case "copy_bundler":
|
|
136
|
+
editor.setClipboard(INSTALL_COMMANDS.bundler);
|
|
137
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.bundler);
|
|
138
|
+
break;
|
|
139
|
+
|
|
140
|
+
case "copy_alt":
|
|
141
|
+
editor.setClipboard(ALT_INSTALL);
|
|
142
|
+
editor.setStatus("Copied: " + ALT_INSTALL);
|
|
143
|
+
break;
|
|
144
|
+
|
|
145
|
+
case "disable":
|
|
146
|
+
editor.disableLspForLanguage("ruby");
|
|
147
|
+
editor.setStatus("Ruby LSP disabled");
|
|
148
|
+
rubyLspError = null;
|
|
149
|
+
break;
|
|
150
|
+
|
|
151
|
+
case "dismiss":
|
|
152
|
+
case "dismissed":
|
|
153
|
+
// Just close the popup without action
|
|
154
|
+
break;
|
|
155
|
+
|
|
156
|
+
default:
|
|
157
|
+
editor.debug(`ruby-lsp: Unknown action: ${data.action_id}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
registerHandler("on_ruby_lsp_action_result", on_ruby_lsp_action_result);
|
|
161
|
+
|
|
162
|
+
// Register hook for action popup results
|
|
163
|
+
editor.on("action_popup_result", "on_ruby_lsp_action_result");
|
|
164
|
+
|
|
165
|
+
editor.debug("ruby-lsp: Plugin loaded");
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
const editor = getEditor();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Scala LSP Helper Plugin
|
|
6
|
+
*
|
|
7
|
+
* Server: Metals (scalameta.org/metals)
|
|
8
|
+
* VS Code: "Scala (Metals)" extension
|
|
9
|
+
* Neovim: nvim-metals plugin (recommended over nvim-lspconfig)
|
|
10
|
+
* Requires: Java 11+ and Coursier
|
|
11
|
+
* Supports: sbt, Mill, Gradle, Maven via Bloop/BSP
|
|
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
|
+
coursier: "cs install metals",
|
|
33
|
+
brew_cs: "brew install coursier/formulas/coursier && cs install metals",
|
|
34
|
+
manual: "curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && ./cs install metals",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
let scalaLspError: { serverCommand: string; message: string } | null = null;
|
|
38
|
+
|
|
39
|
+
function on_scala_lsp_server_error(data: LspServerErrorData): void {
|
|
40
|
+
if (data.language !== "scala") {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
editor.debug(`scala-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
45
|
+
|
|
46
|
+
scalaLspError = {
|
|
47
|
+
serverCommand: data.server_command,
|
|
48
|
+
message: data.message,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
if (data.error_type === "not_found") {
|
|
52
|
+
editor.setStatus(
|
|
53
|
+
`Scala LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
54
|
+
);
|
|
55
|
+
} else {
|
|
56
|
+
editor.setStatus(`Scala LSP error: ${data.message}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
registerHandler("on_scala_lsp_server_error", on_scala_lsp_server_error);
|
|
60
|
+
editor.on("lsp_server_error", "on_scala_lsp_server_error");
|
|
61
|
+
|
|
62
|
+
function on_scala_lsp_status_clicked(data: LspStatusClickedData): void {
|
|
63
|
+
if (data.language !== "scala" || !scalaLspError) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
editor.debug("scala-lsp: Status clicked, showing help popup");
|
|
68
|
+
|
|
69
|
+
editor.showActionPopup({
|
|
70
|
+
id: "scala-lsp-help",
|
|
71
|
+
title: "Scala Language Server Not Found",
|
|
72
|
+
message: `"${scalaLspError.serverCommand}" (Metals) provides completion, diagnostics, refactoring, and debugging for Scala. Requires Java 11+ and Coursier.\n\nSupports sbt, Mill, Gradle, Maven via Bloop/BSP.\nVS Code users: Install "Scala (Metals)" extension.\nNeovim users: Use nvim-metals plugin.\nSee: https://scalameta.org/metals/docs/editors/overview`,
|
|
73
|
+
actions: [
|
|
74
|
+
{ id: "copy_coursier", label: `Copy: ${INSTALL_COMMANDS.coursier}` },
|
|
75
|
+
{ id: "copy_brew", label: `Copy: ${INSTALL_COMMANDS.brew_cs}` },
|
|
76
|
+
{ id: "disable", label: "Disable Scala LSP" },
|
|
77
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
78
|
+
],
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
registerHandler("on_scala_lsp_status_clicked", on_scala_lsp_status_clicked);
|
|
82
|
+
editor.on("lsp_status_clicked", "on_scala_lsp_status_clicked");
|
|
83
|
+
|
|
84
|
+
function on_scala_lsp_action_result(data: ActionPopupResultData): void {
|
|
85
|
+
if (data.popup_id !== "scala-lsp-help") {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
editor.debug(`scala-lsp: Action selected - ${data.action_id}`);
|
|
90
|
+
|
|
91
|
+
switch (data.action_id) {
|
|
92
|
+
case "copy_coursier":
|
|
93
|
+
editor.setClipboard(INSTALL_COMMANDS.coursier);
|
|
94
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.coursier);
|
|
95
|
+
break;
|
|
96
|
+
|
|
97
|
+
case "copy_brew":
|
|
98
|
+
editor.setClipboard(INSTALL_COMMANDS.brew_cs);
|
|
99
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.brew_cs);
|
|
100
|
+
break;
|
|
101
|
+
|
|
102
|
+
case "disable":
|
|
103
|
+
editor.disableLspForLanguage("scala");
|
|
104
|
+
editor.setStatus("Scala LSP disabled");
|
|
105
|
+
scalaLspError = null;
|
|
106
|
+
break;
|
|
107
|
+
|
|
108
|
+
case "dismiss":
|
|
109
|
+
case "dismissed":
|
|
110
|
+
break;
|
|
111
|
+
|
|
112
|
+
default:
|
|
113
|
+
editor.debug(`scala-lsp: Unknown action: ${data.action_id}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
registerHandler("on_scala_lsp_action_result", on_scala_lsp_action_result);
|
|
117
|
+
editor.on("action_popup_result", "on_scala_lsp_action_result");
|
|
118
|
+
|
|
119
|
+
editor.debug("scala-lsp: Plugin loaded");
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
const editor = getEditor();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Solidity LSP Helper Plugin
|
|
6
|
+
*
|
|
7
|
+
* Provides user-friendly error handling for Solidity LSP server issues.
|
|
8
|
+
* When nomicfoundation-solidity-language-server fails to start, this plugin
|
|
9
|
+
* shows an actionable popup with installation instructions.
|
|
10
|
+
*
|
|
11
|
+
* Features:
|
|
12
|
+
* - Detects Solidity LSP server errors
|
|
13
|
+
* - Shows popup with install commands (npm)
|
|
14
|
+
* - Provides option to disable Solidity LSP
|
|
15
|
+
*
|
|
16
|
+
* VS Code: "Solidity" by Nomic Foundation (Hardhat), "Solidity" by Juan Blanco
|
|
17
|
+
* Neovim: nvim-lspconfig solidity
|
|
18
|
+
* Alternative: solc (Solidity compiler with diagnostics)
|
|
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 Solidity LSP server
|
|
39
|
+
// See: https://github.com/NomicFoundation/hardhat-vscode/tree/main/server
|
|
40
|
+
const INSTALL_COMMANDS = {
|
|
41
|
+
npm: "npm i -g @nomicfoundation/solidity-language-server",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Track error state for Solidity LSP
|
|
45
|
+
let solidityLspError: { serverCommand: string; message: string } | null = null;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Handle LSP server errors for Solidity
|
|
49
|
+
*/
|
|
50
|
+
function on_solidity_lsp_server_error(data: LspServerErrorData): void {
|
|
51
|
+
if (data.language !== "solidity") {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
editor.debug(`solidity-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
56
|
+
|
|
57
|
+
solidityLspError = {
|
|
58
|
+
serverCommand: data.server_command,
|
|
59
|
+
message: data.message,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (data.error_type === "not_found") {
|
|
63
|
+
editor.setStatus(
|
|
64
|
+
`Solidity LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
editor.setStatus(`Solidity LSP error: ${data.message}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
registerHandler("on_solidity_lsp_server_error", on_solidity_lsp_server_error);
|
|
71
|
+
editor.on("lsp_server_error", "on_solidity_lsp_server_error");
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Handle status bar click when there's a Solidity LSP error
|
|
75
|
+
*/
|
|
76
|
+
function on_solidity_lsp_status_clicked(data: LspStatusClickedData): void {
|
|
77
|
+
if (data.language !== "solidity" || !solidityLspError) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
editor.debug("solidity-lsp: Status clicked, showing help popup");
|
|
82
|
+
|
|
83
|
+
editor.showActionPopup({
|
|
84
|
+
id: "solidity-lsp-help",
|
|
85
|
+
title: "Solidity Language Server Not Found",
|
|
86
|
+
message: `"${solidityLspError.serverCommand}" (by Nomic Foundation) provides code completion, diagnostics, and navigation for Solidity smart contracts. Requires Node.js. Copy the command below to install it, or visit https://github.com/NomicFoundation/hardhat-vscode for details.`,
|
|
87
|
+
actions: [
|
|
88
|
+
{ id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
|
|
89
|
+
{ id: "disable", label: "Disable Solidity LSP" },
|
|
90
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
91
|
+
],
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
registerHandler("on_solidity_lsp_status_clicked", on_solidity_lsp_status_clicked);
|
|
95
|
+
editor.on("lsp_status_clicked", "on_solidity_lsp_status_clicked");
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Handle action popup results for Solidity LSP help
|
|
99
|
+
*/
|
|
100
|
+
function on_solidity_lsp_action_result(data: ActionPopupResultData): void {
|
|
101
|
+
if (data.popup_id !== "solidity-lsp-help") {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
editor.debug(`solidity-lsp: Action selected - ${data.action_id}`);
|
|
106
|
+
|
|
107
|
+
switch (data.action_id) {
|
|
108
|
+
case "copy_npm":
|
|
109
|
+
editor.setClipboard(INSTALL_COMMANDS.npm);
|
|
110
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.npm);
|
|
111
|
+
break;
|
|
112
|
+
|
|
113
|
+
case "disable":
|
|
114
|
+
editor.disableLspForLanguage("solidity");
|
|
115
|
+
editor.setStatus("Solidity LSP disabled");
|
|
116
|
+
solidityLspError = null;
|
|
117
|
+
break;
|
|
118
|
+
|
|
119
|
+
case "dismiss":
|
|
120
|
+
case "dismissed":
|
|
121
|
+
break;
|
|
122
|
+
|
|
123
|
+
default:
|
|
124
|
+
editor.debug(`solidity-lsp: Unknown action: ${data.action_id}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
registerHandler("on_solidity_lsp_action_result", on_solidity_lsp_action_result);
|
|
128
|
+
editor.on("action_popup_result", "on_solidity_lsp_action_result");
|
|
129
|
+
|
|
130
|
+
editor.debug("solidity-lsp: Plugin loaded");
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/// <reference path="./lib/fresh.d.ts" />
|
|
2
|
+
const editor = getEditor();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SQL LSP Helper Plugin
|
|
6
|
+
*
|
|
7
|
+
* Provides user-friendly error handling for SQL LSP server issues.
|
|
8
|
+
* When sqls fails to start, this plugin shows an actionable
|
|
9
|
+
* popup with installation instructions.
|
|
10
|
+
*
|
|
11
|
+
* Server: sqls (github.com/sqls-server/sqls)
|
|
12
|
+
* VS Code: SQLTools extension, Database Client JDBC
|
|
13
|
+
* Neovim: nvim-lspconfig sqls
|
|
14
|
+
* Note: sqls needs a config.yml for database connections
|
|
15
|
+
* Alternative: sql-language-server (npm)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
interface LspServerErrorData {
|
|
19
|
+
language: string;
|
|
20
|
+
server_command: string;
|
|
21
|
+
error_type: string;
|
|
22
|
+
message: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface LspStatusClickedData {
|
|
26
|
+
language: string;
|
|
27
|
+
has_error: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface ActionPopupResultData {
|
|
31
|
+
popup_id: string;
|
|
32
|
+
action_id: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const INSTALL_COMMANDS = {
|
|
36
|
+
go: "go install github.com/sqls-server/sqls@latest",
|
|
37
|
+
brew: "brew install sqls",
|
|
38
|
+
npm_alt: "npm install -g sql-language-server",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
let sqlLspError: { serverCommand: string; message: string } | null = null;
|
|
42
|
+
|
|
43
|
+
function on_sql_lsp_server_error(data: LspServerErrorData): void {
|
|
44
|
+
if (data.language !== "sql") {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
editor.debug(`sql-lsp: Server error - ${data.error_type}: ${data.message}`);
|
|
49
|
+
|
|
50
|
+
sqlLspError = {
|
|
51
|
+
serverCommand: data.server_command,
|
|
52
|
+
message: data.message,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
if (data.error_type === "not_found") {
|
|
56
|
+
editor.setStatus(
|
|
57
|
+
`SQL LSP server '${data.server_command}' not found. Click status bar for help.`
|
|
58
|
+
);
|
|
59
|
+
} else {
|
|
60
|
+
editor.setStatus(`SQL LSP error: ${data.message}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
registerHandler("on_sql_lsp_server_error", on_sql_lsp_server_error);
|
|
64
|
+
editor.on("lsp_server_error", "on_sql_lsp_server_error");
|
|
65
|
+
|
|
66
|
+
function on_sql_lsp_status_clicked(data: LspStatusClickedData): void {
|
|
67
|
+
if (data.language !== "sql" || !sqlLspError) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
editor.debug("sql-lsp: Status clicked, showing help popup");
|
|
72
|
+
|
|
73
|
+
editor.showActionPopup({
|
|
74
|
+
id: "sql-lsp-help",
|
|
75
|
+
title: "SQL Language Server Not Found",
|
|
76
|
+
message: `"${sqlLspError.serverCommand}" provides completion, hover, and diagnostics for SQL files. It requires a config.yml to connect to your database. See: https://github.com/sqls-server/sqls\n\nAlternative: sql-language-server (npm) supports MySQL, PostgreSQL, SQLite.\nVS Code users: Try the SQLTools extension.`,
|
|
77
|
+
actions: [
|
|
78
|
+
{ id: "copy_go", label: `Copy: ${INSTALL_COMMANDS.go}` },
|
|
79
|
+
{ id: "copy_brew", label: `Copy: ${INSTALL_COMMANDS.brew}` },
|
|
80
|
+
{ id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm_alt}` },
|
|
81
|
+
{ id: "disable", label: "Disable SQL LSP" },
|
|
82
|
+
{ id: "dismiss", label: "Dismiss (ESC)" },
|
|
83
|
+
],
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
registerHandler("on_sql_lsp_status_clicked", on_sql_lsp_status_clicked);
|
|
87
|
+
editor.on("lsp_status_clicked", "on_sql_lsp_status_clicked");
|
|
88
|
+
|
|
89
|
+
function on_sql_lsp_action_result(data: ActionPopupResultData): void {
|
|
90
|
+
if (data.popup_id !== "sql-lsp-help") {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
editor.debug(`sql-lsp: Action selected - ${data.action_id}`);
|
|
95
|
+
|
|
96
|
+
switch (data.action_id) {
|
|
97
|
+
case "copy_go":
|
|
98
|
+
editor.setClipboard(INSTALL_COMMANDS.go);
|
|
99
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.go);
|
|
100
|
+
break;
|
|
101
|
+
|
|
102
|
+
case "copy_brew":
|
|
103
|
+
editor.setClipboard(INSTALL_COMMANDS.brew);
|
|
104
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.brew);
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
case "copy_npm":
|
|
108
|
+
editor.setClipboard(INSTALL_COMMANDS.npm_alt);
|
|
109
|
+
editor.setStatus("Copied: " + INSTALL_COMMANDS.npm_alt);
|
|
110
|
+
break;
|
|
111
|
+
|
|
112
|
+
case "disable":
|
|
113
|
+
editor.disableLspForLanguage("sql");
|
|
114
|
+
editor.setStatus("SQL LSP disabled");
|
|
115
|
+
sqlLspError = null;
|
|
116
|
+
break;
|
|
117
|
+
|
|
118
|
+
case "dismiss":
|
|
119
|
+
case "dismissed":
|
|
120
|
+
break;
|
|
121
|
+
|
|
122
|
+
default:
|
|
123
|
+
editor.debug(`sql-lsp: Unknown action: ${data.action_id}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
registerHandler("on_sql_lsp_action_result", on_sql_lsp_action_result);
|
|
127
|
+
editor.on("action_popup_result", "on_sql_lsp_action_result");
|
|
128
|
+
|
|
129
|
+
editor.debug("sql-lsp: Plugin loaded");
|