Update LSP client/server and CLI scrap command functionality

🤖 Generated with [OpenCode](https://opencode.ai)

Co-Authored-By: OpenCode <noreply@opencode.ai>
This commit is contained in:
Dax Raad 2025-06-10 10:46:55 -04:00
parent 0e58f488df
commit 96b5a079ff
3 changed files with 17 additions and 11 deletions

View file

@ -1,6 +1,5 @@
import { App } from "../../app/app" import { App } from "../../app/app"
import { VERSION } from "../version" import { VERSION } from "../version"
import { LSP } from "../../lsp"
import { cmd } from "./cmd" import { cmd } from "./cmd"
export const ScrapCommand = cmd({ export const ScrapCommand = cmd({
@ -8,10 +7,9 @@ export const ScrapCommand = cmd({
builder: (yargs) => builder: (yargs) =>
yargs.positional("file", { type: "string", demandOption: true }), yargs.positional("file", { type: "string", demandOption: true }),
describe: "test command", describe: "test command",
async handler(args) { async handler() {
await App.provide({ cwd: process.cwd(), version: VERSION }, async () => { await App.provide({ cwd: process.cwd(), version: VERSION }, async (app) => {
await LSP.touchFile(args.file, true) Bun.resolveSync("typescript/lib/tsserver.js", app.path.cwd)
await LSP.diagnostics()
}) })
}, },
}) })

View file

@ -57,6 +57,7 @@ export namespace LSPClient {
}) })
connection.listen() connection.listen()
const initialization = await input.initialization?.(app)
await connection.sendRequest("initialize", { await connection.sendRequest("initialize", {
processId: server.pid, processId: server.pid,
workspaceFolders: [ workspaceFolders: [
@ -66,7 +67,7 @@ export namespace LSPClient {
}, },
], ],
initializationOptions: { initializationOptions: {
...input.initialization, ...initialization,
}, },
capabilities: { capabilities: {
workspace: { workspace: {

View file

@ -10,7 +10,7 @@ export namespace LSPServer {
export interface Info { export interface Info {
id: string id: string
extensions: string[] extensions: string[]
initialization?: Record<string, any> initialization?: (app: App.Info) => Promise<Record<string, any>>
spawn(app: App.Info): Promise<ChildProcessWithoutNullStreams | undefined> spawn(app: App.Info): Promise<ChildProcessWithoutNullStreams | undefined>
} }
@ -27,10 +27,17 @@ export namespace LSPServer {
".mts", ".mts",
".cts", ".cts",
], ],
initialization: { async initialization(app) {
tsserver: { const path = Bun.resolve(
path: require.resolve("typescript/lib/tsserver.js"), "typescript/lib/tsserver.js",
}, app.path.cwd,
).catch(() => {})
if (!path) return {}
return {
tsserver: {
path,
},
}
}, },
async spawn() { async spawn() {
const root = const root =