2025-07-01 16:06:38 +00:00
|
|
|
import { LSP } from "../../../lsp"
|
|
|
|
|
import { bootstrap } from "../../bootstrap"
|
|
|
|
|
import { cmd } from "../cmd"
|
|
|
|
|
import { Log } from "../../../util/log"
|
2025-10-28 20:38:08 +00:00
|
|
|
import { EOL } from "os"
|
2025-07-01 16:06:38 +00:00
|
|
|
|
|
|
|
|
export const LSPCommand = cmd({
|
|
|
|
|
command: "lsp",
|
2025-07-10 10:51:47 +00:00
|
|
|
builder: (yargs) =>
|
|
|
|
|
yargs.command(DiagnosticsCommand).command(SymbolsCommand).command(DocumentSymbolsCommand).demandCommand(),
|
2025-07-01 16:06:38 +00:00
|
|
|
async handler() {},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const DiagnosticsCommand = cmd({
|
|
|
|
|
command: "diagnostics <file>",
|
2025-07-07 19:53:43 +00:00
|
|
|
builder: (yargs) => yargs.positional("file", { type: "string", demandOption: true }),
|
2025-07-01 16:06:38 +00:00
|
|
|
async handler(args) {
|
2025-09-01 21:15:49 +00:00
|
|
|
await bootstrap(process.cwd(), async () => {
|
2025-07-01 16:06:38 +00:00
|
|
|
await LSP.touchFile(args.file, true)
|
2025-12-12 05:20:38 +00:00
|
|
|
await Bun.sleep(1000)
|
2025-10-28 20:38:08 +00:00
|
|
|
process.stdout.write(JSON.stringify(await LSP.diagnostics(), null, 2) + EOL)
|
2025-07-01 16:06:38 +00:00
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export const SymbolsCommand = cmd({
|
|
|
|
|
command: "symbols <query>",
|
2025-07-07 19:53:43 +00:00
|
|
|
builder: (yargs) => yargs.positional("query", { type: "string", demandOption: true }),
|
2025-07-01 16:06:38 +00:00
|
|
|
async handler(args) {
|
2025-09-01 21:15:49 +00:00
|
|
|
await bootstrap(process.cwd(), async () => {
|
2025-07-01 16:06:38 +00:00
|
|
|
using _ = Log.Default.time("symbols")
|
|
|
|
|
const results = await LSP.workspaceSymbol(args.query)
|
2025-10-28 20:38:08 +00:00
|
|
|
process.stdout.write(JSON.stringify(results, null, 2) + EOL)
|
2025-07-01 16:06:38 +00:00
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
})
|
2025-07-10 10:51:47 +00:00
|
|
|
|
|
|
|
|
export const DocumentSymbolsCommand = cmd({
|
|
|
|
|
command: "document-symbols <uri>",
|
|
|
|
|
builder: (yargs) => yargs.positional("uri", { type: "string", demandOption: true }),
|
|
|
|
|
async handler(args) {
|
2025-09-01 21:15:49 +00:00
|
|
|
await bootstrap(process.cwd(), async () => {
|
2025-07-10 10:51:47 +00:00
|
|
|
using _ = Log.Default.time("document-symbols")
|
|
|
|
|
const results = await LSP.documentSymbol(args.uri)
|
2025-10-28 20:38:08 +00:00
|
|
|
process.stdout.write(JSON.stringify(results, null, 2) + EOL)
|
2025-07-10 10:51:47 +00:00
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
})
|