Skip to main content

vsg-rs

A fast Rust-native VHDL formatter and style checker with VSG-compatible rules and configuration.

vsg-rs is an independent Rust implementation of a VHDL formatter and style checker that aims for compatibility with the rules and configuration of the VHDL Style Guide (VSG). It is not affiliated with, endorsed by, or maintained by the VHDL Style Guide project or its maintainers.

vsg-rs was inspired by the VHDL Style Guide (VSG) project by Jeremiah Leary and contributors. vsg-rs contains no VSG code; VSG is used only as a behavioural reference.

Status: beta. Formatting is tested against a corpus of more than 11,000 real-world files. 192 VSG rules are implemented as lint rules with fixes (structure, identifier case, naming, comments, length_001), and the other 779 layout rules are covered by the formatter's policy (blank lines, alignment, keyword case, indentation). Expect layout changes before 1.0.

Why

  • A real formatter. Formatting is not "run the lint rules and apply their fixes". Source is parsed once into a lossless syntax tree and printed in one canonical layout, like rustfmt or Black. Running it twice changes nothing.
  • Long lines are folded, not just reported. length_001 becomes a formatter capability: calls, maps, aggregates, expressions, conditions, declarations and assignments fold at structural boundaries (see docs/line-folding.md).
  • Safe for format-on-save. Every result is re-parsed and checked to contain exactly the same tokens and comments before it is used. Files with syntax errors are left untouched. In pipe mode, stdout carries nothing but the formatted source.
  • No fix phases. No --fix runs that must be repeated until they converge, and no rule-order dependencies. Fixes that could change behaviour are only applied on request (--unsafe-fixes).
  • Fast. Formatting a typical file from stdin takes a few milliseconds; parsing, formatting and verifying real-world VHDL runs at about 3.4 MB/s on one core, and files are processed in parallel (performance).

Usage

pip install vsg-rs                     # Linux and Windows wheels, Python 3.10+ (or: uv tool install vsg-rs)
cargo install --path .                 # from source

vsg-rs fmt src/                        # format files in place
vsg-rs fmt --check src/                # CI: exit 1 if anything would change
vsg-rs fmt --diff src/foo.vhd          # show what would change
vsg-rs fmt --line-length 100 src/
cat foo.vhd | vsg-rs fmt --stdin-filename foo.vhd -   # editor integration
cat foo.vhd | vsg-rs fmt --range 10:24 -              # only lines 10 to 24

vsg-rs lint src/                       # report rule violations
vsg-rs check src/                      # CI: violations and unformatted files
vsg-rs check --output-format sarif src/ > vsg.sarif   # also json, junit, gitlab, syntastic, summary
vsg-rs fix src/                        # apply all safe fixes, then format
vsg-rs fix --unsafe-fixes --diff src/  # also fixes that may change behaviour (review them)
vsg-rs rules --all                     # every VSG rule and how vsg-rs handles it

Configuration uses the VSG format (YAML or JSON). It is read from --config FILE, or from the nearest vsg-rs.yaml / .vsg-rs.yaml (or .json):

rule:
  length_001:
    length: 100
  process_016:
    disable: true
  group:
    case::name:
      case: lower
file_rules:
  legacy/**/*.vhd:
    rule:
      length_001:
        disable: true

Formatting can be switched off for a region with -- vsg-rs: fmt off / -- vsg-rs: fmt on; VSG's -- vsg_off [rule ...] / -- vsg_on comments suppress rules.

Editor integration

Configure your editor to pipe the buffer through vsg-rs fmt --stdin-filename <path> - (add --range START:END to format selected lines). On success (exit code 0) the buffer is replaced with stdout. On failure (exit code 2) stdout is empty and stderr explains why; leave the buffer unchanged. See docs/editors.md for VS Code, Neovim, Helix and Emacs setups.

Documentation

Development

cargo fmt --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test
cargo run --release --example corpus -- --width 80 path/to/vhdl   # stability and overflow report
UPDATE_EXPECT=1 cargo test --test golden                           # re-bless golden files (review the diff)

License

vsg-rs is licensed under either of Apache License, Version 2.0 or MIT license, at your option. Third-party dependencies are listed in THIRD_PARTY_LICENSES.md. The VHDL parser, vhdl_syntax from the rust_hdl project, is MPL-2.0 and is used as an unmodified dependency.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in vsg-rs, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vsg_rs-0.2.0.tar.gz (190.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

vsg_rs-0.2.0-py3-none-win_arm64.whl (1.5 MB view details)

Uploaded Python 3Windows ARM64

vsg_rs-0.2.0-py3-none-win_amd64.whl (1.7 MB view details)

Uploaded Python 3Windows x86-64

vsg_rs-0.2.0-py3-none-musllinux_1_2_x86_64.whl (1.8 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

vsg_rs-0.2.0-py3-none-musllinux_1_2_aarch64.whl (1.6 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

vsg_rs-0.2.0-py3-none-manylinux_2_28_x86_64.whl (1.7 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

vsg_rs-0.2.0-py3-none-manylinux_2_28_aarch64.whl (1.6 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

File details

Details for the file vsg_rs-0.2.0.tar.gz.

File metadata

  • Download URL: vsg_rs-0.2.0.tar.gz
  • Upload date:
  • Size: 190.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vsg_rs-0.2.0.tar.gz
Algorithm Hash digest
SHA256 da2254e92fc0a82e0148e7cafedf5f8ad01d4c971985508c5ea9a4c7f4f41f1b
MD5 a98aa2889fbef7ad1a5e57e697a6f98c
BLAKE2b-256 5e9684061d531622d31cba943c20ac95c10ef45851aa77d4f2e07581ced6fa65

See more details on using hashes here.

File details

Details for the file vsg_rs-0.2.0-py3-none-win_arm64.whl.

File metadata

  • Download URL: vsg_rs-0.2.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vsg_rs-0.2.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 3f0d3015eefd18b2beb9e3f9988dcf20aaa2848a090a7f4b979a49efe821ac26
MD5 13d4493523dca501d8988620e346fc5a
BLAKE2b-256 122decad42fc8deb137144575053a9a11c8a72b38f44f9d1476b3b0b83376428

See more details on using hashes here.

File details

Details for the file vsg_rs-0.2.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: vsg_rs-0.2.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vsg_rs-0.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 148d95b9f5d16de30a6306de76300859cc00000f95b3a711f28c65ccbae49a47
MD5 9615e8de93b4c29700cd554a23ed29ef
BLAKE2b-256 d2d69a7766d8ce64897f255f41b187bc19a5b071b2d12110e22e00932d98bf7f

See more details on using hashes here.

File details

Details for the file vsg_rs-0.2.0-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for vsg_rs-0.2.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d25af406e122d2645bb61cfff23221842af849851e40998bb64e127defc9aa42
MD5 9e7c1661161e764ec5d16b545ae4197e
BLAKE2b-256 5d782b1ebf0d4d04aec611da8c3d824320c0ea42b00e6db27dc9f3f6a2e3aff4

See more details on using hashes here.

File details

Details for the file vsg_rs-0.2.0-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for vsg_rs-0.2.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 2e19a798cbbf0b7a1a03dee5933c7ccc5b07200d157d36e3a69d11ce358af2b6
MD5 9a1b205b2ebd56130c3985d8abd8d8c6
BLAKE2b-256 bd7078303a556a0f4475e5174f05388bf82288c3ffbdd6d103f9f87849616de4

See more details on using hashes here.

File details

Details for the file vsg_rs-0.2.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vsg_rs-0.2.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a88e9cddbf37f1584960632ca22de371fc040c2d2dacb0e033c349e2a939e6e7
MD5 518b43f1f05ab7b914a441588f242fd2
BLAKE2b-256 60a00b7602f62b1477e6643b87e4cb1cdc8512ded582d317808ffa03495b7467

See more details on using hashes here.

File details

Details for the file vsg_rs-0.2.0-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for vsg_rs-0.2.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 088d7cab96a5a55a3dabbe76d2b88a238a8d0e73c7bc0e603ee435e2d6ca7ece
MD5 1637ca06f9b2a28f94384b3e009d0754
BLAKE2b-256 01fd9a98a195279d3663992ca8e9b9403ae8b6f8b4efe34e5ff3bdb2879f43ba

See more details on using hashes here.

Release history Release notifications | RSS feed

0.9.0

9 files

0.8.0

9 files

0.7.0

9 files

0.6.0

7 files

0.5.0

7 files

0.4.0

7 files

0.3.0

7 files

This release

0.2.0 This release

7 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page