/cdda-json-formatter-vscode-extension

VS Code extension to format Cataclysm DDA JSON files

Primary LanguageTypeScriptOtherNOASSERTION

Cataclysm DDA JSON Formatter

This is an extension for VS Code, when enabled this will format json files according to the JSON style of data files for Cataclysm DDA project.

Installation

One of:

Using

When using default VS Code configuration this extension will be plug and play; enabling the extension will default to this formatter for JSON files and enable format-on-save feature. Saving a JSON file or executing a Format Document command will format current file to the JSON format required for Cataclysm DDA project's data files.

If using non-default overrides you'll have to set this formatter manually, e.g. via editor.defaultFormatter setting in user/workspace/folder settings.

Restarting VS Code should usually resolve any temporary issues.

Demo

Save file hotkey or Format Document triggers the formatter:

2023-06-27_21-53-24.mp4

Compiling

To compile or debug dev containers can be used, a guide on how to get started with dev containers can be found in VS Code docs. For a short pick me up guide: install "Docker Desktop for [Your OS]", install the Dev Containers extension in VS and you're good to go.

Once VS Code is set up with dev containers you can clone the repository and open the folder in VS Code. A window should popup offering to "Reopen in container", confirm; once it finishes setting up the container (this also runs npm install inside the container), you can press F5; another VS Code instance will pop up that'll have the extension running under the Extension Host debugger.

An npm package in dependencies handles the formatting, it has the C++ formatter parts from Cataclysm-DDA compiled to javascript with emscripten:

https://github.com/cdda-toys/cdda-json-formatter-emscripten/blob/master/.github/workflows/build.yml

License

Keep in mind the license is non-trivial - see LICENSE.txt: