From 1cb74be43d1777c4e463ba847ba2a479ab11c910 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" Date: Mon, 22 Dec 2025 08:13:27 +0000 Subject: [PATCH] Added docs for experimental LSP tool --- packages/web/src/content/docs/cli.mdx | 1 + packages/web/src/content/docs/lsp.mdx | 28 +++++++++++++++++++++++++ packages/web/src/content/docs/tools.mdx | 23 ++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/packages/web/src/content/docs/cli.mdx b/packages/web/src/content/docs/cli.mdx index c13712d10..f104bfa00 100644 --- a/packages/web/src/content/docs/cli.mdx +++ b/packages/web/src/content/docs/cli.mdx @@ -329,3 +329,4 @@ These environment variables enable experimental features that may change or be r | `OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX` | number | Max output tokens for LLM responses | | `OPENCODE_EXPERIMENTAL_FILEWATCHER` | boolean | Enable file watcher for entire dir | | `OPENCODE_EXPERIMENTAL_OXFMT` | boolean | Enable oxfmt formatter | +| `OPENCODE_EXPERIMENTAL_LSP_TOOL` | boolean | Enable experimental LSP tool | diff --git a/packages/web/src/content/docs/lsp.mdx b/packages/web/src/content/docs/lsp.mdx index df97dc3ff..7178eb4f8 100644 --- a/packages/web/src/content/docs/lsp.mdx +++ b/packages/web/src/content/docs/lsp.mdx @@ -49,6 +49,34 @@ You can disable automatic LSP server downloads by setting the `OPENCODE_DISABLE_ --- +## LLM Tool (Experimental) + +OpenCode includes an experimental built-in tool named `lsp` that lets the LLM query your LSP servers for code navigation and symbol information. + +To enable it, set `OPENCODE_EXPERIMENTAL_LSP_TOOL=true` (or `OPENCODE_EXPERIMENTAL=true` to enable all experimental features). + +Once enabled, you can still disable it via your `tools` config: + +```json title="opencode.json" +{ + "$schema": "https://opencode.ai/config.json", + "tools": { + "lsp": false + } +} +``` + +Example prompts: + +- "Use the lsp tool to go to definition of `createServer` in `src/server.ts` at line 12, character 5." +- "Use lsp hover on `User` in `src/models/user.ts` at line 20, character 10." + +:::note +The `lsp` tool only works when an LSP server is available for the file type. +::: + +--- + ## How It Works When opencode opens a file, it: diff --git a/packages/web/src/content/docs/tools.mdx b/packages/web/src/content/docs/tools.mdx index dd678569e..0f5b0b351 100644 --- a/packages/web/src/content/docs/tools.mdx +++ b/packages/web/src/content/docs/tools.mdx @@ -213,6 +213,29 @@ This tool lists directory contents. It accepts glob patterns to filter results. --- +### lsp (experimental) + +Interact with your configured LSP servers to get code intelligence features like definitions, references, hover info, and call hierarchy. + +:::note +This tool is only available when `OPENCODE_EXPERIMENTAL_LSP_TOOL=true` (or `OPENCODE_EXPERIMENTAL=true`). +::: + +```json title="opencode.json" {4} +{ + "$schema": "https://opencode.ai/config.json", + "tools": { + "lsp": true + } +} +``` + +Supported operations include `goToDefinition`, `findReferences`, `hover`, `documentSymbol`, `workspaceSymbol`, `goToImplementation`, `prepareCallHierarchy`, `incomingCalls`, and `outgoingCalls`. + +To configure which LSP servers are available for your project, see [LSP Servers](/docs/lsp). + +--- + ### patch Apply patches to files.