Skip to content

About

A plugin for dprint to format WebAssembly Text Format files via wat_formatter

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

dprint-plugin-wat

npm version CI

Adapter for wat_formatter for use as a formatting plugin in dprint. It formats WebAssembly Text Format files (.wat).

Install

Install and setup dprint.

Then in your project's directory with a dprint.json file, run:

dprint add wat

Note: You do not need wasm-language-tools installed as dprint will run wat_formatter from the .wasm file in a sandboxed environment.

Configuration

To add configuration, specify a "wat" key in your dprint.json:

{
  "wat": {
    "lineWidth": 100,
    "indentWidth": 4,
    "splitClosingParens": true,
    "multiLineLocals": "always",
  },
  "plugins": [
    // ...etc...
  ],
}

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 Formatting API

Versioning

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.

License

This project is licensed under the MIT License - see the LICENSE file for details. wat_formatter is licensed under the MIT License as well.

About

A plugin for dprint to format WebAssembly Text Format files via wat_formatter

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages