Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions packages/opencode/src/tool/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export const Parameters = Schema.Struct({
character: Schema.Number.check(Schema.isInt())
.check(Schema.isGreaterThanOrEqualTo(1))
.annotate({ description: "The character offset (1-based, as shown in editors)" }),
query: Schema.optional(Schema.String).annotate({
description: "Search query for workspaceSymbol. Empty string requests all symbols.",
}),
})

export const LspTool = Tool.define(
Expand All @@ -40,7 +43,7 @@ export const LspTool = Tool.define(
description: DESCRIPTION,
parameters: Parameters,
execute: (
args: { operation: (typeof operations)[number]; filePath: string; line: number; character: number },
args: Schema.Schema.Type<typeof Parameters>,
ctx: Tool.Context,
) =>
Effect.gen(function* () {
Expand Down Expand Up @@ -89,7 +92,7 @@ export const LspTool = Tool.define(
case "documentSymbol":
return lsp.documentSymbol(uri)
case "workspaceSymbol":
return lsp.workspaceSymbol("")
return lsp.workspaceSymbol(args.query ?? "")
case "goToImplementation":
Comment thread
Hona marked this conversation as resolved.
return lsp.implementation(position)
case "prepareCallHierarchy":
Expand Down
7 changes: 6 additions & 1 deletion packages/opencode/src/tool/lsp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Supported operations:
- findReferences: Find all references to a symbol
- hover: Get hover information (documentation, type info) for a symbol
- documentSymbol: Get all symbols (functions, classes, variables) in a document
- workspaceSymbol: Search for symbols across the entire workspace
- workspaceSymbol: List project-wide symbols matching a query string
- goToImplementation: Find implementations of an interface or abstract method
- prepareCallHierarchy: Get call hierarchy item at a position (functions/methods)
- incomingCalls: Find all functions/methods that call the function at a position
Expand All @@ -16,4 +16,9 @@ All operations require:
- line: The line number (1-based, as shown in editors)
- character: The character offset (1-based, as shown in editors)

workspaceSymbol also accepts:
- query: A query string to filter symbols by. Empty string requests all symbols.

For workspaceSymbol, filePath is not sent in the LSP workspace/symbol request. It is used by opencode to select and start the matching LSP server.

Note: LSP servers must be configured for the file type. If no server is available, an error will be returned.
Loading