OpenCode integrates with Language Server Protocol (LSP) servers for code intelligence. Diagnostics feed back into the LLM after every file edit, and the lsp tool gives the agent access to go-to-definition, find-references, hover, and more.
Built-in servers are auto-detected based on file extensions in your project. If the binary is not found on your PATH, OpenCode can auto-install it.
| Server | Extensions | Install Method | Requirements |
|---|---|---|---|
| gopls | .go |
go install |
go on PATH |
| typescript-language-server | .ts .tsx .js .jsx .mjs .cjs .mts .cts |
npm | npm on PATH |
| bash-language-server | .sh .bash .zsh .ksh |
npm | npm on PATH |
| yaml-language-server | .yaml .yml |
npm | npm on PATH |
| vue-language-server | .vue |
npm | npm on PATH |
| svelte-language-server | .svelte |
npm | npm on PATH |
| astro-ls | .astro |
npm | npm on PATH |
| pyright | .py |
npm | npm on PATH |
| intelephense | .php |
npm | npm on PATH |
| lua-language-server | .lua |
GitHub release | — |
| terraform-ls | .tf .tfvars |
GitHub release | — |
| tinymist | .typ .typc |
GitHub release | — |
| rust-analyzer | .rs |
— | Pre-installed |
| clangd | .c .cpp .cc .cxx .c++ .h .hpp .hh .hxx .h++ |
— | Pre-installed |
| dart | .dart |
— | dart on PATH |
| zls | .zig .zon |
— | Pre-installed |
| ocamllsp | .ml .mli |
— | Pre-installed |
| nixd | .nix |
— | Pre-installed |
| haskell-language-server | .hs .lhs |
— | Pre-installed |
| gleam | .gleam |
— | gleam on PATH |
| sourcekit-lsp | .swift |
— | Xcode / Swift |
| kotlin-lsp | .kt .kts |
— | Pre-installed |
| clojure-lsp | .clj .cljs .cljc .edn |
— | Pre-installed |
| elixir-ls | .ex .exs |
— | elixir on PATH |
| jdtls | .java |
— | Java SDK 21+ |
| ruby-lsp | .rb .rake .gemspec .ru |
— | ruby on PATH |
| csharp-ls | .cs |
— | .NET SDK |
| fsautocomplete | .fs .fsi .fsx .fsscript |
— | .NET SDK |
| prisma | .prisma |
— | Pre-installed |
| metals | .scala |
— | Pre-installed |
Install methods:
go install— usesgo install pkg@latestwithGOBIN=~/.opencode/bin/- npm — uses
npm install --prefix ~/.opencode/bin/ <package> - GitHub release — downloads platform-specific binary from GitHub releases to
~/.opencode/bin/ - — — must be pre-installed on your system PATH
When OpenCode starts, it:
- Merges the built-in server registry with your config overrides
- For each enabled server, resolves the binary (system PATH →
~/.opencode/bin/→ auto-install) - Starts the LSP server process and initializes it
After each file mutation (edit, write, patch), OpenCode:
- Notifies the LSP server of the change
- Waits for updated diagnostics (up to 5 seconds)
- Includes errors and warnings in the tool response so the LLM can fix them
The lsp tool provides code-navigation operations:
| Operation | Description |
|---|---|
goToDefinition |
Find where a symbol is defined |
findReferences |
Find all references to a symbol |
hover |
Get type info and documentation |
documentSymbol |
List all symbols in a file |
workspaceSymbol |
Search symbols across the workspace |
goToImplementation |
Find interface implementations |
prepareCallHierarchy |
Get call hierarchy item at a position |
incomingCalls |
Find all callers of a function |
outgoingCalls |
Find all callees of a function |
Configure LSP servers in .opencode.json under the lsp key:
{
"lsp": {
"gopls": {
"initialization": {
"codelenses": { "test": true, "tidy": true }
}
}
}
}Each server supports:
| Property | Type | Description |
|---|---|---|
disabled |
boolean |
Disable this server |
command |
string |
Override the server command |
args |
string[] |
Command arguments |
extensions |
string[] |
File extensions to handle |
env |
object |
Environment variables |
initialization |
object |
LSP initialization options (server-specific) |
{
"lsp": {
"typescript": { "disabled": true }
}
}{
"lsp": {
"my-lsp": {
"command": "my-lsp-server",
"args": ["--stdio"],
"extensions": [".custom"]
}
}
}{
"lsp": {
"gopls": {
"command": "/usr/local/bin/gopls",
"env": { "GOFLAGS": "-mod=vendor" }
}
}
}{
"lsp": {
"typescript": {
"initialization": {
"preferences": {
"importModuleSpecifierPreference": "relative"
}
}
}
}
}To prevent OpenCode from downloading LSP server binaries:
Via config:
{
"disableLSPDownload": true
}Via environment variable:
export OPENCODE_DISABLE_LSP_DOWNLOAD=trueWhen disabled, only servers already on your system PATH or in ~/.opencode/bin/ are used. Missing servers are silently skipped.