Skip to content

Formatter

lucisv uses a Wadler/Prettier-style document model. Breakable constructs render on one line when they fit and expand predictably when they do not. Comments are attached as trivia and preserved through formatting.

  • 2-space indentation and 100-column lines by default.
  • One port, parameter, or connection per line when a header breaks.
  • Cuddled block transitions such as end else begin.
  • Tight packed dimensions such as [WIDTH-1:0] and [base+:8].
  • At most one preserved blank line between adjacent items.
  • Compiler directives, attributes, and supported verbatim constructs keep their source text.

To indent field macros inside UVM utilities blocks one additional level:

[format]
uvm-utils-indent = true

This v0.49.0 option is off by default. It applies to uvm_field_* macros between uvm_*_utils_begin and uvm_*_utils_end. In editors, lucisv.format.uvmUtilsIndent is the fallback; project configuration wins. Short, comment-free enum bodies already fit on one line without another key.

After toggling this option, run the CLI with --no-cache or remove its format cache: v0.49.0 does not include this option in the cache key. See configuration.

lucisv recognizes existing columnar intent in adjacent ANSI ports, named connections, and parameter declarations. If a group is already aligned—or uses four or more spaces where one would suffice—it is normalized as a table. Flush-left input stays flush-left.

Groups end at blank lines, standalone comments, attributes, or compiler directives. If the widest row exceeds the line limit, the entire group falls back to flush-left, never a half-aligned mixture.

Use a standalone fence to protect hand-laid-out regions:

// verilog_format: off
localparam int A = 1;
localparam int LONGER = 22;
// verilog_format: on

// lucisv: off and // lucisv: on are aliases. Fences preserve exact bytes between items (including class members) and between statements in blocks, forks, functions, tasks, and procedural bodies. They also prevent lint fixes there. A fence must begin on its own line; port/parameter lists, case-label lists, and property/sequence local declarations do not have independent fence scopes. Fenced text must still parse.

--lines selects 1-based inclusive ranges:

Terminal window
lucisv --lines 120-134 rtl/alu.sv
lucisv --lines 3-9,40 --check rtl/alu.sv

The atomic unit is an item: selecting a statement formats its containing always block; selecting a declaration formats that declaration. Everything outside the selected items is emitted byte-for-byte. Ranges require explicit files or stdin, never directories or filelists, and bypass the cache.

  1. Parse first. Whole-file formatting produces no output for a file that cannot be fully parsed.
  2. Preserve meaning. Verification re-lexes input and output and compares normalized tokens, including comments; it does not elaborate the design.
  3. Converge. Formatting twice reaches the same fixed point.
  4. Write atomically. An error leaves the affected file untouched.
  5. Stay deterministic. Parallel worker count changes performance, never output order or exit status.