Config files
config.cpp support — a third language, covering config.cpp, config.cpp.disabled and mod.cpp (claimed by exact file name, so it never competes with C++ over .cpp). Highlighting, folding, brace matching, structure view, Find Usages and rename, plus the navigation that makes a config worth opening:
class X : Yresolves to Y’s declaration in any indexed config;requiredAddons[]jumps to that addon’sCfgPatchesclass — the mod load order, which exists nowhere else as a link;inputs,pictureandfiles[]resolve to the file or folder they name.
displayName="$STR_…" (or "#STR_…") and ghostIcon="set:… image:…" work through the existing stringtable and imageset providers (see String references).
Vanilla’s own configs are opt-in: add the unpacked game data (P:\DZ) to the roots, or the game’s Addons folder as a PBO root. From P:\DZ only its 207 configs are indexed, but they sit inside 24 GB of unpacked game that must be walked once, so the settings page warns before adding it. See Library roots.
The CfgMods defines[] of every indexed config, the project’s and its dependency mods’, feed #ifdef completion: see Completion.
Formatter
Formatter (Ctrl+Alt+L) for config.cpp and mod.cpp, indentation only, like the script one: spacing (scope=2; or scope = 2;, tabs aligning values included) and line breaks are left as written, and so is an array written on one line (units[]={};). One level deeper:
- the contents of a class body;
- the elements of an array initializer written over several lines (
requiredAddons[]=then{ … };), and of the arrays nested in it.
A closing } / };, and a { on a line of its own, line up with the line that opened them. #define and other preprocessor lines stay at the first column. Enter follows the same rules: after a class’s or an array’s {, the caret goes one level deeper.
Tabs by default, under Settings → Editor → Code Style → Enforce Config. The 207 vanilla configs on P:\DZ are written exactly this way (tabs, an array’s { on the line after its name, no spaces around =), and a test reformats every one of them and checks that no line moves. Lines holding only tabs come out empty, as IntelliJ does by default; tick Keep indents on empty lines under Tabs and Indents to keep them.
Undeclared base classes
Base class not declared in this scope reports class MyApple: Apple {} when no class Apple comes before it where Addon Builder looks. Navigation resolves Apple through every indexed config, so nothing looks wrong, but CfgConvert binarises one config.cpp at a time and refuses it: Undefined base class ‘Apple’. Its lookup, checked by binarising a config for each case:
- a class of that name, full or external (
class Apple;), declared before the derived class in the same body; one declared after it is not seen; - else the same in each enclosing body, before the enclosing class, up to the top of the file; a sibling section (
CfgWeaponsfor a class inCfgVehicles) is never searched; - else a class an enclosing class inherits from its base, so
class DamageSystem: DamageSystemworks insideclass MyApple: ApplewhenAppledeclares aDamageSystem, and fails whenAppleis onlyclass Apple;; - names ignore case.
Add ‘class Apple;’ inserts the external declaration at the top of the section, after the ones already there; applied to the whole file, it adds every missing one. It is offered only for a class directly in a top-level section such as CfgVehicles:
- Deeper, the missing base is usually a class the enclosing class’s base was meant to provide.
class Apple;added there would hide it rather than fix it. - At the top of the file,
class Apple;would name a top-levelApplethat nothing declares. The class belongs in a section.
Only config.cpp is checked, and only a base some indexed config declares: one found nowhere may be a dependency outside the roots. Not checked: what the game does with an unbinarised config.cpp under file patching.