Paradox Language Features for Visual Studio Code
Origin
This is a fork of cwtools/cwtools-vscode. The original extension wrapped an F# language server from cwtools/cwtools. This fork ships the Rust engine from this repository's engine/ workspace.
Disclaimer
This extension is still in preview, it may not work, it may stop working at any time.
Make backups of your mod files.
Pre-release builds
Every push to main is published as a pre-release. Switch to it from the
extension's page in VS Code — Switch to Pre-Release Version — and VS Code
keeps you on that channel; the same builds are on Open VSX. Pre-releases take
the odd minor above the current stable one, so 3.5.x is the pre-release line
for stable 3.4.x.
The same builds are also attached to the
GitHub prereleases
for Linux, macOS, and Windows. Download the VSIX for your platform, then run
Extensions: Install from VSIX... in VS Code. The universal VSIX carries
every server binary.
Pre-releases are test builds and may break.
Supported games
- Stellaris
- Hearts of Iron IV
- Europa Universalis IV
- Europa Universalis V - in progress, help needed
- Imperator: Rome - outdated, help needed
- Crusader Kings II - partial
- Crusader Kings III - in progress, help needed
- Victoria 2 - in progress, help needed
- Victoria 3 - in progress, help needed
Features
- Immediate highlighting of syntax errors
- Autocomplete while you type, providing descriptions when available
- Tooltips on hover showing:
- Related localisation
- Documentation for that element
- Scope context at that position
- A wide range of validators for common, interface, and events, checking
- That required localisation keys are defined
- Existence of effects/triggers/modifiers
- Scope context for used effects/triggers/modifiers
- Usage of scripted effects/triggers
- Correct entries for weights/AI_chance/etc
- That event_targets are saved before they're used
- That referenced sprites and graphics files exist
- and a number of other specific validators
Usage
CWTools starts only when an opened workspace folder contains a descriptor.mod
file at its root. Descriptors inside nested folders (including test fixtures) do
not count. Standalone files, metadata-only mods, and vanilla folders do not start
the server. If you add a descriptor after activation, reload the VS Code window.
- Install this extension
- Open your mod folder directly, which should be within a folder containing the game name:
C:\Users\name\Documents\Paradox Interactive\Stellaris\mod\your_mod
- Set the
cwtools.cache.<game> setting (e.g. cwtools.cache.hoi4) to the game's install folder
- Edit files and watch syntax errors show up when you make mistakes
- Wait up to a minute for the extension to scan your mod and find errors
Multiple mods - workspace
If you have multiple mods that need to be loaded at once, use VS Code's multi-root workspace feature.
- Open your first mod
- Use "File", "Add folder to workspace" to add your next mod
- cwtools should reload including both mods and vanilla in context using correct mod load order
If you want to browse vanilla files, you can use the "CWTOOLS LOADED FILES" section in the Explorer tab.
Completion



Scope errors

Localisation error

Go to definition

Find all references

Background reindex
The extension periodically re-scans the whole workspace in the background, so files changed outside the editor and definitions moved between files don't go stale until you reload the window. The rescan is idle-gated: it waits until you stop typing before running. To force one immediately, run cwtools: Re-index workspace from the command palette. cwtools.backgroundReindex.intervalMinutes controls the interval (default 30; 0 disables the automatic pass) and cwtools.backgroundReindex.idleSeconds how long you have to be idle before a pass may start (default 15).
Graph view
The graph view draws entity references as a node graph you can pan, zoom, and click through to the source. cwtools: Show graph loads graph data from the bundled server, Set graph depth controls how many reference hops are included, and cwtools: Recreate graph from json opens a saved export. The live commands appear only when the running server advertises graph support.
Reporting a slow session
If the editor feels slow, turn on cwtools.profiling, reload the window, reproduce the slowdown, then run cwtools: Export profiling log and attach the file to an issue. It records per-phase timing and memory for the language server. Leave it off the rest of the time.
Theming
The extension ships its own TextMate grammar for the supported games, so syntax highlighting works out of the box. No second extension to install.
The grammars are vendored from cwtools/paradox-syntax (see scripts/sync_paradox_syntax.py to refresh them); the .cwt rules grammar is owned here. Themes live under extension/package/themes/. Every theme paints the full scope set from both grammars (game scripts and .cwt rule files) plus a generic baseline, so coloring is consistent whatever file you're in. Pick one with the Color Theme picker:
Highlighting runs off a single merged paradox grammar, with each game's keywords folded into it, so there are no separate per-game grammar files to keep in sync.
Themes also carry a semantic token layer from the language server, which paints the tokens a static grammar can't disambiguate. See Adding a theme for how to build a theme and what that layer covers.
Credits
The TextMate grammars under extension/package/syntaxes/ are vendored from the cwtools/paradox-syntax extension (Copyright (c) 2018 Thomas Boby, MIT). Original authors and contributors:
The bundled themes draw on the following:
cwtools-md-edition itself is a fork of
cwtools/cwtools-vscode maintained
by the Millennium Dawn mod team. The Rust
language server it drives began as
MillenniumDawn/cwtools, itself a
fork of cwtools/cwtools, and now lives in
this repo under engine/.
Links