summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2026-04-10 00:15:45 -0500
committerGitHub <[email protected]>2026-04-10 00:15:45 -0500
commitce19c051be86b5d0fff458bf4d74803c40c06350 (patch)
tree9b8199ce1b81f89008f7f879e47a1310767c36a1
parent91786d2fc18c09a4b08846396e4d7f21b03e0c5c (diff)
downloadopencode-ce19c051be86b5d0fff458bf4d74803c40c06350.tar.gz
opencode-ce19c051be86b5d0fff458bf4d74803c40c06350.zip
fix: ts lsp (#21827)
-rw-r--r--packages/opencode/src/lsp/server.ts12
-rw-r--r--packages/opencode/test/lsp/index.test.ts78
2 files changed, 1 insertions, 89 deletions
diff --git a/packages/opencode/src/lsp/server.ts b/packages/opencode/src/lsp/server.ts
index f50c858e9..abfb31ead 100644
--- a/packages/opencode/src/lsp/server.ts
+++ b/packages/opencode/src/lsp/server.ts
@@ -105,17 +105,7 @@ export namespace LSPServer {
if (!tsserver) return
const bin = await Npm.which("typescript-language-server")
if (!bin) return
-
- const args = ["--stdio", "--tsserver-log-verbosity", "off", "--tsserver-path", tsserver]
-
- if (
- !(await pathExists(path.join(root, "tsconfig.json"))) &&
- !(await pathExists(path.join(root, "jsconfig.json")))
- ) {
- args.push("--ignore-node-modules")
- }
-
- const proc = spawn(bin, args, {
+ const proc = spawn(bin, ["--stdio"], {
cwd: root,
env: {
...process.env,
diff --git a/packages/opencode/test/lsp/index.test.ts b/packages/opencode/test/lsp/index.test.ts
index cfab72d83..7e514e39b 100644
--- a/packages/opencode/test/lsp/index.test.ts
+++ b/packages/opencode/test/lsp/index.test.ts
@@ -1,8 +1,6 @@
import { describe, expect, spyOn, test } from "bun:test"
import path from "path"
-import fs from "fs/promises"
import * as Lsp from "../../src/lsp/index"
-import * as launch from "../../src/lsp/launch"
import { LSPServer } from "../../src/lsp/server"
import { Instance } from "../../src/project/instance"
import { tmpdir } from "../fixture/fixture"
@@ -54,80 +52,4 @@ describe("lsp.spawn", () => {
await Instance.disposeAll()
}
})
-
- test("spawns builtin Typescript LSP with correct arguments", async () => {
- await using tmp = await tmpdir()
-
- // Create dummy tsserver to satisfy Module.resolve
- const tsdk = path.join(tmp.path, "node_modules", "typescript", "lib")
- await fs.mkdir(tsdk, { recursive: true })
- await fs.writeFile(path.join(tsdk, "tsserver.js"), "")
-
- const spawnSpy = spyOn(launch, "spawn").mockImplementation(
- () =>
- ({
- stdin: {},
- stdout: {},
- stderr: {},
- on: () => {},
- kill: () => {},
- }) as any,
- )
-
- try {
- await Instance.provide({
- directory: tmp.path,
- fn: async () => {
- await LSPServer.Typescript.spawn(tmp.path)
- },
- })
-
- expect(spawnSpy).toHaveBeenCalled()
- const args = spawnSpy.mock.calls[0][1] as string[]
-
- expect(args).toContain("--tsserver-path")
- expect(args).toContain("--tsserver-log-verbosity")
- expect(args).toContain("off")
- } finally {
- spawnSpy.mockRestore()
- }
- })
-
- test("spawns builtin Typescript LSP with --ignore-node-modules if no config is found", async () => {
- await using tmp = await tmpdir()
-
- // Create dummy tsserver to satisfy Module.resolve
- const tsdk = path.join(tmp.path, "node_modules", "typescript", "lib")
- await fs.mkdir(tsdk, { recursive: true })
- await fs.writeFile(path.join(tsdk, "tsserver.js"), "")
-
- // NO tsconfig.json or jsconfig.json created here
-
- const spawnSpy = spyOn(launch, "spawn").mockImplementation(
- () =>
- ({
- stdin: {},
- stdout: {},
- stderr: {},
- on: () => {},
- kill: () => {},
- }) as any,
- )
-
- try {
- await Instance.provide({
- directory: tmp.path,
- fn: async () => {
- await LSPServer.Typescript.spawn(tmp.path)
- },
- })
-
- expect(spawnSpy).toHaveBeenCalled()
- const args = spawnSpy.mock.calls[0][1] as string[]
-
- expect(args).toContain("--ignore-node-modules")
- } finally {
- spawnSpy.mockRestore()
- }
- })
})