Skip to main content
OpenCode integrates with your Language Server Protocol (LSP) servers to help the LLM interact with your codebase. It uses diagnostics to provide feedback to the LLM, enabling intelligent code understanding and error detection.

Built-in LSP Servers

OpenCode comes with several built-in LSP servers for popular languages: LSP servers are automatically enabled when one of the above file extensions are detected and the requirements are met.
You can disable automatic LSP server downloads by setting the OPENCODE_DISABLE_LSP_DOWNLOAD environment variable to true.

How It Works

When OpenCode opens a file, it:
1

Detect file extension

Checks the file extension against all enabled LSP servers.
2

Start LSP server

Starts the appropriate LSP server if not already running.
3

Provide diagnostics

The LSP server provides real-time diagnostics and code intelligence to the LLM.

Configuration

You can customize LSP servers through the lsp section in your OpenCode config.
opencode.json
Each LSP server supports the following properties:

Environment Variables

Use the env property to set environment variables when starting the LSP server:
opencode.json

Initialization Options

Use the initialization property to pass initialization options to the LSP server. These are server-specific settings sent during the LSP initialize request:
opencode.json
Initialization options vary by LSP server. Check your LSP server’s documentation for available options.

Disabling LSP Servers

To disable all LSP servers globally, set lsp to false:
opencode.json
To disable a specific LSP server, set disabled to true:
opencode.json

Custom LSP Servers

You can add custom LSP servers by specifying the command and file extensions:
opencode.json

Additional Information

PHP Intelephense

PHP Intelephense offers premium features through a license key. You can provide a license key by placing (only) the key in a text file at:
  • On macOS/Linux: $HOME/intelephense/license.txt
  • On Windows: %USERPROFILE%/intelephense/license.txt
The file should contain only the license key with no additional content.

FAQ

You can check the status of LSP servers by examining the diagnostics in your OpenCode session. Active LSP servers will provide real-time feedback on errors and warnings in your code.
Yes, OpenCode can run multiple LSP servers for the same file if their extension patterns match. For example, both typescript and eslint can run for .ts files.
If an LSP server fails to start, OpenCode will log the error and mark the server as broken for that session. You can check your configuration and requirements to troubleshoot the issue.
Set the OPENCODE_DISABLE_LSP_DOWNLOAD environment variable to true. You’ll need to manually install any required LSP servers.