mirror of
https://github.com/sst/opencode.git
synced 2025-08-04 05:28:16 +00:00
wip: symbols for lsp
This commit is contained in:
parent
fa35407572
commit
c810b6d206
1 changed files with 25 additions and 1 deletions
|
@ -4,10 +4,34 @@ import { LSPClient } from "./client"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { LSPServer } from "./server"
|
import { LSPServer } from "./server"
|
||||||
import { Ripgrep } from "../file/ripgrep"
|
import { Ripgrep } from "../file/ripgrep"
|
||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
export namespace LSP {
|
export namespace LSP {
|
||||||
const log = Log.create({ service: "lsp" })
|
const log = Log.create({ service: "lsp" })
|
||||||
|
|
||||||
|
export const Symbol = z
|
||||||
|
.object({
|
||||||
|
name: z.string(),
|
||||||
|
kind: z.number(),
|
||||||
|
location: z.object({
|
||||||
|
uri: z.string(),
|
||||||
|
range: z.object({
|
||||||
|
start: z.object({
|
||||||
|
line: z.number(),
|
||||||
|
character: z.number(),
|
||||||
|
}),
|
||||||
|
end: z.object({
|
||||||
|
line: z.number(),
|
||||||
|
character: z.number(),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.openapi({
|
||||||
|
ref: "LSP.Symbol",
|
||||||
|
})
|
||||||
|
export type Symbol = z.infer<typeof Symbol>
|
||||||
|
|
||||||
const state = App.state(
|
const state = App.state(
|
||||||
"lsp",
|
"lsp",
|
||||||
async (app) => {
|
async (app) => {
|
||||||
|
@ -96,7 +120,7 @@ export namespace LSP {
|
||||||
client.connection.sendRequest("workspace/symbol", {
|
client.connection.sendRequest("workspace/symbol", {
|
||||||
query,
|
query,
|
||||||
}),
|
}),
|
||||||
)
|
).then((result) => result.flat() as LSP.Symbol[])
|
||||||
}
|
}
|
||||||
|
|
||||||
async function run<T>(
|
async function run<T>(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue