Godot LSP Client
Query Godot's Language Server Protocol for code intelligence on GDScript projects.
Prerequisites
Godot must be running with LSP enabled:
godot --path /path/to/project --lsp-port 6005 --headless &
Default port: 6005 (Godot 3.x and 4.x)
Commands
Find Definition
Locate where a symbol is defined:
python scripts/godot_lsp.py --project-path <project> definition <file>:<line>:<char> python scripts/godot_lsp.py --project-path <project> definition <symbol-name>
Example:
python scripts/godot_lsp.py --project-path ~/Projects/metalball definition scripts/ball.gd:25:10 python scripts/godot_lsp.py --project-path ~/Projects/metalball definition BallPhysics
Get Hover Documentation
Retrieve inline documentation for symbol at cursor position:
python scripts/godot_lsp.py --project-path <project> hover <file>:<line>:<char>
Example:
python scripts/godot_lsp.py --project-path ~/Projects/metalball hover scripts/player.gd:15:8
Search Symbols
Find symbols (classes, functions, variables) across the entire workspace:
python scripts/godot_lsp.py --project-path <project> symbols <query>
Example:
python scripts/godot_lsp.py --project-path ~/Projects/metalball symbols Ball python scripts/godot_lsp.py --project-path ~/Projects/metalball symbols "func _ready"
Code Completion
Get autocomplete suggestions at cursor position:
python scripts/godot_lsp.py --project-path <project> completion <file>:<line>:<char>
Example:
python scripts/godot_lsp.py --project-path ~/Projects/metalball completion scripts/ball.gd:30:12
Position Format
Use file:line:character where:
- •file - path relative to project root (e.g.,
scripts/ball.gd) - •line - 1-indexed line number
- •character - 0-indexed column offset
Workflow Examples
Find where a class is defined:
- •Search symbols:
symbols BallPhysics - •Parse
location.uriandrangefrom response
Get documentation for a method:
- •Position cursor at method call
- •Run:
hover scripts/player.gd:20:15 - •Read
contents.valuemarkdown
Validate GDScript syntax:
- •Use
diagnostics scripts/ball.gd - •Check for errors/warnings in response
Troubleshooting
Connection refused:
- •Ensure Godot is running with
--lsp-port 6005 - •Check port availability:
lsof -i :6005
Empty responses:
- •LSP server may still be indexing files (wait 2-3 seconds after starting)
- •Verify file path is relative to project root
- •Confirm symbol exists in codebase
For detailed protocol reference: See references/lsp_quick_reference.md