A bridge script that enables GDScript Language Server Protocol (LSP) support in OpenCode for Godot Engine development.
Disclaimer: This is an independent community project and is not affiliated with, endorsed by, or officially associated with the OpenCode project or its maintainers. This bridge script is provided as-is to help the community use GDScript LSP with OpenCode.
OpenCode's LSP integration expects servers to communicate via stdio (standard input/output), but Godot's GDScript LSP server communicates via TCP. Additionally, the LSP server is built into the Godot Editor and requires the editor to be running.
This bridge script:
- Automatically launches Godot in headless mode (no visible window) with LSP enabled
- Bridges stdio ↔ TCP communication between OpenCode and Godot's LSP server
- Works cross-platform (Windows, Linux, macOS)
- Node.js (v14 or higher) or Bun (v1.0 or higher)
- Godot Engine 4.4.1+ (recommended for best headless support)
- OpenCode CLI
If running on Linux without a display server (e.g., WSL, CI, headless server):
sudo apt install xvfbThere are multiple ways to install the bridge script:
# Global installation with npm
npm install -g opencode-godot-lsp
# Or with Bun
bun add -g opencode-godot-lspAfter installation, configure OpenCode to use the globally installed command:
You can run directly without installing:
{
"lsp": {
"gdscript": {
"command": ["npx", "opencode-godot-lsp"],
"extensions": [".gd", ".gdshader"]
}
}
}Or with Bun:
{
"lsp": {
"gdscript": {
"command": ["bunx", "opencode-godot-lsp"],
"extensions": [".gd", ".gdshader"]
}
}
}Clone this repository or download godot-lsp-bridge.js:
# Clone the repository
git clone https://github.com/MasuRii/opencode-godot-lsp.git
# Or download just the script
curl -O https://raw.githubusercontent.com/MasuRii/opencode-godot-lsp/main/godot-lsp-bridge.jsPut godot-lsp-bridge.js somewhere accessible. Common locations:
| OS | Recommended Path |
|---|---|
| Windows | C:\Users\<USERNAME>\.config\opencode\scripts\godot-lsp-bridge.js |
| Linux/macOS | ~/.config/opencode/scripts/godot-lsp-bridge.js |
Add the following to your opencode.jsonc configuration file:
{
// ... other configuration ...
"lsp": {
"gdscript": {
"command": ["node", "C:/Users/YOUR_USERNAME/.config/opencode/scripts/godot-lsp-bridge.js"],
"extensions": [".gd", ".gdshader"]
}
}
}{
// ... other configuration ...
"lsp": {
"gdscript": {
"command": ["node", "/home/YOUR_USERNAME/.config/opencode/scripts/godot-lsp-bridge.js"],
"extensions": [".gd", ".gdshader"]
}
}
}If Godot isn't in your PATH or you have multiple versions:
# Windows (PowerShell)
$env:GODOT_PATH = "C:\Path\To\Godot\godot.exe"
# Linux/macOS
export GODOT_PATH="/path/to/godot"Once configured, OpenCode will automatically:
- Detect when you're working in a Godot project (looks for
project.godot) - Launch Godot in headless mode with LSP enabled
- Provide code intelligence features for
.gdand.gdshaderfiles
- Autocomplete - Intelligent code completion for GDScript
- Go to Definition - Jump to function/variable definitions
- Hover Documentation - View inline documentation
- Diagnostics - Real-time error and warning detection
- Symbol Search - Find symbols across your project
The bridge script accepts several options:
# If installed globally via npm/bun
godot-lsp-bridge [options]
# If running via npx/bunx
npx opencode-godot-lsp [options]
bunx opencode-godot-lsp [options]
# If running manually
node godot-lsp-bridge.js [options]
Options:
--port <port> LSP server port (default: 6005)
--host <host> LSP server host (default: 127.0.0.1)
--godot <path> Path to Godot executable
--project <path> Path to Godot project directoryUsing global installation:
{
"lsp": {
"gdscript": {
"command": [
"godot-lsp-bridge",
"--port", "6008",
"--godot", "/custom/path/to/godot"
],
"extensions": [".gd", ".gdshader"]
}
}
}Using npx:
{
"lsp": {
"gdscript": {
"command": [
"npx",
"opencode-godot-lsp",
"--port", "6008",
"--godot", "/custom/path/to/godot"
],
"extensions": [".gd", ".gdshader"]
}
}
}Using manual installation:
{
"lsp": {
"gdscript": {
"command": [
"node",
"/path/to/godot-lsp-bridge.js",
"--port", "6008",
"--godot", "/custom/path/to/godot"
],
"extensions": [".gd", ".gdshader"]
}
}
}┌─────────────┐ stdio ┌──────────────────┐ TCP ┌─────────────────┐
│ OpenCode │ ◄───────────► │ godot-lsp-bridge │ ◄──────────► │ Godot Editor │
│ (Client) │ │ (Bridge) │ :6005 │ (LSP Server) │
└─────────────┘ └──────────────────┘ └─────────────────┘
- OpenCode spawns the bridge script via the configured command
- The bridge checks if Godot LSP is already running on the specified port
- If not, it launches Godot in headless mode with
--editor --headless --lsp-port - The bridge connects to Godot's TCP LSP server
- All LSP messages are proxied between OpenCode (stdio) and Godot (TCP)
-
Check Godot version: Requires Godot 4.x (4.4.1+ recommended)
godot --version
-
Verify project.godot exists: The bridge searches for this file to locate your project
-
Check the port: Ensure port 6005 (or your configured port) isn't already in use
# Windows netstat -an | findstr 6005 # Linux/macOS lsof -i :6005
Set the GODOT_PATH environment variable or use the --godot flag:
# In your shell profile (.bashrc, .zshrc, etc.)
export GODOT_PATH="/path/to/godot"Or modify your OpenCode config:
{
"lsp": {
"gdscript": {
"command": ["node", "/path/to/godot-lsp-bridge.js", "--godot", "/path/to/godot"],
"extensions": [".gd", ".gdshader"]
}
}
}Install Xvfb for headless operation:
sudo apt install xvfbThe bridge will automatically use xvfb-run when no DISPLAY is available.
- Increase the timeout by modifying the script (look for
40iterations × 500ms = 20 seconds) - Check if Godot launches correctly by running manually:
godot --editor --headless --lsp-port 6005 --path /your/project
Using npm global installation (recommended):
{
// ═══════════════════════════════════════════════════════════════════════════
// LSP SERVERS CONFIGURATION
// Language Server Protocol integrations for enhanced code intelligence
// ═══════════════════════════════════════════════════════════════════════════
"lsp": {
// GDScript LSP for Godot Engine development
// Note: Requires Godot Editor (launched automatically in headless mode)
// The bridge script converts stdio (OpenCode) to TCP (Godot's LSP)
"gdscript": {
"command": ["godot-lsp-bridge"],
"extensions": [".gd", ".gdshader"]
}
}
}Using manual installation:
{
"lsp": {
"gdscript": {
"command": ["node", "C:/Users/YOUR_USERNAME/.config/opencode/scripts/godot-lsp-bridge.js"],
"extensions": [".gd", ".gdshader"]
}
}
}| Variable | Description | Default |
|---|---|---|
GODOT_PATH |
Path to Godot executable | Searches common locations |
GODOT_PROJECT |
Path to Godot project | Current working directory |
- Requires Godot Editor: The GDScript LSP server is built into the editor binary and cannot run standalone
- Single Project: Each bridge instance connects to one project; for multiple projects, configure separate bridges
- Startup Time: First connection may take 10-20 seconds as Godot initializes
Contributions are welcome! Please feel free to submit issues or pull requests.
MIT License - See LICENSE for details.
- Godot Engine - The amazing open-source game engine
- OpenCode - AI-powered terminal coding assistant (this project is not affiliated with OpenCode)
- Godot community for documentation on headless LSP operation
This project is an independent community contribution and is not affiliated with, endorsed by, or officially associated with the OpenCode project, OpenCode AI, or any of their maintainers. The use of the name "OpenCode" is solely to indicate compatibility with that software.
{ "lsp": { "gdscript": { "command": ["godot-lsp-bridge"], "extensions": [".gd", ".gdshader"] } } }