diff --git a/packages/opencode/src/lsp/server.ts b/packages/opencode/src/lsp/server.ts index f50c858e912f..abfb31ead0eb 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 cfab72d83471..7e514e39b159 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() - } - }) })