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.

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 inside whole-item regions and also prevent lint fixes there.

--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 compares normalized syntax before accepting output.
  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.