feat: add GDScript (Godot Engine) language server support

Closes #1446. Adds Language.GDSCRIPT backed by a new TCPLanguageServer
that extends LanguageServerInterface directly — no intermediate transport
abstraction layer.

Changes:
- ls_process.py: adds TCPConnectionInfo dataclass and TCPLanguageServer,
  a LanguageServerInterface subclass that manages a TCP socket directly
  (mirroring how StdioLanguageServer manages a subprocess). Stop order
  closes the socket before the BufferedReader wrapper to avoid a deadlock
  where BufferedReader.close() blocks on its internal read lock while
  readline() holds it waiting for data.
- ls_config.py: adds Language.GDSCRIPT with .gd/.gdscript file matcher.
- language_servers/godot_language_server.py: GodotLanguageServer connects
  to the Godot editor's TCP LSP (port 6008, same for Godot 3 and 4),
  registers Godot-specific notification handlers, and performs the
  initialize/initialized handshake. Godot version is auto-detected from
  config_version in project.godot.
- docs: adds GDScript to the language support list and a dedicated setup
  guide covering prerequisites, setup steps, performance characteristics
  (no workspace/symbol support → first full scan is slow, disk cache
  persists across sessions), and known limitations.

Tested against Godot 4.6.1 on Linux (Fedora 41): TCP connection,
initialize handshake, textDocument/documentSymbol returning full symbol
tree, and clean shutdown in <1s.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Erik M JacobsandClaude Sonnet 4.6 committed 2026-05-12 16:20:54 -04:00
1 parent 70d939739a
commit 1ab1c460cb
5 files changed
+376

No files matched your search

@@ -71,6 +71,10 @@ Some languages require additional installations or setup steps, as noted.
(requires [.NET v8.0+](https://dotnet.microsoft.com/en-us/download/dotnet); uses FsAutoComplete/Ionide, which is auto-installed; for Homebrew .NET on macOS, set DOTNET_ROOT in your environment)
* **Fortran**
(requires installation of fortls: `pip install fortls`)
* **GDScript** (Godot Engine)
(requires the Godot editor to be running with its built-in LSP enabled — default on port 6008;
Serena connects over TCP and does not launch Godot itself;
see the [GDScript Setup Guide](../03-special-guides/godot_gdscript_setup_guide_for_serena) for details)
* **Go**
(requires installation of `gopls`)
* **Groovy**
@@ -0,0 +1,78 @@
# GDScript (Godot Engine) Setup Guide for Serena
This guide explains how to prepare a Godot project so that Serena can provide code intelligence for GDScript (`.gd`) files via Godot's built-in Language Server Protocol (LSP) support.
Unlike most language servers, Serena does **not** launch a separate LSP process for GDScript. Instead, Serena connects over TCP to the LSP server that the Godot editor itself runs while it is open. This means the Godot editor must already be running with your project loaded before you start Serena.
---
## Prerequisites
- Godot Engine 3.x or 4.x installed and available on your system.
- A Godot project with a `project.godot` file at the project root.
No additional language server needs to be installed — Godot ships with a built-in LSP server that is enabled by default.
---
## How It Works
When a Godot project is open in the editor, the editor listens for LSP connections on **TCP port 6008** (the same default for both Godot 3 and Godot 4). Serena connects to this port and communicates using standard LSP Content-Length framing.
Serena automatically detects which major version of Godot your project targets by reading the `config_version` field from `project.godot`:
- `config_version` ≥ 5 → Godot 4
- `config_version` = 4 → Godot 3
No additional configuration is needed for version detection.
---
## Setup Steps
1. Open your Godot project in the Godot editor and allow it to finish loading.
2. Verify that the built-in LSP is enabled (it is on by default):
- Go to **Editor → Editor Settings → Network → Language Server**
- Confirm **"Use Language Server"** is checked.
- Confirm the port is **6008** (the default).
3. Add `gdscript` to the `languages` list in your project's Serena configuration:
```yaml
# .serena/project.yml
languages:
- gdscript
```
4. Start Serena in your project root. Serena will connect to the already-running Godot editor automatically.
---
## Using Serena with GDScript
- Serena recognizes `.gd` and `.gdscript` files. The language identifier used in LSP communication is `gdscript`.
- The Godot editor must remain open for the entire Serena session. If the editor is closed, Serena will lose its connection and will need to be restarted once the editor is open again.
- On first use, you may see a brief delay while Serena establishes the TCP connection and the editor indexes your project files — this is expected.
---
## Performance Note
Godot's built-in LSP does not implement the `workspace/symbol` request (global symbol search across the whole project). As a result, when Serena performs a workspace-wide symbol search — for example, calling `find_symbol` without a `relative_path` — it must fall back to sending a `textDocument/documentSymbol` request for **every `.gd` file** in the project individually.
For large projects, this initial full-project scan can take **30–60 seconds or more**.
To mitigate this:
- **Pass `relative_path` whenever possible.** Narrowing a search to a specific file or subdirectory avoids scanning the entire workspace.
- **Let the first full scan complete.** Serena caches the results to disk after the initial scan. Subsequent Serena sessions will use the on-disk cache and start instantly.
---
## Known Limitations
| Limitation | Detail |
|---|---|
| No `workspace/symbol` support | Godot's LSP does not implement this request. All symbol lookups fall back to per-file `documentSymbol` requests, making the first full-project scan slow. |
| Editor must stay open | Serena requires the Godot editor to be running throughout the session. Closing the editor breaks the TCP connection; restart Serena after reopening the editor. |
| Slower workspace operations | `find_symbol` and `find_references` across the whole workspace are slower than for languages whose LSP servers support native workspace-wide queries. |
---
## Reference
- Godot LSP documentation: [https://docs.godotengine.org/en/stable/tutorials/editor/external_editor.html](https://docs.godotengine.org/en/stable/tutorials/editor/external_editor.html)
- GDScript language reference: [https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/)