Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/opencode/src/lsp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1881,10 +1881,10 @@ export namespace LSPServer {
async spawn(root) {
const bin = which("LSPServer") ?? (process.platform === "win32" ? which("LSPServer.exe") : null)
if (!bin) {
log.info("LSPServer not found, please install CangjieSDK first")
log.info("LSPServer not found, please install Cangjie SDK and source envsetup.sh first")
return
}
const proc = spawn(bin, [], {
const proc = spawn(bin, ["--stdio"], {
cwd: root,
})
proc.on("error", (err) => {
Expand Down
46 changes: 46 additions & 0 deletions packages/opencode/test/lsp/cangjie-server.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { describe, expect, test, beforeEach } from "bun:test"
import path from "path"
import { spawn } from "child_process"
import { LSPClient } from "../../src/lsp/client"
import { LSPServer } from "../../src/lsp/server"
import { Instance } from "../../src/project/instance"
import { Log } from "../../src/util/log"

function spawnFakeServer() {
const serverPath = path.join(__dirname, "../fixture/lsp/fake-lsp-server.js")
return {
process: spawn(process.execPath, [serverPath], {
stdio: "pipe",
}),
}
}

describe("Cangjie LSP server", () => {
beforeEach(async () => {
await Log.init({ print: true })
})

test("config has correct id and extensions", () => {
const info = LSPServer.Cangjie
expect(info.id).toBe("cangjie")
expect(info.extensions).toEqual([".cj"])
})

test("initializes over stdio", async () => {
const handle = spawnFakeServer()

const client = await Instance.provide({
directory: process.cwd(),
fn: () =>
LSPClient.create({
serverID: "cangjie",
server: handle as unknown as LSPServer.Handle,
root: process.cwd(),
}),
})

expect(client.connection).toBeDefined()

await client.shutdown()
})
})