UniScript VS Code extension
Language client for the Universe Studio UniScript LSP. Surfaces diagnostics,
completion, hover, go-to-definition, references, formatting, rename, and
code actions for .uniscript files in any VS Code-family window (Cursor /
VSCodium / etc).
Two transports are supported:
- stdio (default) — spawns the bundled standalone
uniscript-lsp.exe as
a child process. No Unity required. ~600 ms cold start, ~100 ms warm.
- tcp — connects to a manually-started server, typically the in-Unity
studio launched with
-startLsp -lspPort 6300. Useful when debugging the
server itself or working with a live editor session.
Server side lives in Assets/Modules/Lsp/ (linked into both transports) and
is documented in docs/ai/systems/uniscript-lsp.md.
One-time setup
cd tools/uniscript-vscode
npm install
npm run compile
npm run package:server # copies the published exe into server/
npm run package:server requires that tools/uniscript-lsp/publish/win-x64/uniscript-lsp.exe
exists — build it first with:
dotnet publish tools/uniscript-lsp/src/UniScriptLsp/UniScriptLsp.csproj \
-c Release -r win-x64 --self-contained true \
-p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true \
-p:PublishTrimmed=false -p:EnableCompressionInSingleFile=true \
-p:DebugType=embedded -o tools/uniscript-lsp/publish/win-x64
Running the extension
Two ways to load it.
Option A — dev host (F5, no install)
- Open
tools/uniscript-vscode/ in VS Code.
- Press F5. A new Extension Development Host window opens with the
extension loaded.
- In the dev host window, open a folder containing
.uniscript files (the
studio's LSP mirror workspace works; so does a plain repo with sample
files). Diagnostics should appear within ~500ms.
The dev host inherits tools/uniscript-vscode/server/uniscript-lsp.exe as
the bundled server. Run npm run package:server before pressing F5 if the
server hasn't been bundled yet.
Option B — install once into your normal VS Code
cd tools/uniscript-vscode
npx @vscode/vsce package # runs vscode:prepublish, produces .vsix with server/ included
code --install-extension uniscript-vscode-0.2.0.vsix
vscode:prepublish chains tsc and package:server, so the .vsix always
contains a fresh server.
Settings
| Setting |
Default |
Purpose |
uniscript.lsp.transport |
stdio |
stdio (spawn bundled exe) or tcp (connect to running server). |
uniscript.lsp.serverPath |
(empty) |
Stdio only. Path to a custom uniscript-lsp.exe. Empty = bundled server. |
uniscript.lsp.host |
127.0.0.1 |
TCP only. Server bind is loopback-only. |
uniscript.lsp.port |
6300 |
TCP only. Match -lspPort. |
uniscript.lsp.projectPath |
(empty) |
Absolute project path, project UUID, or relative-to-workspace path. Empty → server uses its -lspProject flag. |
uniscript.lsp.autoStart |
true |
Connect on activation. |
uniscript.lsp.connectRetryMs |
500 |
TCP only. Initial-connect retry interval. |
uniscript.lsp.connectTimeoutMs |
30000 |
TCP only. Total retry budget before giving up. |
TCP transport (in-Unity)
"<install>/Universe Studio.exe" -startLsp -lspPort 6300 -lspProject <projectId-or-absolute-path>
Add -batchmode -nographics if you want a window-less host (the editor scene
still loads otherwise — see docs/ai/systems/uniscript-lsp.md §Known limits).
The studio writes a mirror workspace to:
<persistentDataPath>/lsp-workspaces/<projectName>/
├── scripts/ (writable, mirrored from project items)
│ ├── Player.uniscript
│ └── …
└── framework/ (read-only, from framework UniBundle)
├── UniObject.uniscript
└── …
Open that directory in VS Code, not the raw projects/<uid>/<projectId>/
folder. The mirror is what the LSP server treats as the workspace root.
On Windows the default is:
C:\Users\<user>\AppData\LocalLow\4GEN\Universe Studio\lsp-workspaces\<projectName>\
Commands
- UniScript: Connect to LSP — manual start.
- UniScript: Disconnect from LSP — graceful shutdown notification.
- UniScript: Restart LSP connection — for after a studio / server restart.
Smoke check
If diagnostics never arrive, sanity-check the server first.
TCP (in-Unity or standalone TCP mode):
cd tools/lsp-test
npm run smoke -- --port 6300 --projectPath "<absolute project path>"
stdio (standalone exe, no Unity):
cd tools/lsp-test
npm run smoke:stdio -- --projectPath "<projectId>"
# --exe defaults to tools/uniscript-lsp/publish/win-x64/uniscript-lsp.exe
Both clients speak the same wire protocol — if smoke works and the extension
doesn't, the bug is in this extension; if neither works, the server isn't
running / responding.
Known limits
Inherited from the server:
- One client at a time. Reconnect via UniScript: Restart.
- Studio's
RuntimeCompiler is shared with the Harness — don't run a
harness compile during LSP diagnostics if you're on the TCP/in-Unity path.
- Framework bundle visibility under stdio: when the standalone is launched
by VS Code with
-stdio, only the explicitly opened .uniscript files and
their workspace mirror are visible. Bundles installed into a project
via the studio's asset store are surfaced through the project mirror as
usual; bundles consumed outside a Universe Studio project are not.