Skip to content

About

dprint plugin for Arity

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

dprint-plugin-arity

A dprint Wasm plugin that wraps the arity formatter for the R language (.R).

It is released independently of the main arity CLI. The plugin lives in its own repository so that its plugin.wasm release asset does not interfere with arity's own GitHub release stream, which the VS Code extension and the install scripts resolve platform binaries from.

Usage

Add the plugin with the dprint CLI:

dprint config add jolars/arity

This adds a versioned, checksummed entry under plugins in your dprint.json:

{
  "arity": {},
  "plugins": [
    "https://plugins.dprint.dev/jolars/arity-x.x.x.wasm@<checksum>"
  ]
}

Then format:

dprint fmt

Configuration

Configure under the arity key in dprint.json. Supported keys:

Key Values Default
lineWidth integer dprint global, else 80
indentWidth integer dprint global, else 2
lineEnding auto, lf, crlf, native from global newLineKind
roxygen boolean true
roxygenMarkdown boolean false

Arity always indents with spaces, so dprint's global useTabs has no effect. Set roxygen to false to preserve the source layout of #' blocks while formatting the surrounding R code, as with roxygen = false in arity.toml.

Arity formats R code with deterministic rules. See the arity docs for the formatting rules themselves.

roxygenMarkdown

Set this to true when the package enables roxygen markdown package-wide, i.e. when DESCRIPTION has:

Roxygen: list(markdown = TRUE)

The arity CLI discovers this on its own by reading DESCRIPTION and man/roxygen/meta.R. A dprint Wasm plugin cannot: dprint hands plugins the file path but the Wasm sandbox exposes no filesystem imports at all, so the setting has to be stated explicitly here. With it set, the plugin's output is byte-identical to arity format.

Per-block @md and @noMd tags still override this default, exactly as in the CLI, so a package that opts in per block needs no configuration.

Building

The plugin is only usable when built for wasm32-unknown-unknown:

cargo build --release --target wasm32-unknown-unknown

The resulting target/wasm32-unknown-unknown/release/dprint_plugin_arity.wasm is published as plugin.wasm on each GitHub release.

It also builds for the host target — generate_plugin_code! is gated to target_arch = "wasm32" — so cargo test can run the config, formatting, and schema tests natively. That native build is not a usable plugin.

License

MIT

About

dprint plugin for Arity

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages