From 96b5a079fff01cedfa6d849fc6346f5d70a57d41 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Tue, 10 Jun 2025 10:46:55 -0400 Subject: [PATCH] Update LSP client/server and CLI scrap command functionality MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [OpenCode](https://opencode.ai) Co-Authored-By: OpenCode --- packages/opencode/src/cli/cmd/scrap.ts | 8 +++----- packages/opencode/src/lsp/client.ts | 3 ++- packages/opencode/src/lsp/server.ts | 17 ++++++++++++----- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/opencode/src/cli/cmd/scrap.ts b/packages/opencode/src/cli/cmd/scrap.ts index 426607731..13f24ae27 100644 --- a/packages/opencode/src/cli/cmd/scrap.ts +++ b/packages/opencode/src/cli/cmd/scrap.ts @@ -1,6 +1,5 @@ import { App } from "../../app/app" import { VERSION } from "../version" -import { LSP } from "../../lsp" import { cmd } from "./cmd" export const ScrapCommand = cmd({ @@ -8,10 +7,9 @@ export const ScrapCommand = cmd({ builder: (yargs) => yargs.positional("file", { type: "string", demandOption: true }), describe: "test command", - async handler(args) { - await App.provide({ cwd: process.cwd(), version: VERSION }, async () => { - await LSP.touchFile(args.file, true) - await LSP.diagnostics() + async handler() { + await App.provide({ cwd: process.cwd(), version: VERSION }, async (app) => { + Bun.resolveSync("typescript/lib/tsserver.js", app.path.cwd) }) }, }) diff --git a/packages/opencode/src/lsp/client.ts b/packages/opencode/src/lsp/client.ts index e2f02216c..e7f8e9697 100644 --- a/packages/opencode/src/lsp/client.ts +++ b/packages/opencode/src/lsp/client.ts @@ -57,6 +57,7 @@ export namespace LSPClient { }) connection.listen() + const initialization = await input.initialization?.(app) await connection.sendRequest("initialize", { processId: server.pid, workspaceFolders: [ @@ -66,7 +67,7 @@ export namespace LSPClient { }, ], initializationOptions: { - ...input.initialization, + ...initialization, }, capabilities: { workspace: { diff --git a/packages/opencode/src/lsp/server.ts b/packages/opencode/src/lsp/server.ts index 5b2db4841..c13f10bec 100644 --- a/packages/opencode/src/lsp/server.ts +++ b/packages/opencode/src/lsp/server.ts @@ -10,7 +10,7 @@ export namespace LSPServer { export interface Info { id: string extensions: string[] - initialization?: Record + initialization?: (app: App.Info) => Promise> spawn(app: App.Info): Promise } @@ -27,10 +27,17 @@ export namespace LSPServer { ".mts", ".cts", ], - initialization: { - tsserver: { - path: require.resolve("typescript/lib/tsserver.js"), - }, + async initialization(app) { + const path = Bun.resolve( + "typescript/lib/tsserver.js", + app.path.cwd, + ).catch(() => {}) + if (!path) return {} + return { + tsserver: { + path, + }, + } }, async spawn() { const root =