prettier-plugin-kv3
v1.1.0
Published
A Prettier plugin for Valve KeyValues3 files
Maintainers
Readme
prettier-plugin-kv3
A Prettier plugin for Valve's text KeyValues3 format.
The plugin is written in TypeScript and publishes compiled ESM with type declarations.
It supports KV3 objects, arrays, scalar and typed values, quoted and multiline strings, headers, line comments, block comments, and trailing array commas.
Install
npm install --save-dev prettier prettier-plugin-kv3Add the plugin to your Prettier configuration:
{
"plugins": ["prettier-plugin-kv3"]
}For an ESM configuration file, the plugin also provides a default export:
import prettierPluginKv3 from "prettier-plugin-kv3";
export default {
plugins: [prettierPluginKv3],
};Prettier will infer the parser for .kv3 and .vsndevts files. For another
Source 2 extension that contains KV3, add an override:
{
"plugins": ["prettier-plugin-kv3"],
"overrides": [
{
"files": "*.vdata",
"options": {
"parser": "kv3"
}
}
]
}Then use Prettier normally:
npx prettier --write "**/*.{kv3,vsndevts}"Development
Compile the plugin with:
pnpm buildPackage releases can be published automatically from GitHub tags using npm Trusted Publishing. See RELEASING.md for the initial setup and release workflow.
The plugin respects Prettier's printWidth, tabWidth, and useTabs options.
API
import * as prettier from "prettier";
import kv3Plugin from "prettier-plugin-kv3";
const formatted = await prettier.format(source, {
parser: "kv3",
plugins: [kv3Plugin],
});