xtrm-tools 0.5.31 → 0.5.33
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/cli/package.json
CHANGED
|
@@ -3,15 +3,18 @@ import { spawnSync, execSync } from "node:child_process";
|
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import * as path from "node:path";
|
|
5
5
|
|
|
6
|
+
type InstallMethod =
|
|
7
|
+
| { type: "npm"; packages: string[] }
|
|
8
|
+
| { type: "go"; module: string }
|
|
9
|
+
| { type: "rustup"; component: string }
|
|
10
|
+
| { type: "brew"; formula: string }
|
|
11
|
+
| { type: "system"; hint: string };
|
|
12
|
+
|
|
6
13
|
interface LspTarget {
|
|
7
|
-
|
|
14
|
+
label: string;
|
|
8
15
|
markers: string[];
|
|
9
|
-
/** Binary to check in PATH */
|
|
10
16
|
bin: string;
|
|
11
|
-
|
|
12
|
-
npmPackages: string[];
|
|
13
|
-
/** Human-readable label */
|
|
14
|
-
label: string;
|
|
17
|
+
install: InstallMethod;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
const TARGETS: LspTarget[] = [
|
|
@@ -19,25 +22,49 @@ const TARGETS: LspTarget[] = [
|
|
|
19
22
|
label: "TypeScript/JavaScript",
|
|
20
23
|
markers: ["tsconfig.json", "package.json"],
|
|
21
24
|
bin: "typescript-language-server",
|
|
22
|
-
|
|
25
|
+
install: { type: "npm", packages: ["typescript-language-server", "typescript"] },
|
|
23
26
|
},
|
|
24
27
|
{
|
|
25
28
|
label: "Python",
|
|
26
29
|
markers: ["pyproject.toml", "requirements.txt", "setup.py"],
|
|
27
30
|
bin: "pyright-langserver",
|
|
28
|
-
|
|
31
|
+
install: { type: "npm", packages: ["pyright"] },
|
|
29
32
|
},
|
|
30
33
|
{
|
|
31
34
|
label: "Vue",
|
|
32
35
|
markers: ["vue.config.js", "vite.config.ts", "vite.config.js"],
|
|
33
36
|
bin: "vue-language-server",
|
|
34
|
-
|
|
37
|
+
install: { type: "npm", packages: ["@vue/language-server"] },
|
|
35
38
|
},
|
|
36
39
|
{
|
|
37
40
|
label: "Svelte",
|
|
38
41
|
markers: ["svelte.config.js", "svelte.config.ts"],
|
|
39
42
|
bin: "svelteserver",
|
|
40
|
-
|
|
43
|
+
install: { type: "npm", packages: ["svelte-language-server"] },
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
label: "Go",
|
|
47
|
+
markers: ["go.mod"],
|
|
48
|
+
bin: "gopls",
|
|
49
|
+
install: { type: "go", module: "golang.org/x/tools/gopls@latest" },
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
label: "Rust",
|
|
53
|
+
markers: ["Cargo.toml"],
|
|
54
|
+
bin: "rust-analyzer",
|
|
55
|
+
install: { type: "rustup", component: "rust-analyzer" },
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: "Kotlin",
|
|
59
|
+
markers: ["build.gradle", "build.gradle.kts", "settings.gradle", "settings.gradle.kts", "pom.xml"],
|
|
60
|
+
bin: "kotlin-language-server",
|
|
61
|
+
install: { type: "brew", formula: "JetBrains/utils/kotlin-lsp" },
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
label: "Swift",
|
|
65
|
+
markers: ["Package.swift"],
|
|
66
|
+
bin: "sourcekit-lsp",
|
|
67
|
+
install: { type: "system", hint: "sourcekit-lsp is bundled with Xcode — install Xcode or Command Line Tools: xcode-select --install" },
|
|
41
68
|
},
|
|
42
69
|
];
|
|
43
70
|
|
|
@@ -56,13 +83,33 @@ function detectTargets(cwd: string): LspTarget[] {
|
|
|
56
83
|
);
|
|
57
84
|
}
|
|
58
85
|
|
|
59
|
-
function
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
86
|
+
function runInstall(target: LspTarget, ctx: any): void {
|
|
87
|
+
const { install } = target;
|
|
88
|
+
let cmd: string[];
|
|
89
|
+
let fallback: string;
|
|
90
|
+
|
|
91
|
+
if (install.type === "npm") {
|
|
92
|
+
cmd = ["npm", "install", "-g", ...install.packages];
|
|
93
|
+
fallback = `npm install -g ${install.packages.join(" ")}`;
|
|
94
|
+
} else if (install.type === "go") {
|
|
95
|
+
cmd = ["go", "install", install.module];
|
|
96
|
+
fallback = `go install ${install.module}`;
|
|
97
|
+
} else if (install.type === "rustup") {
|
|
98
|
+
cmd = ["rustup", "component", "add", install.component];
|
|
99
|
+
fallback = `rustup component add ${install.component}`;
|
|
100
|
+
} else if (install.type === "brew") {
|
|
101
|
+
cmd = ["brew", "install", install.formula];
|
|
102
|
+
fallback = `brew install ${install.formula}`;
|
|
103
|
+
} else {
|
|
104
|
+
// system — cannot auto-install, just warn
|
|
105
|
+
ctx.ui.notify(`lsp-bootstrap: ${target.label} LSP not found — ${install.hint}`, "warning");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
ctx.ui.notify(`lsp-bootstrap: installing ${target.label} language server…`, "info");
|
|
110
|
+
const r = spawnSync(cmd[0], cmd.slice(1), { encoding: "utf8", stdio: "pipe" });
|
|
64
111
|
if (r.status !== 0) {
|
|
65
|
-
ctx.ui.notify(`lsp-bootstrap: failed to install ${
|
|
112
|
+
ctx.ui.notify(`lsp-bootstrap: failed to install ${target.label} — run manually: ${fallback}`, "warning");
|
|
66
113
|
}
|
|
67
114
|
}
|
|
68
115
|
|
|
@@ -72,17 +119,16 @@ export default function register(api: ExtensionAPI) {
|
|
|
72
119
|
const detected = detectTargets(cwd);
|
|
73
120
|
if (detected.length === 0) return;
|
|
74
121
|
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
122
|
+
const missing = detected.filter(t => !isInPath(t.bin));
|
|
123
|
+
if (missing.length === 0) return;
|
|
77
124
|
|
|
78
|
-
for (const target of
|
|
79
|
-
|
|
80
|
-
installPackages(target.npmPackages, ctx);
|
|
125
|
+
for (const target of missing) {
|
|
126
|
+
runInstall(target, ctx);
|
|
81
127
|
}
|
|
82
128
|
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
ctx.ui.notify(`lsp-bootstrap: ready — ${
|
|
129
|
+
const nowReady = missing.filter(t => isInPath(t.bin)).map(t => t.label);
|
|
130
|
+
if (nowReady.length > 0) {
|
|
131
|
+
ctx.ui.notify(`lsp-bootstrap: ready — ${nowReady.join(", ")}`, "info");
|
|
86
132
|
}
|
|
87
133
|
});
|
|
88
134
|
}
|
package/package.json
CHANGED