# lucisv — Language Utility for Coding In SystemVerilog A Verilog and SystemVerilog formatter, linter, and language server written in Rust. Start with the [repository analysis](docs/repository-analysis.md) for a code-based assessment and [dependency topology](docs/topo.md) for interfaces and change impact. The [documentation site source](docs/site/README.md) contains usage guides and references; [CHANGELOG.md](CHANGELOG.md) records releases, and [TODO.md](TODO.md) tracks work in progress. An opinionated, fast formatter and linter for Verilog-2001 and SystemVerilog RTL, built in the image of [ruff](https://github.com/astral-sh/ruff), with layout conventions and lint ergonomics borrowed from [Verible](https://github.com/chipsalliance/verible). ```bash # format files / directories in place (like `ruff format`) lucisv rtl/ tb/top_tb.sv # lint (like `ruff check`); `lucisv format ...` is the explicit spelling of the above lucisv check rtl/ # check mode for CI (exit 1 if anything would change) lucisv --check rtl/ # print a unified diff instead of rewriting (also exit 1 if anything would change) lucisv --diff rtl/ # format exactly what an EDA `.f` filelist names (repeatable, adds to the rest) lucisv -f project.f lucisv check -f project.f -f tb/tb.f rtl/extra.sv # skip generated files while walking directories (repeatable) lucisv --exclude '*_gen.sv' --exclude build rtl/ # .gitignore is honored while walking; --no-gitignore turns that off lucisv --no-gitignore rtl/ # files are formatted on all cores; pin the worker count for reproducible CI lucisv --threads 1 rtl/ # repeat runs skip files that are already formatted; --no-cache turns that off lucisv --check rtl/ lucisv --no-cache --check rtl/ # format only the lines you edited, leaving the rest of the file byte-for-byte lucisv --lines 120-134 rtl/alu.sv lucisv --lines 3-9,40 --check rtl/alu.sv # ...or derive the ranges from git, so only your patch gets formatted tools/lucisv-changed.sh # everything not yet committed tools/lucisv-changed.sh --check origin/main # ignore any lucisv.toml found next to the input lucisv --no-config rtl/ # pipe through stdin/stdout; --stdin-filename names the buffer in messages cat foo.sv | lucisv - cat foo.sv | lucisv --stdin-filename rtl/foo.sv - ``` ### Exit codes (frozen contract — CI may depend on it) | Code | Meaning | |---|---| | 0 | Success: files were formatted, `--check`/`--diff` found nothing to change, or `check` found no violations | | 1 | `--check`/`--diff`: at least one file would be reformatted (nothing written). `check`: at least one violation was reported | | 2 | An error occurred (bad arguments, I/O, or a file that could not be formatted); every file involved in an error is left untouched | An error outranks "would reformat": a run with both exits 2. ### Parallelism Files are formatted on a worker pool, one thread per logical CPU by default. `--threads N` pins the worker count (`--threads 1` is a single worker), which matters for reproducible CI timing and for bisecting; it never changes what is produced. **The thread count does not affect output**: results are collected and reported in input order, so stdout, stderr and the exit code are byte-identical at any `N`, and `lucisv --diff` stays one clean patch in input order. stdin mode is single-threaded. ### Cache lucisv remembers which files it has already verified are formatted, so a repeat run over an unchanged tree skips them: the summary says `N files from cache`, and on one core the corpus check goes from 396 ms to 51 ms (2.3× at the default thread count, where parallelism has already taken the easy win). An entry is keyed on **(content hash, `line-length`, `indent`, `uvm-utils-indent`, lucisv version)** per file, and only ever records the *already formatted* verdict — a file that would be reformatted, or that failed, is re-checked on every run. The store is one text file in `.lucisv_cache/` (self-ignoring, like cargo's `target/`); deleting it, or a corrupted one, costs one slow run and nothing else. `--no-cache` neither reads nor writes it, and `--cache-dir ` puts it elsewhere (the default is relative to the current directory). Content hashing is 64-bit FNV-1a and a lookup never crosses files; `docs/features/format-cache/README.md` states the collision posture, the semantics table and the concurrency story. (In v0.49.0 only, `uvm-utils-indent` was missing from this key, so a cached clean verdict survived a toggle of the option — fixed in 0.50.0; a 0.49.0 store is simply rebuilt.) ### Ignore files While walking a directory, lucisv reads a `.gitignore` in every directory it enters and skips what those rules name. A deeper `.gitignore` is applied after (and so overrides) a shallower one, and within one file the last matching line wins — git's own precedence. `--no-gitignore` switches this off. A path named directly on the command line is never ignored, exactly as with `--exclude`. Supported: `#` comments, blank lines, `*` inside one path component, a leading or embedded `/` (anchors the pattern to that `.gitignore`'s own directory), a trailing `/` (matches directories only), and `!` negation. **Not** supported: `**`, `?`, character classes, `\` escapes, the global/repo excludes files, and git's "already-tracked files are never ignored" rule. See `docs/features/parallel-files/README.md` for the exact subset. Directory walks enter each directory once by identity, so symlink cycles terminate. Inputs resolving to one canonical file path are processed once. Unreadable directories or `.gitignore` files and dangling source links found during a walk warn on stderr and are skipped without changing the exit code; a missing explicitly named input is still an error. ## Configuration Settings live in a `lucisv.toml` (or `.lucisv.toml`) file, ruff-style. For each input, lucisv searches **upward from that path's directory** for one: 1. `lucisv.toml` in the directory — used if present; 2. else `.lucisv.toml` in the directory; 3. else, if the directory contains `.git`, stop: no config (the `.git` check comes *after* 1–2, so a config file in the repo root is still found); 4. else repeat in the parent directory, up to the filesystem root. The first file found wins outright — configs are never merged. Files in different directories may therefore be formatted with different settings in one run. For stdin, the search starts at `--stdin-filename`'s directory, or the current directory if that flag is absent. `--no-config` skips all of this. ```toml # lucisv.toml — every key is optional line-length = 100 # 40..400, same as --line-length indent = 2 # 1..8, same as --indent exclude = [ "*_gen.sv", "build" ] # added to --exclude patterns filelist = "rtl/files.f" # an EDA `.f` filelist, relative to this file [format] style = "google" # a named layout, same as --style (see Named styles) [lint] select = ["no-tabs", "unused-signal"] # optional replacement for defaults ignore = ["module-filename"] # removed after selection ``` `filelist` names the project's sources the way the rest of the EDA world already does — one path per line, `-f` to nest another filelist, `+incdir+`, `+define+`, `#`/`//` comments, `$VAR` expansion, paths relative to the filelist that names them. This **key** is read by `lucisv-server` only, where it defines exactly which files are indexed ([Editor setup](#editor-setup)): a `lucisv rtl/` that quietly formatted a filelist's files instead of `rtl/`'s would be a surprise. On the command line a filelist is named explicitly, with `-f`: ```bash lucisv -f project.f # format exactly the files it names lucisv check -f project.f rtl/ # ...added to whatever else is named ``` The listed paths are taken exactly as written — neither `--exclude` nor `.gitignore` filters them, just as neither filters a file named on the command line — and a file named twice over is processed once. A listed file that has gone missing, an option lucisv does not know and an unset `$VAR` are warnings on stderr that change no exit code; a filelist that cannot be read at all is an error (exit 2) and nothing is processed. Details: `docs/features/filelist/README.md` and `docs/features/cli-filelist/README.md`. **Precedence: CLI flag > config file > default**, per setting (`--indent 4` with a file that sets only `line-length` uses both). `exclude` is the exception: config patterns are *added* to `--exclude`, not replaced by it. `[format] style` (flag `--style`, editor `lucisv.format.style`) picks one of the [named styles](#named-styles). The style is resolved first and supplies the starting indent and line length; an explicit `indent` or `line-length` — from a flag or from the file — then wins over the preset's, so `style = "microsoft"` with `indent = 2` is Microsoft's layout at 2 spaces. An unknown style name is the same hard error as an unknown key, and lists the valid names. In the editor, `lucisv.toml` outranks the editor settings as for every formatting key, and a chosen style (other than `lucisv` or `auto`) also outranks the editor's tab size. `[format] uvm-utils-indent = true` (editor: `lucisv.format.uvmUtilsIndent`), off by default, indents the `` `uvm_field_* `` macros written between `` `uvm_*_utils_begin `` and `` `uvm_*_utils_end `` one level; like `style`, it is a formatting choice lucisv leaves to the project, because it changes bytes in existing UVM code (21 of the 860 corpus files). An unknown key, a bad value, an out-of-range number, or any TOML beyond the supported subset (tables other than `[format]`, `[lint]` and `[lint.]`, multi-line arrays, unsupported string escapes) is a hard error naming the file and line — exit 2, with nothing written. This is deliberate: a silently ignored `line_length` typo costs more than a strict parser does. ## Linting `lucisv check` runs a set of lint rules over the same files `lucisv` would format — same walk, same `--exclude`, same `.gitignore` handling, same `lucisv.toml` discovery. ```bash lucisv check rtl/ # FILE:LINE:COL: severity: message [rule] lucisv check --output-format json rtl/ # one JSON array, for editors and CI lucisv check --select no-tabs rtl/ # only these rules (comma-separated) lucisv check --ignore module-filename rtl/ # everything but these lucisv check --select error rtl/ # a whole severity class, by name lucisv check --fix rtl/ # apply the safe fixes, write files back lucisv check --rules-doc # the generated reference for every rule ``` Exit codes are the frozen contract above: 0 clean (or everything fixed), 1 violations remain, 2 error. Unlike the formatter, `check` uses the error-tolerant parser, so a file lucisv cannot fully parse is still linted for what it can see. ### Severities Every rule is in one of three classes, and the class is the word that stands in the diagnostic line, in the JSON `severity` field, and in the editor's squiggle colour: | Class | Means | Editor | |---|---|---| | `error` | would very likely fail to compile, elaborate or synthesize | red (LSP Error) | | `warning` | compiles, and very likely does not mean what it says | yellow (LSP Warning) | | `style` | correct, and reads badly | blue (LSP Information) | A class name is accepted **wherever a rule name is** — on `--select`, on `--ignore`, and in `select`/`ignore` under `[lint]` in `lucisv.toml`: ```bash lucisv check --select error rtl/ # only the compile-breakers lucisv check --ignore style rtl/ # everything but the naming rules ``` Every `error`-class rule follows one discipline: **silence beats a wrong accusation**. Each of them goes quiet whenever the run cannot answer — a file that did not fully parse, a module the project does not hold or holds twice, a name a macro produces, a fragment written to be `` `include``d. That is what makes an editor's red squiggle worth believing. ### The rules | Rule | Severity | Fix | What it wants | |---|---|---|---| | `multiply-driven` † | error | — | one driver per variable | | `wire-reg-mixup` | error | — | `logic`, not `reg`, in a `.sv` file | | `mismatched-labels` | error | — | `end : name` names the block it closes | | `duplicate-declaration` | error | — | each name declared once per scope | | `undeclared-identifier` † | error | — | every name is declared somewhere in the project | | `unknown-port` † | error | — | `.name(…)` is a port the module declares | | `unknown-parameter` † | error | — | `#(.NAME(…))` is a parameter it declares | | `always-ff-non-blocking` | warning | — | `<=` inside `always_ff` | | `always-comb-blocking` | warning | — | `=` inside `always_comb` | | `case-missing-default` | warning | — | every `case`/`casex`/`casez` has a `default` | | `incomplete-assignment` | warning | — | an `always_comb` assigns on every path | | `suspicious-semicolon` | warning | — | no `if (x);` / `for (…);` / `while (…);` | | `forbid-defparam` | warning | — | override at the instantiation, not with `defparam` | | `invalid-system-task-function` | warning | — | no `$random`, `$psprintf`, `$dist_*`, `$srandom` | | `plusarg-assignment` | warning | — | `$value$plusargs`, not `$test$plusargs` | | `truncated-numeric-literal` | warning | — | a sized literal fits its width | | `undersized-binary-literal` | warning | safe | every bit of a sized binary literal is written | | `packed-dimensions-range-ordering` | warning | — | a packed dimension is `[N-1:0]` | | `forbid-negative-array-dim` | warning | — | no negative literal in a dimension | | `module-port` | warning | — | more than one port is connected by name | | `module-parameter` | warning | — | more than one parameter is overridden by name | | `explicit-function-task-parameter-type` | warning | — | every tf argument has a storage type | | `void-cast` | warning | — | `void'(…)` wraps a call | | `instance-shadowing` | warning | — | no declaration hides an enclosing one | | `undriven-net` † | warning | — | everything read is driven by something | | `unused-signal` † | warning | — | no net or variable nothing uses | | `create-object-name-match` | warning | — | `type_id::create("x")` names the handle `x` | | `forbidden-macro` | warning | — | no macro on the project's forbidden list | | `uvm-macro-semicolon` | warning | — | no `;` after a `` `uvm_* `` macro (off by default) | | `macro-string-concatenation` | warning | — | no `` `` `` inside a plain string (off by default) | | `disable-statement` | warning | — | `disable fork`, not a fork label (off by default) | | `no-tabs` | style | safe | spaces, not tabs (a tab inside a string is left alone) | | `no-trailing-whitespace` | style | safe | nothing but code before the newline | | `empty-item` | style | safe | no `;` standing where an item belongs | | `explicit-parameter-storage-type` | style | — | `parameter int W = 8`, not `parameter W = 8` | | `module-filename` | style | — | a one-module file is named after its module | | `enum-name-style` | style | — | `lower_snake_case` ending `_e`/`_t` | | `struct-union-name-style` | style | — | `lower_snake_case` ending `_t` | | `parameter-name-style` | style | — | `CamelCase` or `ALL_CAPS` | | `module-name-style` | style | — | `lower_snake_case` (off by default) | | `line-length` | style | — | no line wider than the width the formatter uses | | `posix-eof` | style | safe | the file ends with a newline | | `forbid-consecutive-null-statements` | style | safe | no `;;` where a statement belongs | | `generate-label` | style | — | every generate block carries a `: label` | | `generate-label-prefix` | style | — | that label starts with `g_` or `gen_` | | `package-filename` | style | — | a one-package file is named after its package | | `interface-name-style` | style | — | `lower_snake_case` ending `_if` | | `macro-name-style` | style | — | a `` `define`` name is `ALL_CAPS` | | `constraint-name-style` | style | — | `lower_snake_case` ending `_c` | | `typedef-enums` | style | — | an `enum` type is named with a `typedef` | | `typedef-structs-unions` | style | — | a `struct`/`union` type is named with a `typedef` | | `always-comb` | style | unsafe | `always_comb`, not `always @*` | | `signal-name-style` | style | — | `lower_snake_case` signals (off by default) | | `parameter-type-name-style` | style | — | `lower_snake_case` ending `_t` type parameters (off) | | `port-name-suffix` | style | — | `_i` / `_o` / `_io` say which way a port points (off) | | `one-module-per-file` | style | — | one `module` per file (off by default) | | `banned-declared-name-patterns` | style | — | no declared name matching a project's own list (off) | | `explicit-begin` | style | safe | every body is a `begin ... end` block (off by default) | | `unused-waiver` | style | — | waivers that suppress nothing | | `unused-import` † | style | safe | no `import` nothing in the scope reaches through (off by default; stays off without a project) | | `explicit-function-lifetime` | style | — | `automatic`/`static` on a function outside a class | | `explicit-task-lifetime` | style | — | `automatic`/`static` on a task outside a class | | `positive-meaning-parameter-name` | style | — | no `disable`-prefixed parameter name | | `suggest-parentheses` | style | safe | `a ? (b ? c : d) : e`, parenthesized | | `unpacked-dimensions-range-ordering` | style | — | an unpacked dimension is `[0:N-1]` | | `module-begin-block` | style | — | no `begin`/`end` at module scope | | `v2001-generate-begin` | style | — | no bare `begin` in a generate region | | `forbid-line-continuations` | style | — | no `\` breaking a string literal | | `legacy-generate-region` | style | — | no `generate … endgenerate` wrapper (off) | | `legacy-genvar-declaration` | style | — | a genvar is declared in the `for` header (off) | | `endif-comment` | style | safe | `` `endif `` names what it closes (off by default) | | `numeric-format-string-style` | style | — | a radix prefix matches its specifier (off) | | `proper-parameter-declaration` | style | — | `parameter` in a header, `localparam` in a body (off) | | `dff-name-style` | style | — | a flip-flop is `_q`, its input `_d` (off by default) | † On by default when lucisv can see a project (a multi-file CLI run or the language server), and off for a single file or stdin unless `--select` names them. These rules read the file's *symbol table* and ask the project about names, not just the file's syntax; the project-wide identifier census keeps a hierarchical use in another file from becoming a false positive. See `docs/features/semantic-lints-on/README.md` and `docs/features/linter-expansion-1/README.md`. `lucisv check --rules-doc` prints the whole reference — every rule, its class, its default, its fix and the paragraph saying why it exists — generated from the registry, so it can never be out of date. Fixes follow ruff's applicability model: `--fix` applies *safe* fixes (those that cannot change what the code means), `--unsafe-fixes` widens that to the rest. One rule ships an unsafe fix: `always-comb` rewrites `always @*` to `always_comb`, which is a different block at time zero and makes a second driver of its outputs an error — right nearly always, and not lucisv's call to make without being asked. Violations inside a `// verilog_format: off` region are reported but never fixed: `off` means hands-off for the linter too, so `--fix` leaves every byte of a fenced region exactly as written. ### Rule options A rule can be configured in a `[lint.]` table: ```toml [lint] ignore = ["typedef-structs-unions"] [lint.line-length] length = 120 # the linter's limit, if not the formatter's [lint.generate-label-prefix] prefix = ["g_", "gen_"] # the label prefixes this project writes [lint.parameter-name-style] localparam_style = "CamelCase" # Verible's own default, stricter than ours [lint.signal-name-style] style_regex = "[a-z][a-z_0-9]*" # a pattern, matched against the whole name ``` The keys are Verible's wherever it has the same option, so a `.rules.verible` file translates word for word. An option nobody sets reads the default `lucisv check --rules-doc` prints beside it. An unknown rule or option name, a value of the wrong kind, an integer out of range or a pattern that does not compile **fails the run**, naming the config file and the line — a typo in a lint setting is not something to guess at. Patterns are not full RE2. What is supported: literals, `.`, `[...]` classes with ranges and negation, the escapes `\d \D \w \W \s \S` (character classes), `\n \t \r` (control characters) and `\` (that character, literally), groups, `|`, and the postfix `*` `+` `?` — matched against the **whole** name, so `^`/`$` are accepted and redundant. Everything else is **refused when the option is read, by name**: counted repetition (`{2,3}`), lookaround and flag groups (`(?=…)`, `(?:…)`), and every escape not listed above — a backreference (`\1`), a word boundary (`\b`), `\A`, `\z`, `\p{…}`, `\x41`. An unsupported escape read as a literal would quietly judge the wrong names (`\bword\b` would match `bwordb`), which is worse than an error you can read. Matching is a Thompson-NFA simulation, so it is linear in pattern × name length whatever shape the pattern has: no pattern can make `lucisv check` — or an editor session — hang. From an editor the same options are one object, `lucisv.lint.options`: ```json "lucisv.lint.options": { "line-length": { "length": 120 }, "typedef-structs-unions": { "allow_anonymous_nested": false } } ``` There the precedence is **the editor's value, then the `lucisv.toml`, then the rule's default — key by key**: a project can set two options and one user override the third without losing the others. (This is the opposite order to the formatting settings, where a checked-in `lucisv.toml` outranks the editor: formatting has a byte-exact contract with CI, and which findings you are shown in your own editor is yours to choose.) A bad entry there is *ignored* and reported in the lucisv log rather than fatal, so one typo cannot leave a session with no diagnostics. ### Waivers ```systemverilog wire a; // lucisv: waive no-tabs suppresses that rule on this line // lucisv: waive no-tabs alone on a line: suppresses the next line // lucisv: waive-start no-tabs ... and everything through // lucisv: waive-stop no-tabs ... this line ``` `verilog_lint:` is accepted in place of `lucisv:`, so code annotated for Verible works unedited — including waivers naming Verible rules lucisv has not implemented, which are ignored rather than reported. A waiver of lucisv's own that suppresses nothing, names an unknown rule or is malformed is reported under `unused-waiver`. Findings can also be suppressed from **outside** the RTL, in Verible's waiver-file format — one directive per line, `#` comments and blank lines ignored: ```text # every line of every file waive --rule=no-tabs # one line, or a range with both ends included waive --rule=line-length --line=12 waive --rule=line-length --line=12-20 # only the files a pattern names waive --rule=no-tabs --location=legacy/top.sv ``` `--rule` is required and names exactly one rule (a severity word is not accepted). `--line` is 1-based. `--location` is matched the way an `--exclude` pattern is — `*` within one path component, a pattern with `/` matching a path suffix, one without matching the file name at any depth — and **not** as a regular expression; a pattern that looks like one (`.*`, `\.`, `[…]`) is an error naming the difference. Waiver files come from three places, and they add up: `lucisv check --waiver-file ` (repeatable, relative to the working directory), `waivers` under `[lint]` in `lucisv.toml` (relative to that file; read by the CLI and the editor), and the editor setting `lucisv.lint.waivers` (relative to the first workspace folder). External and inline waivers are a union: a finding either covers is suppressed, and one both cover leaves neither reported as dead. A missing file or an unparsable directive fails `lucisv check` with `:: ` and exit 2; in an editor the bad line is dropped and the rest of the file applies, and the bad line is written once to the lucisv log whether the file was named by the editor setting or by `lucisv.toml`. Unused external waivers are reported under `unused-waiver` at their line of the waiver file, by `lucisv check` only and only after the whole run. Both front ends read the same configuration, and the editor's settings play the role the CLI's flags play: `lucisv.lint.select` when it is set, else `[lint] select` from the buffer's `lucisv.toml`, else the default set — and the same for `ignore`, decided independently. `lucisv.lint.severity.*` and `lucisv.lint.rules.*` have no project counterpart and apply over whichever selection stands. Project per-rule options are read by both front ends. A project entry lucisv cannot use — an unknown rule name in `[lint] select`/`ignore`, a rejected `[lint.]` option, an unreadable waiver file or a directive that does not parse — fails `lucisv check` with `:: ` and exit 2; in an editor it is dropped, written once to the lucisv log in the same words, and everything lucisv did understand still lints the buffer. Full rules: `docs/features/linter-core/README.md`. ## Architecture (the ruff mapping) The nine-crate workspace separates source syntax, reusable engines, project inputs, and the CLI/LSP front ends. The formatter follows ruff's separation of document layout from language rules: | This repo | ruff equivalent | Role | |---|---|---| | `crates/vlog_parser` | `ruff_python_parser` + `ruff_python_ast` | Hand-written lexer and recursive-descent parser producing a comment-preserving AST | | `crates/vlog_formatter/src/{doc,printer}.rs` | `ruff_formatter` | Wadler/prettier-style document IR (`Text`/`Line`/`Group`/`Indent`) + width-aware printer | | `crates/vlog_formatter/src/format/` | `ruff_python_formatter` | Per-node formatting rules, one module per grammar domain (`item`, `module`, `instance`, `decl`, `stmt`, `expr`, `class`, `cover`, `sva`, …) | | `crates/vlog_linter` | `ruff_linter` | Rule registry, violations, fix applicability, waivers | | `crates/vlog_semantic` | — | File scopes and references, workspace index, conservative cross-file resolution | | `crates/vlog_refactor` | — | Verified rename/references, ports, imports, extract/inline module, instantiation plans | | `crates/lucisv_core` | — | Shared config, filelists, walks, format cache, atomic replacement | | `crates/lucisv` | the `ruff` CLI | Parallel per-file formatting/linting, reports, stdin, in-place writes | | `crates/lucisv_server` | — | Synchronous LSP loop, open-buffer overlays, indexing, editor capabilities | | `crates/lucisv_mcp` | — | Model Context Protocol server for coding agents: project understanding and verified, token-saving edits over stdio (`docs/mcp/PLAN.md`) | `vlog_parser` and `lucisv_core` have no dependencies. The formatter depends only on the parser; semantic analysis also depends only on the parser. Linting consumes the parser, semantics and `lucisv_core` (for the one `--exclude`-style matcher a waiver file's `--location` shares with the CLI); refactoring consumes the parser and semantics. The CLI reaches semantics through the linter and has no refactoring dependency. The server composes all six libraries, and so does the MCP server (never the LSP crate). See [topo.md](docs/topo.md) for the full graph, including the linter’s and refactor’s formatter dependencies used only by tests. Key ideas carried over from ruff/prettier: - **Trivia attachment.** The lexer runs a second phase that folds comments into neighboring tokens as *leading*/*trailing* trivia and records blank lines; the parser then harvests them onto AST nodes (`Meta`). Comments are never dropped — anything not harvested at a precise location is folded into the next node's leading comments. - **Fit-based layout.** Every breakable construct (port lists, connection lists, expressions, concatenations) is a `Group`: it renders on one line if it fits within the line limit, otherwise it breaks one-element-per-line. A comment inside a group forces it to break. - **Verification on every formatting call.** The engine re-lexes input and output and compares normalized tokens, including comments. It then parses and formats the output again and requires a fixed point. Either check can reject the result; the caller retains the original file. This is a lexical safety net, not compiler elaboration or a proof of hardware equivalence. - **Two parsing modes.** Formatting uses strict parsing. Linting and the editor use tolerant parsing: failed elements become error leaves while valid siblings remain available for analysis. A lexer failure is still all-or-nothing. Neither mode performs cross-file macro expansion. ## Style Defaults follow Verible: **2-space indent**, **100-column lines** (both configurable via `--indent` / `--line-length` or a `lucisv.toml`, see [Configuration](#configuration)). The list below is the default `lucisv` style; the [named styles](#named-styles) change some of it. - One port / parameter / connection per line once a header doesn't fit - Cuddled `begin`/`end` (`end else begin`) - Tight dimension expressions: `[WIDTH-1:0]`, `[base+:8]` - Blank lines between items preserved (collapsed to at most one) - `` `define``/`` `ifdef``/`` `include`` and `(* attributes *)` passed through verbatim ### Named styles `[format] style`, `--style` and the editor's `lucisv.format.style` drop-down pick one of a handful of house layouts. Every style moves whitespace only — which line a token starts on and how many spaces precede it — so the same token-equivalence check guards all of them, and each one is a fixed point of itself (proved over the 860-file corpus and OpenTitan's 4 061 `hw/` files for every preset; `docs/features/format-styles/README.md`). | style | indent | width | `begin` | `else` after `end` | after `end : label` | header & connection lists | list indent | columns | |---|---|---|---|---|---|---|---|---| | `lucisv` (default) | 2 | 100 | same line | `end else` | `end : l else` | on one line if it fits | 1 level | kept where you wrote them | | `google` | 2 | 100 | same line | `end else` | own line | one entry per line | 2 levels | kept where you wrote them | | `lowrisc` | 2 | 100 | same line | `end else` | own line | one entry per line | 1 level | always aligned | | `ansi` | 4 | 80 | own line | own line | own line | on one line if it fits | 1 level | kept where you wrote them | | `microsoft` | 4 | 120 | own line | own line | own line | one entry per line | 1 level | kept where you wrote them | | `nxp` | 2 | 80 | same line | own line | own line | one entry per line | 1 level | always aligned | | `auto` | — | — | the preset the file is already closest to | | | | | | `google` follows the [Google Verilog Style Guide](https://google.github.io/styleguide/verilogguide.html) and `lowrisc` the [lowRISC Verilog Coding Style Guide](https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md) (OpenTitan's). **`ansi`, `microsoft` and `nxp` are lucisv's educated guesses** at what those names suggest — C formatters' ANSI/Allman layout, clang-format's `Microsoft` base style carried over to `begin`/`end`, a conservative RTL house style — not rules those organisations publish; none of them publishes a Verilog style that we could find. A `case` item's and a `do`'s `begin` stays on its own line's end in every style. "Header & connection lists" are module headers' parameter and port lists and instances' *named* overrides and connections — not `#(16)`, ordered connections or function ports. `lowrisc` differs from its guide in two places: the widest aligned connection keeps one space before its `(`, and a comment line ends an aligned table. `auto` formats the file once per preset, at the configured indent and width, and keeps the output that changes the fewest lines (indentation included, so a one-line edit does not flip a whole file to another preset); it never guesses an indent or a width, and it is idempotent by construction. **`auto` picks a layout for the configured indent and width; it never infers them — set `indent` to match the file first.** Because every re-indented line counts as changed, a file written at another indent is closest to whichever preset changes the fewest of its lines once they are all re-indented: a 4-space Allman file (formatted with `--style ansi`) run through `--style auto` at the default indent 2 comes out in the cuddled `lucisv` layout, while with `indent = 4` it stays Allman (and with `line-length = 80` as well, byte for byte). Under `auto`, range and selection formatting use the style of the whole file, not of the selected lines; the language server remembers each document's preset from its last whole-file format, so a keystroke or a selection does not search again, and a buffer with a parse error keeps its preset. One that has never resolved — no memory, and it does not parse — gets the default layout. ### Alignment is inferred, not imposed Hand-aligned columns are how RTL is read, so lucisv reads the spacing you already wrote and keeps your intent — Verible's rule, without the knobs. Within a run of adjacent ANSI **port declarations**, **named connections** (`.clk (clk)`) or **`parameter`/`localparam` declarations**, four or more spaces where one would do — or a run whose column is already lined up — means "aligned": every row is padded to the widest one, and the list stays one element per line. Anything else formats flush-left with a single separator, exactly as it always has, so a file written without alignment never grows any. ```systemverilog // written with aligned columns, so lucisv leaves them aligned — at the width // the group actually needs, which is what makes two people's tables agree module m ( input wire clk, input wire [WIDTH-1:0] data, output logic valid ); localparam int A = 1; localparam int LONGER = 22; endmodule ``` Groups end at a blank line, a standalone comment, an `(* attribute *)` or a compiler directive, so two tables separated by a comment get their own columns. A group whose widest aligned line would pass the line limit falls back to flush-left *as a whole* — never half-aligned. Full rule, including why both layouts are fixed points of re-formatting: `docs/features/alignment/README.md`. ### Turning the formatter off Everything between a `// verilog_format: off` and a `// verilog_format: on` comment is emitted as the exact source bytes it was written with, indentation included — the escape hatch for hand-aligned tables and the like. `// lucisv: off` / `// lucisv: on` is an accepted alias. ```systemverilog module m; // verilog_format: off localparam int A = 1; // hand-aligned, left alone localparam int LONGER = 22; // verilog_format: on localparam int B = 3; // formatted normally endmodule ``` A fence works between **items** — module, package and class members, and top-level items — and between **statements**: inside `begin`…`end`, `fork`…`join*`, and function, task, `initial`, `always` and `final` bodies. ```systemverilog class scoreboard; function void build_phase(); // verilog_format: off uvm_config_db#(cfg_t)::set(this, "env.agent", "cfg", cfg.agent_cfg); // hand-wrapped, left alone // verilog_format: on endfunction endclass ``` The fence must be a line comment that begins its own line, and its text must match exactly — `// lucisv: off for now` is an ordinary comment, not a fence, and so is one written after code on the same line (`wire a; // lucisv: off`, `begin // lucisv: off`). An `off` with no matching `on` runs to the end of the enclosing list and no further: the module body, the class body, the `begin`…`end`, the function body, or the file. A fence inside a port list, a parameter list or a `case` **label** list is still an ordinary comment. Full rules: `docs/features/format-fences/README.md` and `docs/features/statement-fences/README.md`. ### Range formatting (`--lines`) `--lines M-N` formats only the constructs meeting those 1-based, inclusive lines and emits every other byte exactly as it was written. This is the adoption path for a legacy tree: your patch comes out formatted and nothing else moves, so review sees the change rather than a reflow. ```bash lucisv --lines 120-134 rtl/alu.sv # one range lucisv --lines 3-9,40 rtl/alu.sv # several, comma-separated lucisv --lines 3-9 --lines 40 rtl/alu.sv # the same, repeated ``` The unit is one **item**. An item whose lines meet a range — a declaration, an `always` block, an instantiation — is laid out exactly as a whole-file run would lay it out; nothing smaller is, so selecting one statement lays out the `always` block around it. A module or package is descended into: its header and its `endmodule` stay as written unless they are themselves selected, and only the body items that are selected are laid out — a three-line edit in a two-thousand-line module reformats three lines. `// verilog_format: off` still wins over any range. `--lines` needs explicit file arguments (or `-`), never a directory, and neither reads nor writes the cache: a partly-formatted file is not the "already formatted" verdict the cache stores. It combines with `--check`, `--diff`, `--stdout` and stdin. `tools/lucisv-changed.sh` turns `git diff` hunks into ranges. Full semantics, including what happens at a range boundary: `docs/features/range-formatting/README.md`. ## Supported syntax v0.49.0 adds real `randsequence` productions; nonblocking `->>` event triggers with optional timing; streaming `with [range]`; constant-expression and packed-type cast bases; net drive strengths; statement-level `let`; and min:typ:max clocking skews. The parser, formatter and AST consumers share these nodes. See [coverage gaps](docs/coverage_gaps.md) for the dated survey and remaining semantic limits. Basic Verilog-2001 and the common synthesizable SystemVerilog subset: - Modules (ANSI and non-ANSI headers), packages, parameter ports, `import`, `timeunit` - Net/variable declarations (`wire`/`reg`/`logic`/`int`/... , signing, packed/unpacked dimensions, net delays and net drive strengths), `parameter`/`localparam`, `genvar`, `defparam` - `assign` (with delays), `always`/`always_comb`/`always_ff`/`always_latch`, `initial`/`final` - Full statement set: `begin/end` (labeled), `if`/`else`, all `case` kinds with `unique`/`priority`, `for`/`while`/`do`/`repeat`/`forever`/`foreach`, `fork/join*`, timing controls (`#`, `@`), `wait`, `disable`, `force`/ `release`, event triggers, immediate assertions, `break`/`continue`/ `return` - Module/gate instantiation: named and ordered connections, `.*`, parameter overrides, instance arrays - `bind` directives (IEEE 1800 §23.11): `bind [: ]` followed by an ordinary instantiation, at module scope, at top level and inside `generate`. The target may be a module, interface or instance name or a hierarchical path. See `docs/features/bind/README.md` - Interfaces (IEEE 1800 §25): `interface [import pkg::*;] [#( ... )] [( ... )]; ... endinterface[: label]` — the module header's grammar, the module body's items, plus `modport a (input x, output y), b (...);` and `clocking cb @(posedge clk); ... endclocking` (including `default clocking`, the anonymous and body-less spellings, and `#skew`/edge skews). `virtual [interface] iface [#( ... )]` stands in every type position — a `typedef` base type, a task/function argument, a declaration. See `docs/features/interfaces/README.md` - `generate` regions and module-level `if`/`for`/`case` - Functions and tasks (ANSI and old-style port declarations) - `typedef` (aliases, `enum`, packed `struct`/`union`, `typedef class` forward declarations), including an `enum` whose base type is a typedef'd name and a struct member whose own type is an inline aggregate - Anonymous `enum`/`struct`/`union` used as a type in place, wherever a type stands: `enum logic [1:0] {IDLE, STOP} state, state_next;`, `struct packed { ... } s;`, and as the default of a `type` parameter. `parameter type` / `localparam type` also stand as body items, not only in the `#( ... )` list. A typedef'd type may carry packed dimensions before the declarator (`payload_t [NumOut-1:0][NumInp-1:0] out_data;`). See `docs/features/types-decls/README.md` - Classes: `class`/`virtual class` … `endclass[: label]`, `#( ... )` class parameters, `extends Base[#( ... )]`, `implements`, and class-scope members — properties with `rand`/`randc`/`local`/`protected`/`static`/`const`, virtual interface handles, parameterized types (`uvm_analysis_port #(bit [31:0]) p;`), methods with `virtual`/`static`/`local`/`protected`/`automatic`, `function new`, `extern` and `pure virtual` prototypes and their out-of-body definitions, plus everything that already works at module scope (`typedef`, `localparam`, `import`, directives, macro items, nested classes). `constraint c { ... }` and `covergroup … endgroup` are structured too: constraint expressions, `soft`/`dist`, implication, `foreach`, `solve before`, coverpoints, bins, transitions and crosses all format canonically and participate in rename, references and semantic lints. An unrecognized body rewinds to its exact source bytes instead of blocking the surrounding file. See `docs/features/constraint-bodies/README.md` and `docs/features/covergroup-bodies/README.md` - Concurrent assertions (IEEE 1800 §16): `assert`/`assume`/`cover`/`restrict property ( ... )` with an optional `label:` prefix and an action block (`else $error(...)`, `$info(...); else ...`, `else begin ... end`, and any statement that nests blocks: `if (c) begin ... end else ...`, `fork ... join_none`, `case ... endcase`), wherever a module item or a statement can appear — module and package bodies, generate regions, `begin`/`end`, and at file scope. `sequence` and `property` declarations, typed formals, local variables, `expect`, `cover sequence`, and `default disable iff` are real nodes. The property/sequence expression grammar uses the LRM precedence table; top-level `|->`/`|=>`/`##`/`and`/`or` operators break one per line when needed. Rename, references, document symbols and semantic lints see inside; an unrecognized construct falls back to its exact source bytes and produces a rename warning. See `docs/features/sva-bodies/README.md` - Dynamic types: queues (`string q[$]`, bounded `[$:N]`), dynamic arrays (`int a[]`), associative arrays (`[*]`, `[string]`, `[key_t]`) — in declarations, class properties, typedefs and function/task arguments; the empty literal (`q = {};`), `new[expr]`, `$`-bound indexing (`q[$]`, `q[$-1]`) and queue method calls. See `docs/features/dynamic-types/README.md` - DV statements (IEEE 1800 §7.12, §9.3.5, §11.12, §12.7.3, §13.4.2, §18.7, §18.16): `randomize() with { ... }` / `std::randomize(x, y) with { ... }` (the call and its constraint block are structural, with byte-exact fallback for an unrecognized constraint shape), the array-method iterator argument `q.sum() with (item.w)`, `foreach` over a package-scoped or hierarchical array with selects on the way (`foreach (pkg::isa[i])`, `foreach (h[id].sub[k])`, `foreach (a[i][j])`), `randcase ... endcase`, `wait fork;`, `import pkg::x;` among a block's declarations, `let name(ports) = expr;`, an omitted positional call argument (`create("x", , `gfn)`), and a statement label on any statement (`chk: assert (a) x++; else y++;`). A stray `;` after a task/function footer label (`endtask : t;`) is reproduced where it was written. See `docs/features/dv-statements/README.md` - DPI: `import "DPI-C" [context|pure] [c_name =] function|task ...;` — a function/task prototype with a linkage prefix, so the argument list breaks like any other; `export "DPI-C" [c_name =] function|task name;`; and package re-exports `export pkg::*;` / `export pkg::a, pkg::b;` / `export *::*;`. See `docs/features/dpi-export/README.md` - Named function/task call arguments (`csr_wr(.ptr(p), .value(v))`, `.flag()`), `case (expr) inside` with `[lo:hi]` range labels, and bare event controls (`@ev;`, `@hier.name;`) - Expressions: the full operator precedence table including the implication operators `->`/`<->`, ternaries, concatenation/replication, slices (`+:`/`-:`), streaming concatenations (`{<<8{v}}`, `{>>{a, b}}`, also as an assignment target), casts over any constant primary (`int'(x)`, `(NumLevels)'(x)`, `pkg::Width'(x)`), assignment patterns (`'{...}`, including the replication form `'{N{0}}`), `inside` (with a `{...}` set or a macro standing in for one), hierarchical and package-scoped names, and the `new` forms — the constructor `new(...)`, the dynamic-array resize `new[N]` and the shallow copy `new obj` (IEEE 1800 §8.12). See `docs/features/expressions-2/README.md` - Drive strengths on a continuous assignment (`assign (weak0, pull1) x = y;`), `const ref` task/function arguments, and `(* attribute *)` instances in front of a named port connection - Macro invocations (`` `NAME ``, `` `NAME(args) ``, with or without a trailing `;`) in expression position **and** wherever a module item or a statement can appear — module and package bodies, generate regions and blocks, `begin`/`end` and `fork`/`join`, case-item and `if`/`else` bodies, function and task bodies. The invocation is passed through verbatim (a multi-line argument list keeps its own line structure, re-indented); a trailing `;` is reproduced only if the source wrote one. At item and statement position a space before the argument list is accepted too (`` `uvm_field_int (a, UVM_DEFAULT) ``) and is reproduced as written; in *expression* position the author-written gap is preserved too, because it can affect how a macro with formals is interpreted. A macro that ends its line is a complete macro, so whatever opens the next line — a declaration, or a statement starting with `@`, `#`, `->` or `{` — is its own item. See `docs/features/item-misc/README.md` and `docs/features/mop-up-2/README.md` - A based number whose digits come from a macro (`` 32'h`DM_ADDR ``, `` 8'b`BITS ``). The backtick must touch the base; `` 32'h `X `` stays a lex error. See `docs/features/mop-up-2/README.md` - Elaboration system tasks where a module or generate item belongs: `$fatal`, `$error`, `$warning`, `$info` — at module scope and inside generate `if`/`for`/`case` and `begin`/`end`, including a generate-`if` whose whole body is one of them. The argument list is a breakable group, like any other call. `` `error``/`` `warning`` compiler directives are passed through verbatim, like `` `define`` - `` `ifdef``/`` `ifndef``/`` `else``/`` `elsif``/`` `endif``, `` `define``, `` `undef``, `` `include`` and macro invocations written **between the elements** of a module header's port list, its parameter port list, an enum member list, an instantiation's `#( ... )` parameter overrides or an instance's `( ... )` connection list. The condition is not evaluated: both arms' elements are entries of the one list, exactly as at item position. The directive must be the last thing on its line, and the comma placement the source wrote is reproduced — including a comma written *inside* an `` `ifdef`` arm. A list may be nothing *but* a directive (``sub #(`include "config.vh") u (...)``). See `docs/features/directives-in-lists/README.md` and `docs/features/directives-in-instances/README.md` - Programs, interface classes, `alias`, `union tagged`, `specparam`, library map entries, and statement-form `expect`. `specify`, UDP `primitive`/`table`, `checker`, and `config` blocks are recognized as opaque blocks so vendored simulation models and formal collateral do not block the rest of a file; their internal layout is preserved. See `docs/features/vendor-formal-grammar/README.md` ### Historical syntax roadmap This roadmap records how parse coverage was raised, in measured-impact order. See `docs/features/corpus-check/README.md` for the 820-file corpus baseline: 1. ~~Macro invocation at module-item / statement position (`` `ASSERT_INIT(...) `` style)~~ — **done**; see `docs/features/macro-items/README.md`. Unblocked 179 corpus files and moved the parse rate from 35.2% to 57.1% 2. ~~Classes/constraints (mostly blocks DV/UVM code, not RTL) — the top blocker at 142 files, all `extends`~~ — **done**; see `docs/features/classes/README.md`. Unblocked 102 corpus files and moved the parse rate from 58.0% to 70.5%. 72 of the 142 `extends` files now format; the other 70 advanced to a second blocker, 34 of them to item 4 below, which is now the top blocker 3. ~~`bind` directives~~ — **done**; see `docs/features/bind/README.md`. Unblocked 28 corpus files and moved the parse rate from 81.8% to 85.2% 4. ~~Dynamic arrays and queues — now the top blocker at 41 files (`bit x[$]`, `int q[]`)~~ — **done**; see `docs/features/dynamic-types/README.md`. Queues (`x[$]`, `q[$]`/`q[$-1]` indexing, `[$:N]`), dynamic arrays (`int q[]`), wildcard associative arrays (`[*]`), `= {}` initializers, named call arguments (`f(.a(x))`) and `case (expr) inside` — unblocked 58 corpus files and moved the parse rate from 70.5% to 77.6%. All 7 `inside`-blocked files format; 28 of the 41 `$`-blocked and 17 of the 21 `.`-blocked do too, the rest advancing to named next blockers (`interface` at 25 files is now the top one — item 8 below) 5. ~~Declarations with identifier (typedef'd) types in some positions (`my_t [N-1:0] x;`)~~ — **done**; see `docs/features/types-decls/README.md`. With the rest of the `types-decls` bucket (anonymous `enum`/`struct` as a type, `struct packed` as a `parameter type` default, a typedef'd enum base type, nested anonymous structs, `localparam type` as a body item, and a `for` init declaring several variables) it unblocked all 11 files of the bucket and moved the parse rate from 90.2% to 91.6% 5b. ~~Macro invocation with a space before its argument list (`` `uvm_field_int (a, b) ``), a bare macro item followed by a declaration on the next line, `` `error``/`` `warning`` directives, and elaboration system tasks (`$error(...)`) at item position~~ — **done**; see `docs/features/item-misc/README.md`. Unblocked 25 corpus files and moved the parse rate from 77.6% to 80.6%; the 2 remaining files of those two buckets advanced to blockers in other categories 6. ~~`` `ifdef``/`` `define``/`` `include`` inside a port, parameter or enum list~~ — **done**; see `docs/features/directives-in-lists/README.md`. Two corpus files unblocked and six advanced to their next blocker (`picorv32.v` itself now parses 1986 lines further but still does not format — its next blocker is `restrict property`, item 7 below). The real payoff was the workspace index: `picorv32`, `picorv32_axi` and `picorv32_wb` now index (521 → 530 modules), taking cross-file external resolution from 87.0% to 93.6% on cleanly-parsed files. The instantiation half followed in `docs/features/directives-in-instances/README.md`: the same construct inside an *instantiation's* `#( ... )` overrides or an instance's `( ... )` connections, which unblocked the remaining 6 files. **No corpus file is blocked on a compiler directive any more** 7. ~~DPI~~ — **done**; see `docs/features/dpi-export/README.md`. DPI imports and exports plus package re-exports unblocked 10 corpus files and moved the parse rate from 80.6% to 81.8%; the 11th advanced to a `foreach` blocker in the dv-statements bucket. Still open in this item: non-simple casts 7b. ~~Concurrent assertions (`assert`/`assume`/`cover`/`restrict property`), `sequence`/`property` declarations~~ — **done**; see `docs/features/assertions/README.md`. Unblocked all 13 files of the `assertions` bucket and moved the parse rate from 85.2% to 86.8%. `picorv32.v` — 3000 lines of Verilog-2001, blocked on `restrict property` since item 6 — now formats end to end 8. ~~Interfaces/modports/clocking blocks~~ — **done**; see `docs/features/interfaces/README.md`. `interface … endinterface` (header `import`s, ANSI ports, parameters), `modport`, `clocking` blocks and `virtual` interface types in every type position unblocked 28 corpus files and moved the parse rate from 86.8% to 90.2%; the other 3 advanced to blockers in the `expressions` and `other` buckets. Still open in this item: specify blocks, `checker`, `program` and `interface class` — all rare in the corpus RTL (`let` landed with item 10 below) 9. ~~Expressions: casts with a non-simple base, streaming concatenations, `->`/`<->` implication, drive strengths, attributes on port connections, the `'{N{0}}` assignment-pattern replication, `inside` a macro, and `const ref` arguments~~ — **done**; see `docs/features/expressions-2/README.md`. Emptied the `expressions` bucket (21 files) plus one `other` file and moved the parse rate from 91.6% to 94.1% 10. ~~DV statements: `with` clauses, package-scoped/hierarchical `foreach`, `randcase`, `wait fork`, block-level `import`, `let`, omitted call arguments and statement labels~~ — **done**; see `docs/features/dv-statements/README.md`. Emptied the `dv-statements` bucket (26 files) and moved the parse rate from 94.1% to 97.1%; 24 of the 26 files format, the other 2 advanced to a macro-items blocker and to the `new obj` shallow-copy expression. `randsequence` remained unsupported at this point; it shipped as real nodes in 0.49.0. The other vendor/formal constructs listed here landed in 0.30.0 11. ~~A macro statement that ends its line followed by a symbol on the next one, the `new obj` shallow copy (IEEE 1800 §8.12), and a based number whose digits come from a macro (`` 32'h`DM_ADDR ``)~~ — **done**; see `docs/features/mop-up-2/README.md`. Unblocked the last 4 fixable corpus files and moved the parse rate from 97.1% to 97.6%. Every file still failing is in a deliberately unsupported category, except `compare_helper.sv`, whose `` `X_EACH_CSR 1 `` needs a macro body from another file — lucisv does not preprocess, so it stays a parse error 12. ~~Conditional-split constructs — an `` `ifdef``/`` `else`` region whose arms are each an incomplete fragment of one declaration (alternative heads sharing one body, alternative struct bodies sharing one closing)~~ — **done**; see `docs/features/directive-split/README.md`. Recovered as a verbatim item (exact source bytes, first line re-indented), never reformatted inside — the `constraint`/`covergroup`/assertions precedent. The recovery fires only when the failed arm left a bracket open inside a conditional region that is genuinely open at item scope; ordinary syntax errors near directives still refuse. Unblocked 13 corpus files and moved the parse rate from 97.6% to 99.1%. Still failing (7): macro-bracketed covergroups and `` `X_EACH_CSR`` (need macro expansion, a deliberate non-goal) and 5 files that are not valid standalone Verilog Fragment-mode support subsequently raised the current frozen corpus baseline to **814/820 (99.3%)**. The remaining six files require cross-file macro expansion, contain a conditional-split outlier, or are not valid standalone Verilog; none regressed when the vendor/formal and SVA grammars landed. Like ruff, `lucisv` refuses to output anything for a file it cannot fully parse, so it can never corrupt code. ## Editor setup `lucisv-server` is a language server: one binary, LSP over stdio, the same answers in every editor. It ships formatting, diagnostics as you type, semantic highlighting, hover (including single-step `` `define`` expansion), go-to-definition, references and document/workspace symbols — the full list, and what is deliberately *not* advertised yet, is in `docs/features/lucisv-server/README.md`. The editor now offers these refactorings alongside rename and port propagation: | Action | Behavior | |---|---| | Expand wildcard | Replace `.*` with declaration-order named connections; unmatched ports become `.p()` with a warning | | Convert ports to ANSI | Merge a legacy module header and its body port declarations, preserving comments and attributes | | Organize imports | Remove unused imports, merge exact duplicates and sort a top-of-scope run; uncertainty keeps the action conservative | | Extract module | Move selected whole module items into a named module, infer its interface, and insert the replacement instance; create a file when supported or append below the source module | | Inline module | Copy a separate-file module body into its instance site with simple named-connection substitution and collision-aware internal renaming | The [language-tools reference](docs/site/src/content/docs/reference/language-tools.md) records commands and refusal limits. Inline-module has a known transitive source-selection gap; review hierarchical uses through wrapper modules before applying it (topology handshake 33). In the VS Code hierarchy, **Star as DUT** groups a module’s children and parents into sections alongside Other Modules. Stars persist per workspace; `lucisv.hierarchy.duts` adds team-configured names, which are locked in the menu. **VS Code needs no separate binary**: every release on the [releases page](https://git.luci.ooo/lucio/lucisv/releases) carries a platform-specific `.vsix` with the binaries inside it — pick yours (`darwin-arm64`, `darwin-x64`, `linux-x64`, `linux-arm64`, `win32-x64`) and sideload it: ```bash code --install-extension lucisv--darwin-arm64.vsix ``` — or take `lucisv--all.vsix`, which carries all five platforms' binaries in one file and picks the right pair at startup, when the machine is not known in advance (or is Alpine, which VS Code never offers a Linux package to). Every other editor (and the universal `lucisv-.vsix`, the fallback for platforms not listed) finds `lucisv-server` on `PATH`; the binary comes from the same build as the CLI: ```bash cargo build --release # target/release/lucisv-server (and target/release/lucisv) cp target/release/lucisv-server ~/.local/bin/ # anywhere on PATH ``` Each editor also accepts an absolute path if you would rather leave the binary in `target/`. **VS Code** — a thin extension in `editors/vscode/` whose entire job is registering the file types and starting the server (bundled, from `PATH`, or from the `lucisv.serverPath` setting). To build the packages yourself: ```bash tools/release.sh # dist/lucisv-.vsix + the host platform package code --install-extension dist/lucisv--darwin-arm64.vsix ``` Sideloading is the supported install; the extension is not on any marketplace. Settings are listed in `editors/vscode/README.md`, along with the full steps, the F5 development flow and troubleshooting. **Neovim / Vim** — no plugin, just configuration. Neovim 0.11+: ```lua vim.filetype.add({ extension = { v = 'verilog', vh = 'verilog', sv = 'systemverilog', svh = 'systemverilog' } }) vim.lsp.config('lucisv', { cmd = { 'lucisv-server' }, filetypes = { 'verilog', 'systemverilog' }, root_markers = { 'lucisv.toml', '.lucisv.toml', '.git' }, }) vim.lsp.enable('lucisv') ``` `nvim-lspconfig`, Vim 9 (`vim-lsp`) and coc.nvim equivalents: `editors/nvim/README.md`. **Agents (MCP).** `lucisv-mcp` is lucisv as a Model Context Protocol server for coding agents: project overview, unit interfaces, outlines, one item's source, definition/references/hierarchy, diagnostics, and verified edits (format, lint fixes, rename, the port refactorings, single-item replace/insert/delete), each with `dry_run`. The platform `.vsix` packages carry it as a third binary and, on VS Code 1.101+, register it with agent mode — one server per workspace folder, under **MCP: List Servers** (`lucisv.mcp.enabled`, `lucisv.mcp.path`). For Claude Code or Cursor, run **lucisv: Copy MCP server config** in VS Code, or by hand: `cargo build --release -p lucisv_mcp`, then `claude mcp add lucisv -- lucisv-mcp --root .`. The tool list, the config snippets and the safety rules are in the [Agents (MCP) guide](docs/site/src/content/docs/guides/agents.md). **Which files the server indexes.** A filelist if the project has one — the `filelist` key of its `lucisv.toml`, or the editor setting `lucisv.filelist` (a path, absolute or relative to the workspace folder) — and then exactly the files it names. Otherwise the default `lucisv.index.scope = "folder"` starts from open-file folders, widens by `lucisv.index.scopeDepth` (default 2), and stays bounded by the workspace roots; `"workspace"` walks the full roots. With no folder open, the server stays in the current file's directory: depth 0 scans it flat; a positive depth walks its descendants but never climbs to a parent. Open buffers are always indexed on top. A filelist that cannot be read warns and falls back to the folder walk, so the index is never silently empty. **Checking the server without an editor.** `node editors/vscode/smoke.js ` spawns it exactly as the extension does and drives a whole `initialize`/`didOpen`/`shutdown`/`exit` session over stdio, exiting 0 only if the handshake and the advertised capabilities are intact — which tells you whether a failure is the server or your editor config. Its neighbour `node editors/vscode/restart_test.js` needs no binary at all: it drives the extension's server-restart chain (the one `lucisv.verbose` uses) against a scripted fake client, so a toggle can never be lost to a restart that was already in flight. **Formatting through an editor reads `lucisv.toml` too**, discovered from the buffer's own path by the CLI's rule, so format-on-save agrees with what `lucisv --check` does in CI. Precedence, highest first: `lucisv.toml`, then the editor's `lucisv.lineLength`/`lucisv.indent` settings, then the editor's tab size (indent only — the protocol carries no line-length), then the defaults. A broken config never blocks formatting: the buffer is formatted with the next rung down and the error is surfaced in the editor. ## Contributing / workflow This is a solo project — committing directly to `master` is allowed and expected; no PRs or review required. ## Building ```bash cargo build --release # binaries at target/release/{lucisv,lucisv-server} tools/gates.sh # every gate: fmt, clippy, build, each crate's suites, doc tests, corpus, node tools/gates.sh --only suites # just the per-crate test suites ``` `tools/gates.sh` runs each gate as its own guarded step with a kept log and prints a summary (`docs/features/release-gates/README.md`). Snapshot tests live in `crates/vlog_formatter/tests/fixtures/`; regenerate expected outputs only for intentional formatting changes with `UPDATE_SNAPSHOTS=1 tools/guard.sh -- cargo test -p vlog_formatter`. Table-driven cases live in `crates/vlog_formatter/tests/cases/`; lint cases live in `crates/vlog_linter/tests/cases/`. All tests, fuzzers, and corpus/tree sweeps must run through `tools/guard.sh` (8 GiB RSS / 30 minutes by default), as required by [CLAUDE.md](CLAUDE.md). A guard kill is a finding, not a reason to increase the limit. Documentation build instructions are in [docs/site/README.md](docs/site/README.md). ## Install and releases Prebuilt downloads live on the [releases page](https://git.luci.ooo/lucio/lucisv/releases): every tagged version carries **seven `.vsix` packages** — platform-specific ones for Apple Silicon and Intel macOS, x86-64 and ARM64 Linux (static musl) and Windows, each with `lucisv` and `lucisv-server` embedded, an all-platforms one carrying every pair at once for unknown or mixed machines, plus the universal no-binary fallback — and a `SHA256SUMS` to verify them with (`shasum -a 256 -c SHA256SUMS`). Sideload the one for your machine with `code --install-extension`. Standalone binaries are not published; build them with `cargo build --release` (or `tools/release.sh --cross` for the full set — the release binaries are cut from the same scripts). The macOS binaries inside the packages are smoke-tested on the build machine; the Linux and Windows ones are cross-built and audited (file type, dynamic-linkage, glibc-version ceiling), not executed — there is no Linux or Windows machine in the loop. To build the same artifact set yourself: ```bash tools/release.sh # host binaries + the .vsix + SHA256SUMS, into dist/ tools/release.sh --cross # ...plus the four cross-built platforms and the all package ``` The script itself publishes nothing anywhere; publishing is CI's job — pushing a `vX.Y.Z` tag builds all of the above on Gitea Actions and attaches it to a release, with that version's `CHANGELOG.md` section as the notes. Release notes are in [`CHANGELOG.md`](CHANGELOG.md); the full checklist — where the version number lives, how the `.vsix` is packaged, and what marketplace publishing would take if it ever happens — is in [`tools/RELEASING.md`](tools/RELEASING.md). lucisv is MIT licensed ([`LICENSE`](LICENSE)).