|
|
@@ -4,12 +4,14 @@ import os from "os"
|
|
|
import { Global } from "../global"
|
|
|
import { Log } from "../util/log"
|
|
|
import { BunProc } from "../bun"
|
|
|
-import { $, readableStreamToText } from "bun"
|
|
|
+import { $ } from "bun"
|
|
|
+import { text } from "node:stream/consumers"
|
|
|
import fs from "fs/promises"
|
|
|
import { Filesystem } from "../util/filesystem"
|
|
|
import { Instance } from "../project/instance"
|
|
|
import { Flag } from "../flag/flag"
|
|
|
import { Archive } from "../util/archive"
|
|
|
+import { Process } from "../util/process"
|
|
|
|
|
|
export namespace LSPServer {
|
|
|
const log = Log.create({ service: "lsp.server" })
|
|
|
@@ -133,7 +135,7 @@ export namespace LSPServer {
|
|
|
)
|
|
|
if (!(await Filesystem.exists(js))) {
|
|
|
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
|
|
|
- await Bun.spawn([BunProc.which(), "install", "@vue/language-server"], {
|
|
|
+ await Process.spawn([BunProc.which(), "install", "@vue/language-server"], {
|
|
|
cwd: Global.Path.bin,
|
|
|
env: {
|
|
|
...process.env,
|
|
|
@@ -263,14 +265,16 @@ export namespace LSPServer {
|
|
|
}
|
|
|
|
|
|
if (lintBin) {
|
|
|
- const proc = Bun.spawn([lintBin, "--help"], { stdout: "pipe" })
|
|
|
+ const proc = Process.spawn([lintBin, "--help"], { stdout: "pipe" })
|
|
|
await proc.exited
|
|
|
- const help = await readableStreamToText(proc.stdout)
|
|
|
- if (help.includes("--lsp")) {
|
|
|
- return {
|
|
|
- process: spawn(lintBin, ["--lsp"], {
|
|
|
- cwd: root,
|
|
|
- }),
|
|
|
+ if (proc.stdout) {
|
|
|
+ const help = await text(proc.stdout)
|
|
|
+ if (help.includes("--lsp")) {
|
|
|
+ return {
|
|
|
+ process: spawn(lintBin, ["--lsp"], {
|
|
|
+ cwd: root,
|
|
|
+ }),
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -372,8 +376,7 @@ export namespace LSPServer {
|
|
|
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
|
|
|
|
|
|
log.info("installing gopls")
|
|
|
- const proc = Bun.spawn({
|
|
|
- cmd: ["go", "install", "golang.org/x/tools/gopls@latest"],
|
|
|
+ const proc = Process.spawn(["go", "install", "golang.org/x/tools/gopls@latest"], {
|
|
|
env: { ...process.env, GOBIN: Global.Path.bin },
|
|
|
stdout: "pipe",
|
|
|
stderr: "pipe",
|
|
|
@@ -414,8 +417,7 @@ export namespace LSPServer {
|
|
|
}
|
|
|
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
|
|
|
log.info("installing rubocop")
|
|
|
- const proc = Bun.spawn({
|
|
|
- cmd: ["gem", "install", "rubocop", "--bindir", Global.Path.bin],
|
|
|
+ const proc = Process.spawn(["gem", "install", "rubocop", "--bindir", Global.Path.bin], {
|
|
|
stdout: "pipe",
|
|
|
stderr: "pipe",
|
|
|
stdin: "pipe",
|
|
|
@@ -513,7 +515,7 @@ export namespace LSPServer {
|
|
|
const js = path.join(Global.Path.bin, "node_modules", "pyright", "dist", "pyright-langserver.js")
|
|
|
if (!(await Filesystem.exists(js))) {
|
|
|
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
|
|
|
- await Bun.spawn([BunProc.which(), "install", "pyright"], {
|
|
|
+ await Process.spawn([BunProc.which(), "install", "pyright"], {
|
|
|
cwd: Global.Path.bin,
|
|
|
env: {
|
|
|
...process.env,
|
|
|
@@ -746,8 +748,7 @@ export namespace LSPServer {
|
|
|
|
|
|
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
|
|
|
log.info("installing csharp-ls via dotnet tool")
|
|
|
- const proc = Bun.spawn({
|
|
|
- cmd: ["dotnet", "tool", "install", "csharp-ls", "--tool-path", Global.Path.bin],
|
|
|
+ const proc = Process.spawn(["dotnet", "tool", "install", "csharp-ls", "--tool-path", Global.Path.bin], {
|
|
|
stdout: "pipe",
|
|
|
stderr: "pipe",
|
|
|
stdin: "pipe",
|
|
|
@@ -786,8 +787,7 @@ export namespace LSPServer {
|
|
|
|
|
|
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
|
|
|
log.info("installing fsautocomplete via dotnet tool")
|
|
|
- const proc = Bun.spawn({
|
|
|
- cmd: ["dotnet", "tool", "install", "fsautocomplete", "--tool-path", Global.Path.bin],
|
|
|
+ const proc = Process.spawn(["dotnet", "tool", "install", "fsautocomplete", "--tool-path", Global.Path.bin], {
|
|
|
stdout: "pipe",
|
|
|
stderr: "pipe",
|
|
|
stdin: "pipe",
|
|
|
@@ -1047,7 +1047,7 @@ export namespace LSPServer {
|
|
|
const js = path.join(Global.Path.bin, "node_modules", "svelte-language-server", "bin", "server.js")
|
|
|
if (!(await Filesystem.exists(js))) {
|
|
|
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
|
|
|
- await Bun.spawn([BunProc.which(), "install", "svelte-language-server"], {
|
|
|
+ await Process.spawn([BunProc.which(), "install", "svelte-language-server"], {
|
|
|
cwd: Global.Path.bin,
|
|
|
env: {
|
|
|
...process.env,
|
|
|
@@ -1094,7 +1094,7 @@ export namespace LSPServer {
|
|
|
const js = path.join(Global.Path.bin, "node_modules", "@astrojs", "language-server", "bin", "nodeServer.js")
|
|
|
if (!(await Filesystem.exists(js))) {
|
|
|
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
|
|
|
- await Bun.spawn([BunProc.which(), "install", "@astrojs/language-server"], {
|
|
|
+ await Process.spawn([BunProc.which(), "install", "@astrojs/language-server"], {
|
|
|
cwd: Global.Path.bin,
|
|
|
env: {
|
|
|
...process.env,
|
|
|
@@ -1339,7 +1339,7 @@ export namespace LSPServer {
|
|
|
const exists = await Filesystem.exists(js)
|
|
|
if (!exists) {
|
|
|
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
|
|
|
- await Bun.spawn([BunProc.which(), "install", "yaml-language-server"], {
|
|
|
+ await Process.spawn([BunProc.which(), "install", "yaml-language-server"], {
|
|
|
cwd: Global.Path.bin,
|
|
|
env: {
|
|
|
...process.env,
|
|
|
@@ -1518,7 +1518,7 @@ export namespace LSPServer {
|
|
|
const js = path.join(Global.Path.bin, "node_modules", "intelephense", "lib", "intelephense.js")
|
|
|
if (!(await Filesystem.exists(js))) {
|
|
|
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
|
|
|
- await Bun.spawn([BunProc.which(), "install", "intelephense"], {
|
|
|
+ await Process.spawn([BunProc.which(), "install", "intelephense"], {
|
|
|
cwd: Global.Path.bin,
|
|
|
env: {
|
|
|
...process.env,
|
|
|
@@ -1615,7 +1615,7 @@ export namespace LSPServer {
|
|
|
const js = path.join(Global.Path.bin, "node_modules", "bash-language-server", "out", "cli.js")
|
|
|
if (!(await Filesystem.exists(js))) {
|
|
|
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
|
|
|
- await Bun.spawn([BunProc.which(), "install", "bash-language-server"], {
|
|
|
+ await Process.spawn([BunProc.which(), "install", "bash-language-server"], {
|
|
|
cwd: Global.Path.bin,
|
|
|
env: {
|
|
|
...process.env,
|
|
|
@@ -1827,7 +1827,7 @@ export namespace LSPServer {
|
|
|
const js = path.join(Global.Path.bin, "node_modules", "dockerfile-language-server-nodejs", "lib", "server.js")
|
|
|
if (!(await Filesystem.exists(js))) {
|
|
|
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
|
|
|
- await Bun.spawn([BunProc.which(), "install", "dockerfile-language-server-nodejs"], {
|
|
|
+ await Process.spawn([BunProc.which(), "install", "dockerfile-language-server-nodejs"], {
|
|
|
cwd: Global.Path.bin,
|
|
|
env: {
|
|
|
...process.env,
|