ITADN
apcamargo/dprint-plugin-typstyle
apcamargo/dprint-plugin-typstyle · 文件
文件最后提交记录最后更新时间
README.md

dprint-plugin-typstyle

CI

Adapter plugin for dprint that formats Typst files via Typstyle.

Install

Add the plugin release URL to your dprint.json:

{
  "typstyle": {
    // typstyle's config goes here
  },
  "plugins": [
    "https://plugins.dprint.dev/apcamargo/typstyle-0.1.0.wasm"
  ]
}

Configuration

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

{
  "typstyle": {
    "lineWidth": 100,
    "indentWidth": 2,
    "blankLinesUpperBound": 1,
    "collapseMarkupSpaces": false,
    "reorderImportItems": true,
    "wrapMode": "none",
    "lineEnding": "lf",
  },
  "plugins": [
    // ...etc...
  ]
}

Properties

PropertyTypeDefaultDescription
lineWidthinteger80Maximum width of each line. Minimum 1.
indentWidthinteger2Number of spaces per indentation level. Minimum 0.
blankLinesUpperBoundinteger1Maximum number of consecutive blank lines preserved. Minimum 0.
collapseMarkupSpacesbooleanfalseCollapse consecutive whitespace in markup into a single space.
reorderImportItemsbooleantrueSort the items of an import statement alphabetically.
wrapModestring"none"Text wrapping mode: "none" (do not wrap text), "fill" (wrap text to fit within line width), or "sentence" (place each sentence on its own line).
lineEndingstring"lf"The line ending style to use when writing files: "lf" (line feed) or "crlf" (carriage return, line feed).

Versioning

This plugin is released independently from Typstyle. The version of typstyle-core used by the plugin is listed in Cargo.toml and is checked for updates by this repository's monthly update workflow.

Development

Build and test locally:

# Run unit and spec tests
cargo test

# Run clippy checks
cargo clippy --all-targets --all-features -- -D warnings

# Build Wasm module
rustup target add wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknown --features wasm --release