Adapter for wat_formatter for use as a formatting plugin in dprint. It formats WebAssembly Text Format files (.wat).
Then in your project's directory with a dprint.json file, run:
dprint add watNote: You do not need wasm-language-tools installed as dprint will run wat_formatter from the .wasm file in a sandboxed environment.
To add configuration, specify a "wat" key in your dprint.json:
The options and their defaults match wat_formatter's, with dprint's names for the common ones:
| dprint | wat_formatter | Default |
|---|---|---|
lineWidth |
print_width |
80 |
useTabs |
use_tabs |
false |
indentWidth |
indent_width |
2 |
newLineKind |
line_break |
"lf" |
splitClosingParens |
split_closing_parens |
false |
wrapBeforeLocals |
wrap_before_locals |
"always" |
wrapBeforeFields |
wrap_before_fields |
"multiOnly" |
wrapBeforeConstExpr |
wrap_before_const_expr |
"always" |
multiLineLocals |
multi_line_locals |
"smart" |
multiLineFields |
multi_line_fields |
"smart" |
formatComments |
format_comments |
false |
ignoreCommentDirective |
ignore_comment_directive |
"fmt-ignore" |
Option values are camelCase versions of wat_formatter's (ex. "multi-only" is "multiOnly"). Since the defaults are wat_formatter's, the global lineWidth, useTabs, indentWidth and newLineKind in your dprint.json are used when they're set and wat_formatter's defaults otherwise.
A ;; fmt-ignore comment keeps the module or module field after it as it is, and range formatting is supported. A file with a syntax error is reported as an error rather than formatted.
For an overview of the config, see https://github.com/dprint/dprint-plugin-wat/blob/main/deployment/schema.json
- JS Formatter - Browser/Deno and Node
- npm package
This repo automatically upgrades to the latest version of wat_formatter once a day. You can check which version of wat_formatter is being used by looking at the wat_formatter entry in the Cargo.toml file in this repo:
https://github.com/dprint/dprint-plugin-wat/blob/main/Cargo.toml
At the moment, the version of this plugin does not reflect the version of wat_formatter.
This project is licensed under the MIT License - see the LICENSE file for details. wat_formatter is licensed under the MIT License as well.
{ "wat": { "lineWidth": 100, "indentWidth": 4, "splitClosingParens": true, "multiLineLocals": "always", }, "plugins": [ // ...etc... ], }