textDocument/willSaveWaitUntil is advertised and served, gated on a new lucisv.formatOnSave setting that defaults to off (a server that formats uninvited fights the editor's own format-on-save and doubles up); the decline is one comparison, before any buffer lookup. When on, the hook is textDocument/formatting with a different trigger: the same engine, the same all-or-nothing verified-output contract, settings resolved by the new format::settings_without_editor_options — the ladder minus the tabSize rung the protocol simply does not carry here, with the honest consequence (save-format can differ from manual format without a lucisv.toml) documented in the README, the VS Code setting description and the nvim README. Every save reason formats; refusals are shown per save, on purpose. 18 tests added across settings/format/server/e2e, including QA's executable proofs of the tab-size gap and its lucisv.toml resolution, a no-reindex/no-generation-bump guard for the new setting, and an idempotency round-trip through a real didChange. QA also fixed the stale 'not advertised' feature list in editors/nvim/README.md and sharpened the config-warning dedup claim to what the code does (once per buffer state) — reworded in the README, pinned by test. docs/features/will-save-wait-until/README.md Co-Authored-By: Claude Fable 5 <[email protected]>
766 lines
47 KiB
Markdown
766 lines
47 KiB
Markdown
# TODO — best practices adopted from ruff and Verible
|
||
|
||
Curated backlog for lucisv, drawn from `astral-sh/ruff` (architecture, CLI/UX,
|
||
fix model) and `chipsalliance/verible` (formatter safety, alignment,
|
||
waivers, and especially test methodology). Items reference the current
|
||
draft's files. Roughly ordered by priority within each section.
|
||
|
||
Legend: **[V]** = practice from Verible, **[R]** = from ruff, **[V+R]** = both.
|
||
|
||
---
|
||
|
||
## 1. Correctness safety net (highest priority)
|
||
|
||
- [x] **[V] Token-stream equivalence verification.** Verible's formatter
|
||
re-lexes its output and asserts it is lexically equivalent to the input
|
||
(`verilog_equivalence.cc`); on mismatch it emits the *original* text.
|
||
Add `verify_equivalence(input, output)` to `vlog_formatter`: re-lex both
|
||
through `vlog_parser::lexer`, compare token kinds + text (whitespace
|
||
excluded, comments included). Run it inside `format_source()` on every
|
||
call — not just in tests. This turns "the formatter can never corrupt
|
||
code" from a test-suite property into a runtime guarantee.
|
||
- [x] **[V] Convergence (idempotency) verification at runtime.** Verible
|
||
formats twice and checks a fixed point before writing. Do the same in
|
||
`format_source()` (optionally behind `--no-verify` for speed later).
|
||
Today idempotency is only asserted in `tests/fixtures.rs`.
|
||
- [x] **[V] Failsafe fallback semantics.** On any internal verification
|
||
failure, return the input unchanged *with a diagnostic and nonzero exit*,
|
||
never partially formatted output. Parse errors already behave this way
|
||
(README notes it); extend the same contract to the two checks above.
|
||
- [x] **[R] Panic containment.** ruff catches panics per-file and reports
|
||
them as errors instead of killing the whole run. Wrap per-file work in
|
||
`crates/lucisv/src/main.rs` with `std::panic::catch_unwind`.
|
||
- [x] **`@(* )` fails to lex** (bug-fix QA find): `(*` followed by anything
|
||
but `)` is unconditionally lexed as an attribute (`lexer.rs`), so a bare
|
||
space inside `@( * )`-style spellings errors out. Make the attribute
|
||
scan back off when the contents are just `*`.
|
||
→ `docs/features/lexer-cleanup/README.md`, with the BOM and non-ASCII
|
||
message fixes and the `lucisv check` lex-error silence fix.
|
||
- [x] **Recursion-depth limit in the parser.** Found by cli-polish QA:
|
||
~150 levels of expression nesting overflow the stack and abort the whole
|
||
process — uncatchable by `catch_unwind`, so mid-batch files after the
|
||
crash never get processed. Add an explicit depth counter in
|
||
`vlog_parser::parser` that returns a parse error past a documented limit
|
||
(ruff does the same). Do the same in the formatter's recursive walk.
|
||
|
||
- [ ] **Atomic in-place writes.** QA find during cli-filelist (2026-08-25,
|
||
pre-existing): `process_file` and the `--fix` path write with plain
|
||
`fs::write` (open/truncate/write) while `cache.rs` next door already
|
||
does tempfile+rename. Two workers reaching one inode through two
|
||
spellings (symlink alias — lexical dedup cannot see it) could tear a
|
||
file. Fix: tempfile+rename in both writers; optionally canonicalized
|
||
dedup keys as a second line of defense.
|
||
|
||
## 2. Formatter features
|
||
|
||
- [x] **[V] Format-off fences.** Support `// verilog_format: off` /
|
||
`// verilog_format: on` (accept a `lucisv: off/on` alias). Verible
|
||
implements this as "emit the original byte range verbatim" — the trivia
|
||
in `Meta` already carries comments, so detect fences during formatting in
|
||
`format.rs` and splice source text by span. Requires nodes to carry
|
||
byte spans (see §5, it's needed for LSP anyway).
|
||
→ `crates/vlog_formatter/src/fence.rs`; grammar, item-level semantics and
|
||
join rules in `docs/features/format-fences/README.md`. Item scopes only —
|
||
statement-level fences are documented as not implemented.
|
||
- [x] **[V] Range formatting: `--lines M-N[,M-N...]`.** Format only
|
||
constructs intersecting the given line ranges; emit everything else
|
||
verbatim. This is what makes adoption in dirty legacy codebases possible
|
||
(Verible ships `git-verible-verilog-format.sh` on top of it). Follow-up:
|
||
a `lucisv --diff-base <rev>` or contrib script that derives ranges from
|
||
`git diff`.
|
||
→ `crates/vlog_formatter/src/range.rs` (`format_range`, `LineRanges`), the
|
||
CLI's `--lines`, the server's `documentRangeFormattingProvider`, and
|
||
`tools/lucisv-changed.sh` for the `git diff` half of the follow-up (a
|
||
`--diff-base` flag inside lucisv is still open). The unit is one item;
|
||
modules and packages are descended into so a three-line edit does not
|
||
reflow a two-thousand-line body; statements and generate regions are
|
||
deliberately atomic. Fences outrank ranges, the cache is bypassed, and the
|
||
runtime safety net runs over the whole output — the convergence half by
|
||
replaying the per-item decisions, since line numbers move when text does.
|
||
578 corpus files × 8236 range trials: 0 refusals, and whole-file output is
|
||
byte-identical to before. Semantics, interaction rules and the honest
|
||
limits in `docs/features/range-formatting/README.md`.
|
||
- [x] **[V] Alignment inference for declaration/port/connection groups.**
|
||
Verible's most-loved feature: infer align-vs-flush-left intent from the
|
||
original spacing (≥4 excess spaces = author wants alignment), and break
|
||
alignment groups at blank lines and standalone comments
|
||
(`--alignment_group_boundary`). Start with the three constructs where RTL
|
||
culture demands it: port declarations, named connections (`.clk (clk)`),
|
||
and localparam/parameter lists. This needs original-spacing info
|
||
preserved through the lexer — record "excess spaces before token" as
|
||
trivia.
|
||
→ `crates/vlog_formatter/src/align.rs`; all three constructs ship (ports
|
||
align the name column, connections the `(`, parameters the name and `=`
|
||
columns). No lexer trivia was needed after all: `name_span` plus the
|
||
source text the formatter already holds gives both the preceding gap and
|
||
the token's column, so the spans suite is untouched. Zero churn on the
|
||
397-case table; 291 of 578 formattable corpus files now format
|
||
differently, with 0 verification errors and 0 round-trip failures over
|
||
2312 config-sweep runs. Rule, fixed-point argument and the parked columns
|
||
(`#( ... )` parameter ports, the type column, the trailing-comment column)
|
||
in `docs/features/alignment/README.md`.
|
||
- [x] **Comment inside port/param lists and assignment patterns is
|
||
dropped → refused** (found at scale by format-fences QA: 112 of 1868
|
||
corpus injection trials refuse with exit 2). The failsafe holds, but
|
||
this is the largest remaining comment-attachment gap; fix alongside the
|
||
three documented expression refusals (replication, compact bracket,
|
||
assign-value) from docs/features/formatter-bug-fixes and corpus-bugs.
|
||
→ `Meta::before_sep` keeps a comment on its element's side of the
|
||
separator, at every list kind; replication, gate arguments, header
|
||
imports, event lists, a connection's own parens and the enum dangling
|
||
bucket all gained comment slots too. Injection-harness refusal rate
|
||
2.3% → 0.4%. Still refused (documented, not hacked around):
|
||
`[a : b]`-style bracket interiors and a comment before a *procedural*
|
||
statement's `;` — see `docs/features/comments-round/README.md`.
|
||
→ Round 2 closed the two shapes a plain line-insertion sweep still hit
|
||
(14 of 989 trials): a comment before a module/instantiation head's `#(`
|
||
or `(` (four new `Vec<Comment>` fields), and a comment written next to
|
||
an `(* attribute *)`, which `Fmt::leading` now interleaves by span
|
||
instead of printing all comments then all attributes. Sweep 14 → 0; the
|
||
exhaustive per-line sweep's survivors are the shapes parked above plus
|
||
a comment before `else` — see `docs/features/comments-round-2/README.md`.
|
||
→ QA round-1 follow-up closed three more shapes with no node of their
|
||
own: between `bind` and its target (and before the bound module name),
|
||
before a call's `(` / inside an empty `()`, and on either side of a
|
||
postfix `with`. Still parked: a comment before a procedural statement's
|
||
`;`, and one inside a `bind`'s `: instance, list`.
|
||
- [x] **Two leading comments separated by one blank line come out
|
||
separated by two** (format-fences QA find, pre-existing): `leading`
|
||
pushes a HardLine after each comment and a BlankLine before the next.
|
||
Fix churns snapshots; take it with the comments round above.
|
||
→ `Fmt::leading_comments` emits the break *before* each comment
|
||
instead of after; 6 corpus files became fixed points, zero test churn.
|
||
- [x] **[R] `--diff` mode.** Like `ruff format --diff` / Verible's autofix
|
||
`patch` mode: print a unified diff instead of rewriting, for CI logs and
|
||
code review.
|
||
- [x] **[R] `--stdin-filename <path>`.** Editors pipe buffer contents via
|
||
stdin; the filename is needed for good error messages and (later)
|
||
per-directory config resolution.
|
||
|
||
## 3. CLI / UX (mostly ruff)
|
||
|
||
- [x] **[R] Config file discovery.** Search upward from each input file for
|
||
`lucisv.toml` / `.lucisv.toml` (analog of `ruff.toml` / `pyproject.toml`).
|
||
Keys: `line-length`, `indent`, `exclude` globs. CLI flags override file
|
||
config. Keep Verible's philosophy of *few* knobs — don't grow a
|
||
clang-format-sized option surface.
|
||
→ `crates/lucisv_core/src/config.rs` (lifted from crates/lucisv by lucisv-core-lift); discovery rule, TOML subset and
|
||
precedence in `docs/features/config-discovery/README.md`.
|
||
- [x] **[R] Parallel file processing.** ruff's speed story is embarrassing
|
||
parallelism over files. `main.rs` formats serially; use `rayon`
|
||
par_iter over the collected file list (formatting is already pure).
|
||
→ `crates/lucisv/src/main.rs`; pool sizing (8 MiB worker stacks, per the
|
||
recursion-limit handshake), the reworked panic hook and the
|
||
ordered-reporting determinism argument in
|
||
`docs/features/parallel-files/README.md`. `--threads N` pins the worker
|
||
count; output is byte-identical at any count. 3.6× on 10 cores.
|
||
- [x] **[R] Content-hash cache.** Skip files whose (content hash, config
|
||
hash, lucisv version) triple is unchanged, stored in `.lucisv_cache/`.
|
||
Do this *after* parallelism; it matters for big monorepo RTL trees.
|
||
→ `crates/lucisv_core/src/cache.rs` (`--no-cache`, `--cache-dir`); the key
|
||
stores the resolved `line-length`/`indent` *values*, and only the
|
||
"already formatted" verdict is ever cached — a would-reformat or an
|
||
error is re-checked every run, so `--check`/`--diff` cannot go stale.
|
||
Hand-rolled FNV-1a and a hand-rolled tab-separated store (no new
|
||
dependency); corrupt or another version's entries are ignored, never
|
||
fatal. Warm `--check` over the pre-formatted corpus: 7.7× on one
|
||
thread, 2.3× at the default thread count. Collision posture, the
|
||
semantics table and the cwd-relative-default limitation in
|
||
`docs/features/format-cache/README.md`.
|
||
- [x] **[R] Respect `.gitignore`** and add `--exclude` globs when walking
|
||
directories (`collect_files` in `main.rs` currently walks everything,
|
||
including e.g. generated netlists).
|
||
→ `--exclude` shipped with cli-polish; `.gitignore` is hand-rolled in
|
||
`crates/lucisv_core/src/walk.rs` (anchoring, directory-only, `!` negation,
|
||
nested files override) with a `--no-gitignore` escape hatch. The
|
||
supported subset and everything git does that this does not are listed
|
||
in `docs/features/parallel-files/README.md`.
|
||
- [x] **[V+R] Exit-code contract doc.** Already ruff-like (0 clean /
|
||
1 would-reformat / 2 error) — document it in README and freeze it; CI
|
||
scripts will depend on it.
|
||
|
||
## 4. Linter (`lucisv check`) — new crate `vlog_linter`
|
||
|
||
Design it ruff-style from day one (shared parse, fix model), with
|
||
Verible's rule ergonomics (waivers, configurable rules).
|
||
|
||
- [x] **[R] One parse, two tools.** `lucisv check` and `lucisv format` must
|
||
share `vlog_parser` output in a single invocation (`lucisv check --fix
|
||
--format` style workflows come free later). ~~*Not done:* `lucisv check`
|
||
re-parses today (tolerantly, which the formatter does not), and nothing in
|
||
`vlog_linter`'s API prevents sharing a tree later — only `LintContext` would
|
||
change.~~
|
||
→ Delivered on the linter side (`docs/features/one-parse/README.md`):
|
||
`LintContext::from_parse` accepts pre-built products, `ParsedSource` is the
|
||
owned bundle, `lucisv check` parses once per file (one lex instead of two —
|
||
corpus check 266 → 208 ms single-threaded), and `lucisv_server` lints from the
|
||
`Document` it already analyzed (didChange→publish 18 → 11 ms on picorv32.v).
|
||
Byte-identical output proven against a HEAD-worktree binary. The formatter
|
||
half stands unchanged by design: `lucisv format` needs the *strict* parse its
|
||
safety net is defined over, so a combined `check --fix --format` workflow
|
||
remains a future feature — but nothing in the API blocks it anymore.
|
||
- [x] **[V+R] Rule trait + registry.** Each rule: stable kebab-case name,
|
||
one-line summary, longer doc with style-guide rationale (Verible links
|
||
each rule to a style-guide section — do the same), and a
|
||
`check(node/token) -> Vec<Diagnostic>` over syntax tree or token stream.
|
||
→ `crates/vlog_linter`: `Rule` (name/summary/doc/check over a `LintContext`
|
||
carrying tokens, the tolerant AST, the source and a `LineIndex`),
|
||
`all_rules`/`default_rules`/`rule_by_name`/`select_rules`. Rules, waiver
|
||
grammar and the corpus baseline in `docs/features/linter-core/README.md`.
|
||
- [x] **[V] Diagnostic format `FILE:LINE:COL: message [rule-name]`** plus
|
||
**[R]** `--output-format json` for tooling from the start.
|
||
→ `lucisv check`; text sorted by file then position, JSON one array on stdout
|
||
(hand-rolled, no new dependency) with location, end_location, range and fix.
|
||
- [x] **[R] Fix applicability model.** ruff distinguishes *safe* vs
|
||
*unsafe* fixes (`--fix` vs `--unsafe-fixes`). Adopt it now — retrofitting
|
||
safety classification is painful.
|
||
→ `Fix { edits, applicability: Safe | Unsafe }` and `--fix` /
|
||
`--unsafe-fixes`. Only `no-tabs` and `no-trailing-whitespace` ship fixes
|
||
(both Safe); the unsafe path is plumbed and tested but no rule uses it yet.
|
||
- [ ] **[V] Waiver mechanisms:** inline `// lucisv: waive rule-name` (accept
|
||
`verilog_lint: waive` for migration), `waive-start`/`waive-stop` ranges,
|
||
and external waiver files (`waive --rule=X --line=N --location=glob`) for
|
||
code you can't touch. ruff's lesson: also warn about *unused* waivers.
|
||
- [x] inline `waive`, `waive-start`/`waive-stop`, both spellings, and the
|
||
`unused-waiver` pseudo-rule (unused, unknown rule, malformed, unmatched
|
||
`waive-stop`). A `verilog_lint:` waiver naming a rule lucisv lacks is
|
||
ignored rather than reported, so Verible-annotated code lints unedited.
|
||
- [ ] external waiver files — needs a file format, a discovery rule and a
|
||
precedence story against inline waivers.
|
||
- [x] **[V] Configurable naming rules via regex** (module/instance/
|
||
parameter/enum naming), with named presets like Verible's
|
||
(snake_case, ALL_CAPS, etc.).
|
||
→ Named presets ship, **without a regex dependency**: `parameter-name-style`,
|
||
`enum-name-style`, `struct-union-name-style` (Verible-default-on, Verible's
|
||
own names and patterns) and `module-name-style` (default-off — Verible has no
|
||
such rule to inherit a default from). Presets are character-class predicates
|
||
in `crates/vlog_linter/src/naming.rs`; the justification, the parked rules and
|
||
the corpus baseline are in `docs/features/lint-rules-2/README.md`.
|
||
*Not* done: making the style **configurable per rule** — that needs the
|
||
`lint` key in `lucisv.toml`, still open below.
|
||
- [x] **[V] `--generate_markdown`-style self-documentation** — generate the
|
||
rule reference from the registry so docs can't drift. ruff does the same
|
||
for its 900+ rules.
|
||
→ `vlog_linter::rules_markdown() -> String` renders the whole registry (name,
|
||
default on/off, fix applicability, summary, doc), with a golden shape test
|
||
and an "every registered rule appears" test. Renderable today via
|
||
`cargo run -p vlog_linter --example rules_markdown`; a `lucisv check
|
||
--rules-doc` flag is filed as a handshake for `crates/lucisv`.
|
||
- [ ] Seed rules (all syntactic, all from Verible's default set):
|
||
no-tabs, no-trailing-spaces, explicit-parameter-storage-type,
|
||
case-missing-default, always-ff-non-blocking / always-comb-blocking,
|
||
forbid `wire`-reg mixups in SV files, module-filename match.
|
||
- [x] `no-tabs`, `no-trailing-whitespace`,
|
||
`explicit-parameter-storage-type`, `case-missing-default`,
|
||
`always-ff-non-blocking`, `always-comb-blocking`, `module-filename` —
|
||
corpus baseline per rule in `docs/features/linter-core/README.md`.
|
||
- [x] `wire`/`reg` mixups in SV files — `wire-reg-mixup`, default on. The
|
||
SystemVerilog-ness decision is the **file extension** (`.sv`/`.svh`), so a
|
||
stdin buffer without `--stdin-filename` is silent. It flags the `reg`
|
||
keyword only; `wire` is legitimate SystemVerilog and is not flagged. Note
|
||
for the record: unlike the other seed rules this one is **not** from
|
||
Verible's default set — Verible has no wire/reg rule at all; the rationale
|
||
is IEEE 1800 (`logic` and `reg` are one type) and the lowRISC style guide.
|
||
See `docs/features/lint-rules-2/README.md`.
|
||
|
||
## 5. Testing — adapt Verible's methodology
|
||
|
||
Verible's formatter confidence comes from a few complementary layers
|
||
(`formatter_test.cc`, component tests, equivalence/convergence checks).
|
||
Adapt each:
|
||
|
||
- [x] **[V] Massive text-in/text-out table tests.** Verible's
|
||
`formatter_test.cc` is thousands of small `{input, expected}` pairs — the
|
||
backbone of the formatter. `small_cases` in
|
||
`crates/vlog_formatter/tests/fixtures.rs` is the seed; grow it into a
|
||
dedicated `tests/cases/` organized by construct (one file per area:
|
||
ports, expressions, case-statements, generate, comments, macros...).
|
||
Port cases directly from `formatter_test.cc` where our supported-syntax
|
||
overlaps — it encodes years of accumulated edge cases (translate expected
|
||
output to our style: 2-space indent matches, wrap style differs).
|
||
- [ ] **[V] Run equivalence + convergence on *every* test case**, not just
|
||
snapshots — once §1's `verify_equivalence` exists, assert it in the
|
||
fixture harness too, so every new case buys three checks for free.
|
||
- [ ] **[V] Component-level tests.** Verible tests the pipeline stages
|
||
separately (`token-annotator_test.cc`, `tree-unwrapper_test.cc`). Ours:
|
||
unit tests for `lexer.rs` trivia attachment (comment → leading/trailing
|
||
decisions, blank-line counting), `parser.rs` per-construct parse tests,
|
||
and `printer.rs` group-breaking behavior on synthetic docs.
|
||
- [x] **[V] Lint test harness with inline violation markers.** Port the
|
||
`LintTestCase` / `RunLintTestCases` idea: test cases embed expected
|
||
findings positionally in the source (Verible splices `ExpectedTokenInfo`
|
||
fragments inline). A Rust adaptation: annotate with a marker comment or a
|
||
`^^^` caret line, e.g.
|
||
`assert_lint::<NoTabsRule>("module m;\n\twire x;\n ^ no-tabs\nendmodule")`.
|
||
Exact-match: unexpected findings fail the test too.
|
||
→ File-driven: `crates/vlog_linter/tests/cases/*.lint` (76 cases, all 13
|
||
rules with violating/clean/waived/unused-waiver coverage) run by
|
||
`tests/lint_cases.rs` — `//^ <col> <rule>` markers carry the exact
|
||
`line:col` the CLI prints, matched exactly in both directions, with
|
||
stale-marker detection (a marker naming a dead rule fails the suite) and
|
||
12 self-policing tests pinning the failure reports. Format spec and
|
||
migration stats in `docs/features/lint-harness/README.md`.
|
||
- [x] **[V] `RunApplyFixCases` equivalent:** every autofix rule gets
|
||
`(input, fixed_output)` pairs, and the fixed output must itself be
|
||
lint-clean and formatter-idempotent.
|
||
→ A `----` section in a `.lint` case: the CLI's fix→re-lint loop must land
|
||
exactly on the expected text, leave nothing Safe-fixable, and the fixed
|
||
output must be accepted and converged by `vlog_formatter::format_source`
|
||
(inputs the formatter refuses must say `#tolerant`, enforced in both
|
||
directions like `#SKIP`; that population is empty today — all 5 fix cases
|
||
for the 2 fixable rules run the full cross-tool check).
|
||
- [ ] **[V] Error-case tests.** Table of inputs that must *fail* to parse
|
||
with the expected error position — locks in the failsafe path.
|
||
- [x] **[R] Real-world corpus check (ruff's "ecosystem check").** ruff
|
||
CI runs against big OSS codebases and diffs results between commits. Do
|
||
the same with permissively-licensed RTL: e.g. lowRISC Ibex, OpenTitan,
|
||
PULP cores, picorv32. Script: clone pinned revs, run lucisv over every
|
||
`.sv/.v`, report parse-success rate + equivalence/convergence failures;
|
||
fail CI on regression. Also the honest tracker for the "not yet
|
||
supported" list in README.
|
||
→ `tools/corpus_fetch.sh` + `tools/corpus_check.sh`, baseline and
|
||
findings in `docs/features/corpus-check/README.md`. CI wiring is the
|
||
one part left open (network access is a separate decision).
|
||
→ Latest movement: classes/constraints
|
||
(`docs/features/classes/README.md`) took the corpus from 476/820
|
||
formattable (58.0%) to **578/820 (70.5%)** — 102 files gained, 0 lost,
|
||
0 verification errors, 0 crashes, checked by diffing the two TSVs by
|
||
path. 72 of the 142 `extends`-blocked files now format; the other 70
|
||
advanced to a second blocker, and the new top blocker is dynamic
|
||
arrays and queues (README roadmap item 4, 41 files).
|
||
→ Dynamic types (`docs/features/dynamic-types/README.md`) then took it
|
||
from 578/820 to **636/820 (77.6%)** — 58 files gained, 0 lost, 0
|
||
verification errors, 0 crashes, all 636 round-tripped individually.
|
||
Queues/dynamic arrays, named call arguments and `case ... inside` are
|
||
done; the new top blocker is `interface` declarations (25 files,
|
||
README roadmap item 8), then `` `else`` inside an element (13, the
|
||
documented directives-in-lists non-goal) and `` `uvm_field_int `` (11,
|
||
the documented macro-items lexer gap).
|
||
→ item-misc (`docs/features/item-misc/README.md`) then took it from
|
||
636/820 to **661/820 (80.6%)** — 25 files gained, 0 lost, passing set
|
||
verified as a strict superset. The `` `uvm_field_int `` gap is closed
|
||
(in the parser, at item position only — the lexer glue stays parked for
|
||
the reason `docs/features/lexer-cleanup/README.md` gives), along with a
|
||
bare macro item followed by a declaration on the next line,
|
||
`` `error``/`` `warning`` directives and elaboration system tasks
|
||
(`$error`/`$fatal`/`$warning`/`$info`) at item position. `interface`
|
||
(31 files) and `bind` (28) are now the top two blockers.
|
||
→ bind (`docs/features/bind/README.md`) then took it from 671/820
|
||
(81.8%, the baseline after round 21) to **699/820 (85.2%)** — all 28
|
||
`bind` files gained, 0 lost, passing set verified as a strict superset.
|
||
`interface` (31 files) is now the top blocker.
|
||
→ interfaces (`docs/features/interfaces/README.md`) then took it from
|
||
712/820 (86.8%, the baseline after round 21) to **740/820 (90.2%)** —
|
||
28 of the 31 `interface` files gained, 0 lost, passing set verified as
|
||
a strict superset and all 28 round-tripped individually.
|
||
`interface`/`modport`/`clocking` and `virtual` interface types in
|
||
every type position are done; the 3 files left advanced to blockers in
|
||
the `expressions` and `other` buckets. `dv-statements` (26 files) is
|
||
now the top blocker.
|
||
→ expressions-2 (`docs/features/expressions-2/README.md`) then took it
|
||
from 751/820 (91.6%, the baseline after round 21) to **772/820
|
||
(94.1%)** — 20 of the 21 `expressions` files plus the `dv_utils_pkg.sv`
|
||
`other` file gained, 0 lost, passing set verified as a strict superset.
|
||
Casts over any constant primary, streaming concatenations, `->`/`<->`
|
||
implication, drive strengths on continuous assigns, attributes on named
|
||
port connections, the `'{N{0}}` pattern replication, `inside` a macro
|
||
and `const ref` arguments are done; the one file left
|
||
(`compare_helper.sv`) advanced to a macro-items blocker
|
||
(`` `MACRO expr`` in expression position). `dv-statements` (26 files)
|
||
is still the top blocker.
|
||
→ dv-statements (`docs/features/dv-statements/README.md`) then took it
|
||
from 772/820 (94.1%, the baseline on the same tree) to **796/820
|
||
(97.1%)** — 24 of the 26 `dv-statements` files gained, 0 lost, passing
|
||
set verified as a strict superset. `randomize() with { ... }`,
|
||
array-method `with (expr)`, package-scoped and hierarchical `foreach`,
|
||
`randcase`, `wait fork`, block-level `import`, `let`, omitted call
|
||
arguments, statement labels and a stray `;` after a task/function
|
||
footer are done, along with a comment written before `else` (which had
|
||
been crossing the keyword and failing verification). The 2 files left
|
||
advanced to blockers other clusters own: `dv_base_vseq.sv` to
|
||
macro-items (a bare macro followed by `@` on the next line),
|
||
`riscv_instr.sv` to the `new obj` shallow-copy expression.
|
||
`directive-split` (14 files) is now the top blocker.
|
||
→ mop-up-2 (`docs/features/mop-up-2/README.md`) then took it from
|
||
796/820 (97.1%, the baseline on the same tree) to **800/820 (97.6%)**
|
||
— 4 files gained, 0 lost, passing set verified as a strict superset. 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 are a macro (`` 32'h`DM_ADDR ``) are done; the
|
||
`lex-macro-number` bucket is gone. `compare_helper.sv` stays failing
|
||
and is not fixable: `` `X_EACH_CSR 1 `` needs the macro's body, which
|
||
lives in a file lucisv deliberately does not read. `directive-split` (14
|
||
files) is still the top blocker, and every remaining failure is in a
|
||
deliberately-unsupported category.
|
||
- [ ] **[R] Fuzzing.** ruff fuzzes its parser. `cargo-fuzz` targets:
|
||
(a) parser must never panic on arbitrary bytes, (b) for inputs that
|
||
parse, format must satisfy equivalence + convergence.
|
||
- [ ] **[R] Consider `insta`** for the snapshot harness (review workflow
|
||
`cargo insta review` beats `UPDATE_SNAPSHOTS=1`), keeping the
|
||
idempotency loop from `fixtures.rs`.
|
||
|
||
## 6. LSP: full editor support (a first-class goal, not a maybe)
|
||
|
||
Goal (owner's requirement, 2026-08-19): lucisv becomes a language server
|
||
for VS Code and Vim/Neovim with feature parity, for Verilog/
|
||
SystemVerilog, with what the Python VS Code stack (ruff + Pylance)
|
||
offers over LSP — scoped to **synthesizable Verilog first**:
|
||
|
||
- semantic syntax highlighting (`semanticTokens`)
|
||
- formatting (document + range) and lint diagnostics as you type
|
||
- go-to-definition and find-all-references
|
||
- hover: declaration/type info, and **`` `define`` expansion on hover**
|
||
(hover a macro usage → see its value/body)
|
||
- document + workspace symbols; later: completion, rename, signature
|
||
help for module instantiation
|
||
- **cross-file resolution through header imports**: `import pkg::*;` /
|
||
`import pkg::name;` at the top of a file or in a module header must
|
||
resolve into the package's file anywhere in the workspace (workspace
|
||
index of modules/packages; `` `include`` paths resolved too)
|
||
|
||
One server binary serves both editors (VS Code via a thin extension,
|
||
Vim/Neovim via built-in LSP config); no editor-specific logic below the
|
||
protocol layer. Foundation decisions that are cheap now and expensive
|
||
later:
|
||
|
||
- [x] **Byte spans on every token and AST node.** Prerequisite for
|
||
everything in this section (and for §2 fences/range formatting).
|
||
`token.rs` / `ast.rs` should carry `TextRange { start, end }` offsets;
|
||
add a line-index utility (ruff's `ruff_source_file`) for offset↔line:col.
|
||
→ `docs/features/spans/README.md`. `vlog_parser::span::TextRange` on every
|
||
token, comment and node; `vlog_parser::line_index::LineIndex` for
|
||
offset↔line:col; token-level losslessness is a test
|
||
(`crates/vlog_parser/tests/spans.rs`).
|
||
- [x] **Error-tolerant parsing mode.** A formatter may refuse broken input;
|
||
an LSP cannot — code is mid-edit most of the time. Add recovery in
|
||
`parser.rs`: on statement-level error, record a diagnostic, skip to a
|
||
sync token (`;`, `end`, `endmodule`), continue. Formatter keeps requiring
|
||
zero errors; the LSP consumes the partial tree.
|
||
→ `vlog_parser::parse_source_tolerant(src) -> (SourceFile,
|
||
Vec<ParseDiagnostic>)`; unparsable ranges become `ItemKind::Error` /
|
||
`StmtKind::Error` leaves. Sync tokens, the four guarantees and the
|
||
deliberate gaps (no tolerant *lexer*, no recovery inside headers or lists)
|
||
in `docs/features/error-recovery/README.md`. `parse_source` unchanged.
|
||
- [ ] **Keep the CST lossless.** Current design (trivia in `Meta`) is
|
||
format-oriented; verify every source byte is reachable from the tree
|
||
(tokens + trivia + spans). A `reconstruct(tree) == input` round-trip test
|
||
makes losslessness a tested invariant — this is what makes the same tree
|
||
serve formatter, linter, and highlighter. If gaps appear, consider a
|
||
rowan-style green tree (rust-analyzer / ruff direction) rather than
|
||
patching `Meta`.
|
||
- [x] **New crate `vlog_semantic`** (analog of `ruff_python_semantic`):
|
||
symbol tables per scope (module/package/function/block/generate), binding
|
||
→ references. Serves go-to-definition/hover first, then semantic lint
|
||
rules (unused-signal, undriven-net) which are the lint rules people
|
||
actually want and Verible *can't* do (it's syntax-only — this is the
|
||
differentiation opportunity).
|
||
→ `vlog_semantic::analyze(&SourceFile, src) -> Semantics`, never failing,
|
||
with `symbol_at` / `definition_of` / `references_of` / `document_symbols`.
|
||
Two-pass bind-then-resolve (so forward references work), imports of
|
||
in-file packages resolved and all others kept as
|
||
`Resolution::ExternalCandidate` for the workspace index below. Rules,
|
||
simplifications and the corpus baseline (79.5% of uses resolved in-file on
|
||
cleanly-parsed corpus files, 19.6% external, 0.9% unresolved) in
|
||
`docs/features/vlog-semantic/README.md`.
|
||
→ The crate's biggest named gap — "no name declared inside a class body
|
||
is indexed, hovered or navigable" (the classes round's handshake) — has
|
||
since closed: `docs/features/class-semantics/README.md` binds classes
|
||
(`SymbolKind::Class`, `ScopeKind::Class`, members, `extends`,
|
||
`this`/`super`, out-of-body methods, the honest
|
||
`Resolution::InheritedCandidate` for what only a base class could
|
||
supply), indexes classes and their members in the workspace layer, and
|
||
grows the corpus tables by +4 232 symbols / +16 631 references (clean
|
||
files: 74.0 % in-file, 17.9 % external, 7.1 % inherited, 1.0 %
|
||
unresolved, 0 unplaced).
|
||
- [x] **`` `define`` table for hover expansion.** Record every
|
||
`` `define`` (name, params, body text, source span) during lexing
|
||
instead of treating it as fully opaque — no expansion during
|
||
formatting (that non-goal stands), but the table feeds hover
|
||
(`` `WIDTH`` → "defined as 8 in defs.svh:12") and later single-step
|
||
macro expansion display. Cheap to collect now that directives carry
|
||
`RawText`.
|
||
→ `vlog_parser::defines::collect_defines(&tokens) -> DefineTable`, a
|
||
post-lex pass with zero lexer changes. `Define { kind, name, params,
|
||
body, span, name_span }`; every definition of a name is kept
|
||
(`all`/`latest`) and `` `undef`` is recorded as an event. Body
|
||
normalization (backslash-newline removed, nothing else touched) and the
|
||
gaps — no `` `ifdef`` evaluation, no cross-file `` `include`` — in
|
||
`docs/features/define-table/README.md`. Hover itself waits on
|
||
`lucisv_server`; this is only the table.
|
||
- [x] **Workspace index for cross-file navigation.** Map module/package/
|
||
typedef names → (file, span) across all workspace files, so header
|
||
imports (`import pkg::*;`) and instantiations resolve to definitions
|
||
in other files. Start as a full-scan-on-startup index (Verilog
|
||
codebases are small); incrementality comes with salsa later.
|
||
→ `vlog_semantic::WorkspaceIndex::build(files) `+
|
||
`resolve_external(&Semantics, &WorkspaceIndex) -> ExternalResolutions`,
|
||
a two-layer design: the index is a full scan (860 corpus files in 0.7 s),
|
||
the answers arrive as an overlay keyed by `ReferenceId` and `Semantics`
|
||
is never mutated. Package/module members and per-file `` `define``
|
||
tables are indexed too, so `import p::*`, `p::x` and `.port(...)` all
|
||
reach into the other file. On cleanly-parsed corpus files the workspace
|
||
answers **87 % of the external candidates**, taking the unresolved-
|
||
external rate from 19.6 % to 2.6 % of all references. Duplicate-name
|
||
policy, `` `define`` lookup (no include graph → no resolution order) and
|
||
the honest gaps in `docs/features/workspace-index/README.md`.
|
||
→ The index's biggest named gap has since closed: accepting `` `ifdef``
|
||
inside a port/parameter/enum list (README roadmap item 6,
|
||
`docs/features/directives-in-lists/README.md`) means `picorv32`,
|
||
`picorv32_axi` and `picorv32_wb` index at all — 521 → 530 modules,
|
||
8044 → 9174 exported members, external candidates answered 87.0 % → 93.6 %
|
||
on cleanly-parsed files (unresolved-external rate 2.6 % → 1.3 % of all
|
||
references). The instantiation half followed in
|
||
`docs/features/directives-in-instances/README.md` (directives in an
|
||
instantiation's `#( ... )` overrides and an instance's `( ... )`
|
||
connections); after it **no corpus file is blocked on a compiler directive
|
||
at all**, so nothing is left unindexed for this reason. The *index* counts
|
||
above did not move (530 modules, 9174 exported members, 502 defines — the
|
||
six files it unblocked have headers that already parsed, so their modules
|
||
were already indexed); what moved is 6 more files that now format, and with
|
||
them external candidates answered 93.6 % → **94.0 %** on cleanly-parsed
|
||
files (unresolved-external rate 1.3 % → **1.2 %**).
|
||
- [x] **New crate `lucisv_server`** (analog of `ruff_server`): LSP over
|
||
stdio via `tower-lsp` or `lsp-server`. Order of capabilities:
|
||
1. `textDocument/formatting` + `rangeFormatting` (reuses §2 `--lines`),
|
||
2. publish parse/lint diagnostics,
|
||
3. `semanticTokens` for highlighting (needs only the lexer + spans),
|
||
4. `hover` (decl info + define table) / `definition` / `references`
|
||
(needs `vlog_semantic` + workspace index),
|
||
5. document/workspace symbols; then completion, rename, signature
|
||
help for instantiations.
|
||
→ `crates/lucisv_server`, binary `lucisv-server`, on `lsp-server` +
|
||
`lsp-types` (synchronous, no async runtime). **Shipped:**
|
||
`textDocument/formatting`, `textDocument/rangeFormatting` (round 18, on §2's
|
||
`--lines`), parse diagnostics on didOpen/didChange/didSave,
|
||
`semanticTokens/full`, `hover` (in-file and workspace `` `define``
|
||
expansion, declaration snippets), `definition` (both resolution layers,
|
||
all locations when ambiguous), `references` (in-file), `documentSymbol`
|
||
and `workspace/symbol`. **Not shipped, deliberately:** ~~`rangeFormatting`
|
||
(waits on §2 `--lines`)~~ **delivered**, lint diagnostics (waits on
|
||
`vlog_linter`) **delivered**, cross-file references,
|
||
completion/rename/signature help. Byte↔UTF-16
|
||
position conversion, the state/staleness model and the dependency audit
|
||
are in `docs/features/lucisv-server/README.md`.
|
||
- [x] **Editor packaging.** A minimal VS Code extension (launch the
|
||
server, register file types) and a documented Vim/Neovim `lspconfig`
|
||
snippet. No editor-specific features beyond launching.
|
||
→ `editors/vscode/` (41-line plain-JS `extension.js` on the official
|
||
`vscode-languageclient`, pinned `9.0.1`; one setting, `lucisv.serverPath`;
|
||
`.v`/`.vh`→`verilog`, `.sv`/`.svh`→`systemverilog`; no grammar — semantic
|
||
tokens come from the server; no commands, no status bar) and
|
||
`editors/nvim/README.md` (`vim.lsp.config` for Neovim 0.11+, plus
|
||
`nvim-lspconfig`, Vim 9 `vim-lsp` and coc.nvim). `editors/vscode/smoke.js`
|
||
is the pre-publish check: zero-dependency node, spawns the server with the
|
||
extension's exact contract and drives `initialize`/`didOpen`/`shutdown`/
|
||
`exit` over hand-rolled framing. Manual install steps only — CI packaging
|
||
and Marketplace publishing are out of scope, and `publisher` is a
|
||
placeholder. `docs/features/editor-packaging/README.md`.
|
||
- [ ] **Salsa-style incrementality — defer.** ruff's `ruff_db` uses salsa;
|
||
don't take that dependency until hover/definition across files exists.
|
||
Per-file recompute is fine at Verilog file sizes.
|
||
- [x] **Release prep.** `LICENSE` (MIT), `CHANGELOG.md` (v0.2.0), version
|
||
bumped to 0.2.0 across the workspace and the extension, `tools/release.sh`
|
||
(release binaries + `.vsix` + `SHA256SUMS` into a gitignored `dist/`) and
|
||
`tools/RELEASING.md`. `docs/features/release-prep/README.md`.
|
||
**Publishing (owner actions):** fully optional and deferred per the owner
|
||
(2026-08-19) — sideloading the `.vsix` is the supported path. If it is ever
|
||
revisited, only the owner can do it: create a Marketplace publisher id and
|
||
replace `REPLACE-ME` (done 2026-08-25: publisher `guoliangchen`, author
|
||
Guoliang Chen), hold the `vsce`/`ovsx` tokens, supply an extension
|
||
icon, and confirm the public repo URL. Commands are in `tools/RELEASING.md`'s
|
||
appendix.
|
||
|
||
## 7. Deliberate non-goals (also a best practice)
|
||
|
||
- No preprocessor expansion *in the formatter*: like Verible, format
|
||
unpreprocessed source and never expand macros into the output. (The
|
||
LSP's define table in §6 *records* definitions for hover display —
|
||
that is bookkeeping, not expansion, and doesn't weaken this rule.)
|
||
- No option explosion: Black/ruff's lesson — every knob halves the value
|
||
of a canonical style. Alignment inference (§2) is the culturally
|
||
necessary exception.
|
||
- No semantic claims in v1 lint rules: syntax-only rules first (Verible's
|
||
scope), semantic rules only after `vlog_semantic` exists.
|
||
|
||
## 8. Refactoring — the rope port (owner request, 2026-08-24)
|
||
|
||
Port the ideas of `python-rope/rope` to Verilog/SV, server-first. The full
|
||
rope→Verilog mapping, feature checklist and milestone specs live in
|
||
`docs/features/refactor/README.md` — that file is the source of truth; this
|
||
section only tracks the milestones.
|
||
|
||
- [x] **M1 `filelist`** — EDA `.f` filelist defines the index scope
|
||
(`-f` nesting, `+incdir+`/`+define+` recorded, env vars); fallback:
|
||
workspace walk, then current file's directory when rootless.
|
||
- [x] **M2 `refactor-rename`** — new crate `vlog_refactor`; LSP
|
||
`prepareRename`/`rename` for every symbol kind `vlog_semantic` resolves,
|
||
cross-file, whole-edit-or-nothing verified by re-parse.
|
||
- [x] **M3 `refactor-ports`** — add/remove/propagate module ports across
|
||
the declaration and every instantiation (named/ordered/`.*`).
|
||
- [x] **M4 `refactor-instantiate`** — module hinting: instantiation
|
||
skeleton completion from the definition, auto-connect, signature help.
|
||
- [x] **M5 `completion-core`** — keyword + project-wide identifier
|
||
completion (token-harvested, comments/strings excluded), merged with
|
||
M4's module snippets; version 0.3.0.
|
||
- [x] **M6 `completion-templates`** — context-gated statement/item snippet
|
||
completion from the server (if/else, case, always, loops, declarations),
|
||
reconciled with the static VS Code snippets; version 0.4.0.
|
||
- [x] **M7 `references-nav`** — cross-file find-all-references (reuse
|
||
M2's collection machinery), document highlight, folding ranges from the
|
||
rainbow's pair data.
|
||
- [x] **M8 `inlay-hints`** — port-name hints on ordered connections and
|
||
parameter-name hints on ordered `#(...)` overrides, from the index.
|
||
- [x] **M9 `file-watching`** — `workspace/didChangeWatchedFiles` for
|
||
sources and the filelist; reindex on external changes (git pull,
|
||
filelist edits outside the editor).
|
||
- [x] **M10 `include-nav`** — clickable `` `include`` lines resolved
|
||
through the filelist's `+incdir+`s; cross-file `` `define`` lookup
|
||
along the include graph.
|
||
- [x] **M11 `hierarchy`** — module hierarchy both directions (who
|
||
instantiates X / what X instantiates) over LSP callHierarchy.
|
||
- [x] **M12 `semantic-lints`** — unused-signal, undriven-net,
|
||
multiply-driven: the first semantic lint rules on `vlog_semantic`.
|
||
- [x] **M13 `cli-filelist`** — `lucisv -f files.f` on the command line,
|
||
reusing M1's parser; format/lint exactly the project's files.
|
||
- [x] **M14 `macro-expansion`** — single-step macro expansion on hover
|
||
(the define-table README's promised follow-up); version 0.5.0 with a
|
||
CHANGELOG entry covering M7–M14.
|
||
- [ ] Backlog (extract module, inline, `.*` expansion, ANSI conversion,
|
||
organize imports, …) — triaged in the umbrella README after M5.
|
||
|
||
## 9. LSP 3.18 protocol audit (2026-08-26)
|
||
|
||
Systematic comparison of `lucisv_server` against the LSP 3.18
|
||
specification. What we implement: hover, definition, references,
|
||
documentHighlight, documentLink, document/workspace symbols, folding,
|
||
semanticTokens/full, inlayHint, completion, inlineCompletion (3.18),
|
||
signatureHelp, codeAction + executeCommand, rename + prepare,
|
||
callHierarchy, formatting + rangeFormatting, push diagnostics, dynamic
|
||
file-watcher registration, configuration push. Below is everything
|
||
major that's missing, ordered by priority. The `resolve` endpoints
|
||
(completionItem, codeAction, inlayHint, documentLink, workspaceSymbol)
|
||
are **deliberately** unadvertised — every item is returned complete —
|
||
and are not gaps.
|
||
|
||
### 9a. Compliance and high-value (round 1)
|
||
|
||
- [x] **`executeCommand` must deliver its edit via `workspace/applyEdit`.**
|
||
Today `ports::execute`'s `WorkspaceEdit` is returned as the request's
|
||
*result* (`server.rs`, `ports.rs:79`), which the spec does not define
|
||
and standard clients drop on the floor — `vscode-languageclient` does
|
||
not apply executeCommand results and `editors/vscode/extension.js`
|
||
has no custom handler, so `lucisv.addPort`/`removePort`/`propagate`
|
||
invoked as *commands* currently do nothing in every stock client (the
|
||
code-action path is unaffected: those carry the edit inline). Fix:
|
||
push a `workspace/applyEdit` request, return `null` as the command
|
||
result, and read the `ApplyWorkspaceEditResponse` (the one client
|
||
response we can no longer ignore wholesale). Gate on the client's
|
||
`workspace.applyEdit` capability with the old return-the-edit
|
||
behavior as the documented fallback.
|
||
→ `docs/features/apply-edit/README.md`; the edit is pushed with a
|
||
`lucisv: <command>` label, the result is `null`, and a refusal is shown
|
||
as an ERROR naming the command. Watcher-registration answers stay
|
||
ignored; `editors/vscode/extension.js` needed no change.
|
||
- [x] **Pull diagnostics (3.17): `textDocument/diagnostic` +
|
||
`workspace/diagnostic`.** The modern model — client controls timing,
|
||
prioritizes visible editors, caches via `resultId`/`unchanged`.
|
||
Advertise `DiagnosticOptions` (`inter_file_dependencies: true` — a
|
||
save can change other files' diagnostics through the index;
|
||
`workspace_diagnostics`), compute from the same parse+lint pass that
|
||
feeds `publish`, answer `Unchanged` when the buffer version and index
|
||
generation both stand. Keep push for clients that don't send
|
||
`text_document.diagnostic` capability; never run both models for the
|
||
same client (double diagnostics).
|
||
→ `docs/features/pull-diagnostics/README.md`; one generation counter is
|
||
the whole `resultId` (bumped by `set_document` and `reindex`), the
|
||
push gate sits in `send_diagnostics` so the `didClose` clear is
|
||
suppressed too, and `workspace/diagnostic` reports the open buffers —
|
||
the honest limit, stated there.
|
||
- [x] **`textDocument/selectionRange`** — expand-selection. Cheap for
|
||
us: the scope-pair matcher (`pairs.rs`) and AST spans already give
|
||
the nesting chain; walk offset → enclosing token → statement → item →
|
||
scope → file, one linked chain per input position.
|
||
→ `docs/features/selection-range/README.md`
|
||
(`crates/lucisv_server/src/selection.rs`); token, AST, scope-pair and
|
||
file ranges are collected and filtered down to what strictly nests. No
|
||
expression step — deliberate, and recorded there.
|
||
|
||
### 9b. High-value, next rounds
|
||
|
||
- [x] **Incremental text sync** (`TextDocumentSyncKind::INCREMENTAL`).
|
||
Full-buffer sync on every keystroke scales poorly; apply
|
||
range-scoped `contentChanges` in order, with a full-text fallback on
|
||
any malformed change. Touches `set_document` and the staleness model
|
||
in `docs/features/lucisv-server/README.md`.
|
||
→ `docs/features/incremental-sync/README.md`
|
||
(`crates/lucisv_server/src/sync.rs`); one pure
|
||
`apply_changes(text, changes) -> String` over `convert::Positions`, a
|
||
fresh line table per change so each range sees the previous one's
|
||
result, rangeless changes still replacing the whole buffer, and every
|
||
desynced position clamped (line past EOF, character past line end,
|
||
surrogate half rounds forward, `start > end` becomes an insertion).
|
||
Still one `set_document` — one reparse, one generation bump, one
|
||
publish — per notification. Advertised as `TextDocumentSyncOptions`
|
||
with the open/close and `save.includeText: false` values a bare `Kind`
|
||
already implied, so no client's save behavior moved.
|
||
- [x] **`textDocument/willSaveWaitUntil`** — the protocol-native
|
||
format-on-save hook (client-side `editor.formatOnSave` already works;
|
||
this serves the editors without it).
|
||
→ `docs/features/will-save-wait-until/README.md`; advertised as
|
||
`willSaveWaitUntil: true` (the plain `willSave` notification stays
|
||
unadvertised — there is nothing for us in it), and gated on a new
|
||
`lucisv.formatOnSave` setting that is **off** by default, so a client
|
||
with its own format-on-save never formats twice. On, it is
|
||
`textDocument/formatting` with a different trigger: same engine, same
|
||
all-or-nothing edit, same `[]` for an already-formatted buffer, and the
|
||
settings ladder minus its `tabSize` rung because the request carries no
|
||
`FormattingOptions`. Every save reason formats; an unopened buffer and
|
||
the off state both answer `null`.
|
||
- [ ] **Semantic tokens `range` + `full/delta`** — we set
|
||
`range: None` and no delta, so clients re-request whole-file token
|
||
sets on every edit. Delta needs `resultId` bookkeeping per buffer.
|
||
- [ ] **Work-done progress** — `reindex()` is a synchronous full
|
||
rescan on every save with no `window/workDoneProgress` reporting;
|
||
on a big filelist the server just goes quiet.
|
||
- [ ] **`$/cancelRequest`** — the loop handles requests sequentially
|
||
and ignores cancellation; at minimum answer already-cancelled queued
|
||
requests with `RequestCancelled`.
|
||
|
||
### 9c. Moderate value, Verilog-shaped
|
||
|
||
- [ ] **Goto type definition** — from a net/variable use to its
|
||
typedef/struct/enum/interface declaration; real value once
|
||
`vlog_semantic` tracks declared types of bindings.
|
||
- [ ] **Linked editing range** — edit `module m` and its
|
||
`endmodule : m` label together (`end : label`, `endfunction : name`,
|
||
etc.). A genuinely good fit for SV's closing labels.
|
||
- [ ] **Code lens** — "N instantiations" above each module header from
|
||
the hierarchy index; `codeLens/resolve` unnecessary (counts are
|
||
cheap), `workspace/codeLens/refresh` on reindex.
|
||
- [ ] **On-type formatting** — conspicuous absence for a
|
||
formatter-first server; candidate trigger: newline (indent the new
|
||
line per block nesting), `;` (reformat the finished statement).
|
||
- [ ] **Type hierarchy (3.17)** — arguably the semantically correct
|
||
home for the module hierarchy (and later interface/class extends
|
||
chains); keep callHierarchy as the compatibility surface.
|
||
- [ ] **File operations** — `workspace/willRenameFiles`: renaming a
|
||
`.sv/.svh` rewrites `` `include`` lines that reference it (the
|
||
include graph exists); `didRename/didDelete` as cheaper index nudges
|
||
than the watcher round-trip.
|
||
- [ ] **`workspace/didChangeWorkspaceFolders`** — roots are read once
|
||
at initialize; adding/removing a folder mid-session is ignored.
|
||
- [ ] **`workspace/configuration` (server-pull)** — we rely solely on
|
||
push `didChangeConfiguration`; clients are moving to the pull model.
|
||
- [ ] **3.18 additions:** `textDocument/rangesFormatting` (multi-range,
|
||
feeds format-modified-lines), snippet edits in `WorkspaceEdit`
|
||
(would improve `addPort` cursor placement), and
|
||
`workspace/textDocumentContent` (could serve a read-only "expanded
|
||
macro" document).
|
||
|
||
### 9d. Deliberately skipped (no Verilog use case)
|
||
|
||
Notebook sync, moniker (LSIF), inline value (debugger), document
|
||
color, goto implementation, goto declaration (Verilog has no
|
||
declaration/definition split lucisv models). Recorded here so the
|
||
audit doesn't repeat.
|