Skip to content

Commit 6097d6a

Browse files
docs: experimental LSP tool (anomalyco#5943)
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
1 parent 09d2feb commit 6097d6a

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

packages/web/src/content/docs/cli.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,4 @@ These environment variables enable experimental features that may change or be r
329329
| `OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX` | number | Max output tokens for LLM responses |
330330
| `OPENCODE_EXPERIMENTAL_FILEWATCHER` | boolean | Enable file watcher for entire dir |
331331
| `OPENCODE_EXPERIMENTAL_OXFMT` | boolean | Enable oxfmt formatter |
332+
| `OPENCODE_EXPERIMENTAL_LSP_TOOL` | boolean | Enable experimental LSP tool |

packages/web/src/content/docs/lsp.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,34 @@ You can disable automatic LSP server downloads by setting the `OPENCODE_DISABLE_
5151

5252
---
5353

54+
## LLM Tool (Experimental)
55+
56+
OpenCode includes an experimental built-in tool named `lsp` that lets the LLM query your LSP servers for code navigation and symbol information.
57+
58+
To enable it, set `OPENCODE_EXPERIMENTAL_LSP_TOOL=true` (or `OPENCODE_EXPERIMENTAL=true` to enable all experimental features).
59+
60+
Once enabled, you can still disable it via your `tools` config:
61+
62+
```json title="opencode.json"
63+
{
64+
"$schema": "https://opencode.ai/config.json",
65+
"tools": {
66+
"lsp": false
67+
}
68+
}
69+
```
70+
71+
Example prompts:
72+
73+
- "Use the lsp tool to go to definition of `createServer` in `src/server.ts` at line 12, character 5."
74+
- "Use lsp hover on `User` in `src/models/user.ts` at line 20, character 10."
75+
76+
:::note
77+
The `lsp` tool only works when an LSP server is available for the file type.
78+
:::
79+
80+
---
81+
5482
## How It Works
5583

5684
When opencode opens a file, it:

packages/web/src/content/docs/tools.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,29 @@ This tool lists directory contents. It accepts glob patterns to filter results.
213213

214214
---
215215

216+
### lsp (experimental)
217+
218+
Interact with your configured LSP servers to get code intelligence features like definitions, references, hover info, and call hierarchy.
219+
220+
:::note
221+
This tool is only available when `OPENCODE_EXPERIMENTAL_LSP_TOOL=true` (or `OPENCODE_EXPERIMENTAL=true`).
222+
:::
223+
224+
```json title="opencode.json" {4}
225+
{
226+
"$schema": "https://opencode.ai/config.json",
227+
"tools": {
228+
"lsp": true
229+
}
230+
}
231+
```
232+
233+
Supported operations include `goToDefinition`, `findReferences`, `hover`, `documentSymbol`, `workspaceSymbol`, `goToImplementation`, `prepareCallHierarchy`, `incomingCalls`, and `outgoingCalls`.
234+
235+
To configure which LSP servers are available for your project, see [LSP Servers](/docs/lsp).
236+
237+
---
238+
216239
### patch
217240

218241
Apply patches to files.

0 commit comments

Comments
 (0)