Skip to content

Commit ce19c05

Browse files
authored
fix: ts lsp (#21827)
1 parent 91786d2 commit ce19c05

2 files changed

Lines changed: 1 addition & 89 deletions

File tree

packages/opencode/src/lsp/server.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,7 @@ export namespace LSPServer {
105105
if (!tsserver) return
106106
const bin = await Npm.which("typescript-language-server")
107107
if (!bin) return
108-
109-
const args = ["--stdio", "--tsserver-log-verbosity", "off", "--tsserver-path", tsserver]
110-
111-
if (
112-
!(await pathExists(path.join(root, "tsconfig.json"))) &&
113-
!(await pathExists(path.join(root, "jsconfig.json")))
114-
) {
115-
args.push("--ignore-node-modules")
116-
}
117-
118-
const proc = spawn(bin, args, {
108+
const proc = spawn(bin, ["--stdio"], {
119109
cwd: root,
120110
env: {
121111
...process.env,
Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { describe, expect, spyOn, test } from "bun:test"
22
import path from "path"
3-
import fs from "fs/promises"
43
import * as Lsp from "../../src/lsp/index"
5-
import * as launch from "../../src/lsp/launch"
64
import { LSPServer } from "../../src/lsp/server"
75
import { Instance } from "../../src/project/instance"
86
import { tmpdir } from "../fixture/fixture"
@@ -54,80 +52,4 @@ describe("lsp.spawn", () => {
5452
await Instance.disposeAll()
5553
}
5654
})
57-
58-
test("spawns builtin Typescript LSP with correct arguments", async () => {
59-
await using tmp = await tmpdir()
60-
61-
// Create dummy tsserver to satisfy Module.resolve
62-
const tsdk = path.join(tmp.path, "node_modules", "typescript", "lib")
63-
await fs.mkdir(tsdk, { recursive: true })
64-
await fs.writeFile(path.join(tsdk, "tsserver.js"), "")
65-
66-
const spawnSpy = spyOn(launch, "spawn").mockImplementation(
67-
() =>
68-
({
69-
stdin: {},
70-
stdout: {},
71-
stderr: {},
72-
on: () => {},
73-
kill: () => {},
74-
}) as any,
75-
)
76-
77-
try {
78-
await Instance.provide({
79-
directory: tmp.path,
80-
fn: async () => {
81-
await LSPServer.Typescript.spawn(tmp.path)
82-
},
83-
})
84-
85-
expect(spawnSpy).toHaveBeenCalled()
86-
const args = spawnSpy.mock.calls[0][1] as string[]
87-
88-
expect(args).toContain("--tsserver-path")
89-
expect(args).toContain("--tsserver-log-verbosity")
90-
expect(args).toContain("off")
91-
} finally {
92-
spawnSpy.mockRestore()
93-
}
94-
})
95-
96-
test("spawns builtin Typescript LSP with --ignore-node-modules if no config is found", async () => {
97-
await using tmp = await tmpdir()
98-
99-
// Create dummy tsserver to satisfy Module.resolve
100-
const tsdk = path.join(tmp.path, "node_modules", "typescript", "lib")
101-
await fs.mkdir(tsdk, { recursive: true })
102-
await fs.writeFile(path.join(tsdk, "tsserver.js"), "")
103-
104-
// NO tsconfig.json or jsconfig.json created here
105-
106-
const spawnSpy = spyOn(launch, "spawn").mockImplementation(
107-
() =>
108-
({
109-
stdin: {},
110-
stdout: {},
111-
stderr: {},
112-
on: () => {},
113-
kill: () => {},
114-
}) as any,
115-
)
116-
117-
try {
118-
await Instance.provide({
119-
directory: tmp.path,
120-
fn: async () => {
121-
await LSPServer.Typescript.spawn(tmp.path)
122-
},
123-
})
124-
125-
expect(spawnSpy).toHaveBeenCalled()
126-
const args = spawnSpy.mock.calls[0][1] as string[]
127-
128-
expect(args).toContain("--ignore-node-modules")
129-
} finally {
130-
spawnSpy.mockRestore()
131-
}
132-
})
13355
})

0 commit comments

Comments
 (0)