41 KiB
completion-templates
M6 of the refactoring plan (docs/features/refactor/README.md): statement
and item templates in the server's completion response, plus the 0.4.0
version bump.
Goal
Make the completion list finish the construct, not the word. Typing if
inside an always block should offer if begin/end and, on accept, write
if (cond) begin
end
at the line's own indentation, with cond selected and TAB moving into the
body — and the same for if/else, else if, case, the loops, the always
family, initial and the everyday declarations. This is M5's completion
machinery with one tier added: the templates are a sixth source of items,
ranked between what the code declares and the bare keywords, and gated by two
questions the server can already answer from the token stream — may a
statement be written here? and may a module item? Nothing is offered that
the buffer's own dialect would reject, and every template's untouched expansion
is fed to lucisv's own parser by the test suite, because a template that hands
the user a red squiggle from our own server is worse than no template.
Because this lives in the server, Vim gets it too — which is the reason it is
here rather than in editors/vscode/snippets/*.json, where nine of these
templates used to live. Those are gone; see Reconciliation below.
Assumptions
- A label that is not a keyword is a feature, not a workaround. Dedup in
Itemsis by label, so a template labelledifwould have swallowed the keywordif. Every label is prose (if begin/end,always_ff with reset,logic [N:0] name;) andfilterTextcarries the word the user actually types, so both items appear and the client still matches the template onif.no_label_is_a_bare_keyword_and_no_label_repeatspins it. - Position is judged over the token stream, not a parse. The statement gate
reuses M4's
pairs::analyzescope chain — the same heuristicat_module_itemhas always run on — so a half-typed buffer costs nothing extra and an unbalanced one still answers. Both gates are wrong in the same directions the M4 README already records; the failure mode is a template not offered, never a template offered inside a port list. - A template's defaults are chosen so the untouched expansion parses.
if (${1:cond}), notif ($1): a hole with no default expands to nothing, andif () beginis not Verilog. This is the editor-snippets assumption restated for generated text, and it is verified rather than assumed —every_untouched_expansion_parsesplants every template where its gate says it may be written and assertsparse_source_tolerantreports nothing. $in a body is snippet syntax, not Verilog. The other editor-snippets lesson: VS Code substitutes an unknown$NAMEwith the empty string and says nothing, so an unescaped$finishin a body would vanish invisibly. No system task appears in any body today, andevery_hole_is_a_tabstop_the_snippet_grammar_readsfails the build if one is added without an escape.lucisv.indent(default 2) is the indent step, and the line's own leading whitespace is the base — the sameLayoutM4's skeletons use, resolved the same way and with the same deviation fromlucisv.tomlrecorded there. Because the base is baked in, the item must tell the client not to indent it again: see The indentation contract below.- A template is offered on prefix, not on fuzzy match. The server filters
with
starts_with_ignore_caseon the template's prefix exactly as the other tiers filter on a name, soalwfinds everyalways*template andwhfindswhile. What the client does with the list on top of that is the client's business (M5's "sortTextis a nudge" assumption, unchanged).
Handshakes
- New module
crates/lucisv_server/src/templates.rs— the registry, the dialect rule and the renderer. It is data plus one function; nothing in it knows about LSP.completion.rsowns the tier, the gates and the items. - Consumes
vlog_refactor::Layout— M4's{ base, step }, reused rather than re-declared, so a skeleton and a template are indented by the same type. Nothing invlog_refactorwas touched. - Consumes
lucisv_server::pairsthroughcompletion::enclosing_scopes, exactly as M4 does. No change topairs.rs. - Changed inside
completion.rs, for other tiers to know about:- The tier digits moved. Templates are tier
3; keywords are now4and project words5. The only assertion outside this module that reads a digit ise2e.rs's word-tier check, updated with a comment saying why. at_module_itemnow takes the scope chain instead of computing it, so the two gates share onepairs::analyzecall; its logic is unchanged.Wordgrewstatement_head(see The gates).
- The tier digits moved. Templates are tier
editors/vscode: nine static snippets removed (below). No manifest change, noextension.jschange, no new setting, no new capability —snippetSupportis read exactly where M4 read it.- No new dependency.
The templates
label is what the list shows, prefix is what the user types, and the body
is written as indented lines that the renderer lays out at the site's own
indentation. $0 is where the cursor lands, which is the empty body line in
every block template.
Both dialects:
| Label | Prefix | Gate | Body |
|---|---|---|---|
if begin/end |
if |
statement | if (${1:cond}) begin / $0 / end |
if/else |
if |
statement | if (${1:cond}) begin / $2 / end else begin / $0 / end |
else if |
else |
statement (else-tail) | else if (${1:cond}) begin / $0 / end |
else begin/end |
else |
statement (else-tail) | else begin / $0 / end |
case/endcase |
case |
statement | case (${1:sel}) / ${2:value}: $0; / default: ; / endcase |
casez/endcase |
casez |
statement | as case, with casez |
while begin/end |
while |
statement | while (${1:cond}) begin / $0 / end |
initial begin/end |
initial |
item | initial begin / $0 / end |
SystemVerilog only (.sv, .svh):
| Label | Prefix | Gate | Body |
|---|---|---|---|
for loop |
for |
statement | for (int ${1:i} = 0; $1 < ${2:N}; $1++) begin / $0 / end |
always_ff @(posedge clk) |
always_ff |
item | always_ff @(posedge ${1:clk}) begin / $0 / end |
always_ff with reset |
always_ff |
item | always_ff @(posedge ${1:clk} or negedge ${2:rst_n}) begin / if (!$2) begin / ${3:q} <= '0; / end else begin / $0 / end / end |
always_comb begin/end |
always_comb |
item | always_comb begin / $0 / end |
logic name; |
logic |
declaration | logic ${1:name}; |
logic [N:0] name; |
logic |
declaration | logic [${1:7}:0] ${2:name}; |
localparam int NAME = 0; |
localparam |
declaration | localparam int ${1:NAME} = ${2:0}; |
parameter int NAME = 0; |
parameter |
declaration | parameter int ${1:NAME} = ${2:0}; |
Verilog only (.v, .vh, and any buffer with no file name):
| Label | Prefix | Gate | Body |
|---|---|---|---|
for loop |
for |
statement | for (${1:i} = 0; $1 < ${2:N}; $1 = $1 + 1) begin / $0 / end |
always @(posedge clk) |
always |
item | always @(posedge ${1:clk}) begin / $0 / end |
always @(posedge clk or negedge rst_n) |
always |
item | the reset flavour, ${4:1'b0} instead of '0 |
always @(*) |
always |
item | always @(*) begin / $0 / end |
reg name; |
reg |
declaration | reg ${1:name}; |
reg [N:0] name; |
reg |
declaration | reg [${1:7}:0] ${2:name}; |
wire name; |
wire |
declaration | wire ${1:name}; |
wire [N:0] name; |
wire |
declaration | wire [${1:7}:0] ${2:name}; |
localparam integer NAME = 0; |
localparam |
declaration | localparam integer ${1:NAME} = ${2:0}; |
parameter integer NAME = 0; |
parameter |
declaration | parameter integer ${1:NAME} = ${2:0}; |
Sixteen templates in a .sv file, eighteen in a .v one.
Two deliberate details in that table. The parameter templates name a type
(int / integer) because lucisv's own explicit-parameter-storage-type rule
flags localparam NAME = 0; — a template that trips our own linter on insert
is not a template worth shipping, and it was the untouched-expansion check that
surfaced it. casez but not casex: casez costs one registry entry and
is what a decoder is actually written with, while casex is the one most style
guides tell you not to use, and an unused item is noise in the list.
The gates
Three gates, all decided before any item is built, so a request at a position
where no template belongs costs one pairs::analyze and nothing else — and a
request in the middle of an expression does not even cost that, because neither
gate can be true unless the word starts a statement.
Item position is M4's at_module_item, unchanged: the innermost open scope
is a module/interface/program/generate/begin, no function/class/
case/fork is in the chain, the outermost begin is not procedural, and the
parentheses are balanced. An always_ff inside an always_comb is exactly what
that gate already refuses.
Statement position is its mirror image, new in at_statement: the innermost
open scope is a function/task — whose body is statements all the way down —
or a begin/fork whose outermost begin is procedural. Everything else is
refused, case arms included: a bare if is not a legal case item, and a gate
that guessed at one would offer a template that does not compile.
Declaration position is either of the two: a logic/reg/wire/
localparam declaration is a module item and a block item both, and
IEEE 1800's block_item_declaration includes the parameter forms as well.
On top of the scope chain, a template is only offered where a statement can
start on the line: nothing but whitespace before the typed word, or nothing
but end, else or end else — the two words a statement legitimately
follows on one line. That is what makes end else if complete, and what keeps
a template out of x = if. It is Word::statement_head, a list of three
strings, and it is deliberately the whole of the rule: anything else on the
line means the word is part of an expression.
One honesty note about the owner's phrasing ("typing if( then accepting a
suggestion"): the list appears while the word if is being typed, and the
template is accepted from there. Once the ( is typed, the word being
completed is empty and no longer starts a line, so the templates are gone — the
user is inside an expression by then, and the item they wanted was on screen
one keystroke earlier. Offering if (…) begin as a replacement for text that
already contains if( would mean editing backwards over punctuation the user
typed, which is the same line M5's backtick ruling drew.
Comments and strings need no new gate at all. M5's in_comment_or_string
returns None for the whole request before any tier runs, so a // if offers
nothing, and the same is true of a buffer that does not lex.
Ranking
sortText is <tier digit><label>, so the six tiers are:
| Tier | What |
|---|---|
0 |
module instantiation skeletons (M4) |
1 |
declarations the scope chain binds |
2 |
what the project declares |
3 |
templates |
4 |
keywords |
5 |
project words |
Above the keywords because a user who typed if almost always wants
if (…) begin … end rather than the two letters they already have; the bare
keyword is one arrow-key away and is still there. Below both semantic tiers
because a name the code actually declares — a signal called if_enable, a
package called case_pkg — is a fact about this project, and a template is a
guess about intent; facts win. That the templates sit below tier 2 rather
than between 1 and 2 is the one judgment call: tier 2 is names the workspace
index resolved, which is the same kind of evidence as tier 1, so the two stay
adjacent.
Both orderings are asserted (a_template_never_swallows_the_keyword_it_is_ reached_by, a_template_ranks_below_a_name_the_code_declares), and — as M5
recorded — the tests assert what the server sends, not what a client draws.
Dialect
templates::dialect reads the buffer's file extension, the same question
wire-reg-mixup asks: .sv/.svh (case-insensitively) is SystemVerilog,
everything else is Verilog — a .v, a .vh, an unknown extension, and a
buffer with no path at all (untitled:, stdin).
The default is Verilog rather than SystemVerilog on purpose, and it is the
opposite of what "newer is better" would suggest. Every Verilog template is
also legal SystemVerilog: guessing Verilog for an SV buffer costs the user
reg where they wanted logic, one keystroke to fix. Guessing SystemVerilog
for a Verilog buffer hands them always_ff and logic, which their compiler
rejects. The asymmetric cost decides it. Consequence worth naming: an untitled
buffer in VS Code gets the Verilog set even when the user picked the
SystemVerilog language mode, because the server is told a URI, not a language
id, and inventing a second source of truth for one rare case is not worth it.
The moment the buffer is saved as .sv it gets the SystemVerilog set.
Plain-text clients
A client that never advertised completionItem.snippetSupport gets the same
template with every hole filled in, as InsertTextFormat::PLAIN_TEXT — the
M4 ruling for skeletons, applied here. if inserts
if (cond) begin
end
and the cursor lands wherever the client puts it, which is the end of the
insertion. Skipping the tier entirely was the alternative and is worse: the
text is useful, it parses (it is the exact string the expansion test feeds the
parser), and the defaults were chosen for this case as much as for the
preselection. A line that held nothing but $0 loses its indentation in this
spelling, since there is no cursor to park on it.
The two spellings go through one renderer — Template::render(layout, snippets) — so they cannot drift, and
the_two_spellings_of_a_body_are_the_same_text asserts that stripping the
tabstops out of the snippet gives the plain text back.
The indentation contract
Added 2026-08-25, fixing a bug that had been in the popup since 0.4.0 and
was found while fixing its twin in inline-templates.
Every multi-line body here already carries the site's indentation: Layout's
base is the trigger line's leading whitespace and every line after the first
starts with it. VS Code then indents it again. suggestController.ts's
_insertSuggestion calls
snippetController.insert(insertText, {
…,
adjustWhitespace: !(item.completion.insertTextRules! & CompletionItemInsertTextRule.KeepWhitespace),
…
});
and SnippetSession.adjustWhitespace prepends the insertion line's own
leading whitespace to every line after the first, then re-spells the run with
TextModel.normalizeIndentation. So if accepted four spaces in wrote its
body at twelve and its end at eight — one level right of the if.
The escape hatch is LSP's insertTextMode. asIs says "the string is taken
as it is… the client will not apply any kind of adjustments". The vendored
vscode-languageclient 9.0.1 advertises support for it
(completion.js:59), turns it into keepWhitespace: true
(protocolConverter.js:342-346), and extHostLanguageFeatures.ts turns
that into the KeepWhitespace rule that clears adjustWhitespace.
So completion.rs sends insertTextMode: asIs (the KEEP_MY_INDENTATION
constant) on the two item builders that write more than one line: the template
tier and the module-instantiation skeleton. Single-line items neither need it
nor are harmed by it, so they do not send it. It is the right answer for the
plain-text spelling as well — that text is absolutely positioned too — which
is why this path did not switch to relative indentation the way ghost text
had to. An inline completion has no insertTextMode field at all; see
docs/features/inline-templates/README.md's The indentation contract.
Pinned by tests/e2e.rs (insertTextMode == 1 on both the template item and
the module skeleton), over the wire, beside the newText each already
asserted.
Reconciliation with the static VS Code snippets
Nine snippets were deleted from editors/vscode/snippets/*.json because the
server now offers the same construct under the same typing. The list, the
reasoning and the verification are in
docs/features/editor-snippets/README.md's work log (2026-08-24, M2); in
brief: always_ff, always_comb, case, initial from
systemverilog.json, and always, alwayscomb, case, for, initial
from verilog.json. alwayscomb is the only one whose prefix does not collide
outright — VS Code matches a typed always against it as a subsequence and it
had a byte-identical body to the server's always @(*).
Everything file-level stays static, because a file template is worth having
before the server has started and is not position-dependent: module,
modulep, fsm, enum, struct, function, task, interface, package,
class, assertp, genfor, uniquecase, tb, guard. uniquecase and
genfor are kept deliberately — unique case is a different construct from
case, and a generate loop is a module item, not the procedural for the
server offers.
Version 0.4.0
Every place tools/RELEASING.md names, plus the install examples it does not:
Cargo.toml[workspace.package] version→0.4.0(all eight crates inherit it)Cargo.lockregenerated bycargo check --workspace— eight entrieseditors/vscode/package.json"version"editors/vscode/package-lock.json"version"in both placesREADME.md— thedist/lucisv-0.4.0.vsixinstall exampleeditors/vscode/README.md— both install examplestools/RELEASING.md— thedist/listing, the install commands, thegit tag v0.4.0example and the appendix's publish commandsCHANGELOG.md— a0.4.0 — 2026-08-24section in the existing voice- Verified:
target/debug/lucisv --version→lucisv 0.4.0 - Verified:
node editors/vscode/smoke.js target/debug/lucisv-server→smoke: OK
Deliberately not touched: the historical 0.3.x mentions in CHANGELOG.md and
in the feature READMEs that record what happened at those versions.
Status / TODO
templates.rs: registry, dialect rule, one renderer for both spellings- Tier 3 in
completion.rs, above keywords and below the semantic tiers - Statement gate (
at_statement), reusing M4's scope chain - Item and declaration gates
Word::statement_head, soend else ifcompletes- Dialect selection by extension, documented for the pathless buffer
- Plain-text fallback with the defaults filled in
- Registry-wide "every untouched expansion parses" test, both harnesses
- Registry-wide
$-escaping and flat-default tests - Gate tests: statement vs item vs declaration, subprogram bodies, case arms, generate blocks, port lists, mid-line words, comments
- Dialect tests over
.svand.vbuffers - Ranking and dedup tests against the keyword and scope tiers
- e2e stdio round trip: the
iftemplate's exact snippet text, its replaced range, the keyword beside it, and a.vbuffer'salways - Nine static snippets removed, both READMEs' prefix tables updated
- Version 0.4.0 across the workspace, the extension and the docs
cargo fmt --all -- --check,cargo clippy --all-targets,cargo test --workspaceclean;node --checkon both JS files;smoke.jsOK;vsce lsstill accepts the manifest- Not done, deliberately: no
casex, noforever/repeat, nofork/jointemplate, no UVM anything. Each is a template somebody wants and nobody agrees on the shape of, and an unused item is noise in the list — the same ruling editor-snippets made forcovergroupandsequence. - Not done: no template for
generate/endgenerateorgenvarloops. The staticgenforsnippet covers it and is not position-dependent.
Work log
-
2026-08-24 (dev) — implemented.
Registry (
crates/lucisv_server/src/templates.rs, new). ATemplateis five fields: label, prefix, gate, detail, and a body written as(indent level, text)lines.for_dialectchains the eight shared templates onto the dialect's own, so the statement set cannot drift between.svand.v.renderis the only code: it lays the lines out at avlog_refactor::Layoutand either leaves the tabstops alone or replaces each one with the text the editor would have preselected — mirrors included, so$1after${1:i}isi, which is what makes theforloop's expansion parse.Tier (
completion.rs).template_tierbetweenindex_tierandkeyword_tier,TIER_TEMPLATE = '3'; the keyword and word tiers moved to'4'and'5'.Items::templatebuilds the item —CompletionItemKind:: SNIPPET,filterText= the prefix,documentation= the expansion in a fenced block — and goes through the samepushas everything else, so the cap and the dedup are unchanged.Gates.
completionsnow computes the scope chain once, guarded by "does this word start a statement at all", and passes it to bothat_module_item(whose body is otherwise untouched) and the newat_statement. The guard matters: before M6 a mid-expression keystroke never ranpairs::analyze, and it still does not.Decisions worth flagging to the lead:
- The tier digits shifted. Templates had to rank above keywords, and
there is no character between
'2'and'3', so keywords became'4'and project words'5'. One assertion outsidecompletion.rsreads a digit —e2e.rs's word-tier check — and it is updated with a comment. Every in-module test reads theTIER_*constants and needed no change. - A pathless buffer gets the Verilog set, not the SystemVerilog one.
Reasoning under Dialect; it is the conservative direction, and it is
also the one
wire-reg-mixupalready takes. end,elseandend elseare statement starts, soend else ifcompletes. Three strings, an explicit list, and the test that pins it also pins thatx = ifis not one.- The parameter templates name a type (
int/integer) so that the untouched expansion does not trip lucisv's ownexplicit-parameter-storage-typerule. Found by running the expansions throughlucisv checkwhile choosing the bodies. alwayscombwas removed fromverilog.jsonalthough its prefix does not collide with anything the server offers. It is a subsequence match onalwayswith a body identical to the server'salways @(*), so it would have shown as a duplicate — but it is the one reconciliation entry that is a judgment call rather than a prefix collision.
Performance. M5's corpus guard, re-run in release against the 860-file corpus:
worst request 284 µs typed / 242 µs empty, against M5's measured 297 µs / 223 µs — unchanged inside the run-to-run noise, which is what the single sharedpairs::analyzeand the "no gate unless the word starts a statement" guard were for. The template path itself formats at most eighteen short strings and touches no table.Suite: 1 268 → 1 292 workspace tests (24 new: 9 in
templates.rs, 14 incompletion.rs, 1 e2e), all green.cargo fmt --all -- --checkandcargo clippy --all-targetsclean;node --checkonextension.jsandsmoke.js;node editors/vscode/smoke.js target/debug/lucisv-server→smoke: OK;npx --no-install @vscode/vsce lsstill lists both snippet files. No new dependency. - The tier digits shifted. Templates had to rank above keywords, and
there is no character between
-
2026-08-25 (dev, inline-templates round 2) — one field, one latent bug.
While fixing the same double-indentation bug in ghost text I read
suggestController.tsand found the popup had it too: every multi-line item this tier sends was being re-indented by the editor on accept, since 0.4.0. Fixed withinsertTextMode: asIsonItems::templateand onitem(the module-instantiation skeleton), behind theKEEP_MY_INDENTATIONconstant so the reasoning sits with the value. Full derivation and sources in The indentation contract above; the inline half is indocs/features/inline-templates/README.md.Flagged for the lead: the module-skeleton item belongs to
refactor-instantiate, not to this feature — the code is incompletion.rs, it is the identical bug, and leaving it broken beside the fixed template item would have been the odd choice.templates.rsitself is untouched: no body, no label, no gate, no renderer changed. Twoe2e.rsassertions added; nothing else.
QA log
2026-08-24 — QA agent.
Gates
cargo fmt --all -- --check— clean.cargo clippy --all-targets --workspace— clean, zero warnings (re-ran aftertouchingcompletion.rsto defeat the cache; still clean).cargo test --workspace— green. Summed everytest result:line myself rather than trusting the total: 1292, matching the Work log's1268 → 1292claim exactly.node --checkonextension.jsandsmoke.js— clean.node editors/vscode/smoke.js target/debug/lucisv-server—smoke: OK.cd editors/vscode && npx --no-install @vscode/vsce ls— accepts the manifest; filtering thenode_modules/**noise out of the listing (as the M1 QA pass for editor-snippets also did —.vscodeignoredoes not touchnode_modules, sovsce lsprints it regardless) leaves exactlypackage.json,extension.js,README.md,LICENSE,snippets/verilog.json,snippets/systemverilog.json.cargo build -p lucisv→target/debug/lucisv --version→lucisv 0.4.0.cargo test --release -p lucisv_server a_keystroke_over_the_whole_corpus_stays_in_budget -- --nocapture—worst request 225.875µs typed / 182.792µs emptyagainst the claimed 284µs/242µs; faster, inside run-to-run noise. Budget test passes.
All gates: pass, claims confirmed.
Priority — the real UX, driven live over stdio
Not trusting the e2e test alone: wrote a standalone Python LSP-stdio client
(/tmp/lucisv_qa/driver.py, ux_check.py, edge_check.py, untitled_check.py
— scratch, not committed) and drove target/debug/lucisv-server directly,
independent of the test suite.
.svbuffer,iftyped inside analways_combbody:if begin/end(kind Snippet=15) andif/elseboth offered,filterText: "if",textEdit.newText="if (${1:cond}) begin\n $0\n end"(tabstops, correct indentation at the site). The bare keywordif(kind Keyword=14) is present at one tier below (sortText3…vs4if). Confirmed exactly as claimed.case/casezinside a begin block: both offered, correct bodies.always_ff/always_combat SV item position: all three always_ff/comb templates offered.logic name;/logic [N:0] name;at SV declaration position: both offered..vbuffer,alwaysat item position:always @(posedge clk),always @(posedge clk or negedge rst_n),always @(*)offered;always_ff/always_combtemplates not offered (the bare keywordsalways_ff/always_combstill show, correctly, at the keyword tier — templates are dialect-gated, keywords are not)..vbuffer:wire/regdeclaration templates offered;logictemplate not offered anywhere in a.vbuffer (checked at declaration position with prefixlo: onlylocalparam integer NAME = 0;came back).- Untitled buffer (
untitled:Untitled-1,languageId: "systemverilog", no path) with prefixl: onlylocalparam integer NAME = 0;— the Verilog set, confirmed live, exactly as Dialect documents (and despite the client-declared language id, which the server correctly never consults for this).
Confirmed exactly as claimed — the plan's exact UX ("type if inside a
module + inside an always/initial body", "the bare keyword if ALSO present
at a lower tier", ".v buffer: always_ff NOT, logic NOT") all hold live,
not just in the unit/e2e suite.
Attacks — gates
All driven live over stdio, independent scripts, not just re-running the existing tests:
| Attack | Result |
|---|---|
if at module-item position (not inside a block) |
not offered |
always_ff inside a begin block (always_comb) |
not offered |
statement template inside fork/join |
offered (fork is a statement scope, correctly) |
statement template inside a function body |
offered |
statement template inside a generate/endgenerate block |
not offered (item position, not statement) |
case arm (case (s) if) |
not offered |
template inside a port list (module top (\n if\n)) |
not offered |
template inside a parameter list (module top #(\n if\n)) |
not offered |
template inside a connection list (.a(if) |
not offered |
cursor in a // if comment |
no completions at all (whole response declines) |
cursor inside an open string ($display("if) |
no completions at all |
end el (else-tail after end on the same line) |
offered (else if, else begin/end) |
x = if (bare identifier before if, mid-expression) |
not offered; keyword tier still answers |
end el (double space between end and else) |
offered — Word::statement_head's split_whitespace().join(" ") normalizes it |
end foo el (garbage between end and else) |
not offered — correctly refused |
Every one of the plan's specific break attempts held. No corruption risk:
verify.rs is untouched by this feature (confirmed by git diff — no
changes outside the stated scope), so hard invariant 4 does not apply here;
the "attack" surface for this milestone is wrong completions, not corrupted
formatter output, and none were found.
Expansion validity — re-derived independently, not trusted from the test
Extracted all 26 Template entries straight out of templates.rs's source
text with a standalone regex parser (not importing or calling
Defaults::substitute), wrote a second, independent tabstop-stripping
implementation in Python, planted each stripped body in the same probe shapes
the registry's own test uses, and fed every probe to a throwaway Rust binary
(/tmp/lucisv_qa/probe_checker, a 10-line main.rs depending on vlog_parser
by path) that calls vlog_parser::parse_source_tolerant directly — no lucisv
code from this feature involved in the check at all.
Result: 26/26 parse clean, independently. Count matches the claim (8 shared + 8 SV-only = 16 SV templates; 8 shared + 10 V-only = 18 V templates).
On "does it test .v templates against Verilog parsing settings?" — no,
and it can't: vlog_parser has no dialect concept anywhere
(grep -rn "Dialect\|dialect" crates/vlog_parser/src/*.rs — zero hits).
parse_source_tolerant is one grammar, a syntactic superset of both
dialects; dialect-specific rejection (e.g. always_ff being illegal in a
.v file) is enforced only by this feature's own gate (templates:: dialect), never by the parser. So the registry test is exactly as strong as
it can be — there is no stricter parsing mode to test .v templates against
anywhere in lucisv today. Worth recording, not a finding: a reader could
otherwise assume "parses" implies "parses under Verilog-2001 rules
specifically", which nothing in lucisv currently checks for any file.
$-escaping: grepped the body text for $ followed by a letter
(grep -oE '"\$[a-zA-Z_]+' templates.rs) — zero hits; every $NAME/$n in
the file is inside a doc comment, not a body. No system task in any template
body today, consistent with the claim.
Mirrors: the independent stripper resolves $1 after ${1:i} to i the
same way Defaults::substitute does (verified by the same 26/26 pass,
including both for loop templates, whose bodies are the only ones with
three mirrored tabstops).
Dialect
.svh/.vh — covered by the registry's own
the_dialect_comes_from_the_extension_and_defaults_to_verilog test
(.SVH case-insensitive → SystemVerilog, .vh → Verilog); re-read the
assertions, they match the README's claim. Documented in Dialect and (see
above) reconfirmed live for the untitled-buffer case, including the
languageId red herring the README calls out by name.
Reconciliation
Parsed both snippet JSONs directly (python3 -c 'json.load(...)') rather
than trusting the diff: systemverilog.json 19 → 15 entries, verilog.json
11 → 6, matching the claim. git diff on the two files' removed
"prefix" lines gives exactly the 9 named in the feature README's
Reconciliation section (4 SV: always_ff, always_comb, case,
initial; 5 V: always, alwayscomb, case, for, initial) — none
missing, none extra.
Keeper prefixes: SV = module, modulep, uniquecase, fsm, enum,
struct, function, task, interface, package, class, assertp,
genfor, tb, guard; V = module, function, task, genfor, tb,
guard. Cross-checked against every server template prefix in the matching
dialect (if, else, case, casez, while, initial/for,
always_ff/always_comb or always, logic/reg/wire, localparam,
parameter) — no exact string collision in either dialect.
Near-misses, as the plan asked to check by name: genfor vs for and
uniquecase vs case both contain the server's word as a literal
substring, so a client that fuzzy-matches by subsequence (VS Code's
completion filter does) can surface both for the same keystrokes — exactly
what the feature README's own Reconciliation section already discloses for
alwayscomb vs always. Not a new finding: the labels (Generate for /
for loop, Unique case / case/endcase) are distinct in the list, so a
user reading labels — which is the whole reason every template label is
prose, not a keyword, per this feature's own first Assumption — can always
tell them apart. No undisclosed near-miss found beyond what the README
already names.
Tier digits
grep -rln "sortText\|sort_text\|TIER_" crates editors — exactly two hits,
completion.rs and e2e.rs, both already inspected in the diff above and
both consistent with the new scheme (0=module, 1=scope, 2=index,
3=template, 4=keyword, 5=word). candidates.rs has no tier-digit
literals at all. No straggler found.
Version
Cargo.toml, all 8Cargo.lockpackage entries,package.json,package-lock.json(both places),README.md,editors/vscode/README.md,tools/RELEASING.md— all0.4.0, checked directly (not by grep-and-eyeball alone; the 8Cargo.lockentries were extracted programmatically withawk).grep -rn "0\.3\.1"outsideCHANGELOG.md— zero hits. The0.3.1section ofCHANGELOG.mditself is correctly left as history.- Finding, fixed directly (small, unambiguous):
CHANGELOG.md's 0.4.0 entry said the static snippets "shed the eight that would otherwise have been offered twice (always,always_ff,always_comb,case,for,initialand their Verilog twins)". The actual count, verified againstgit diffon both snippet JSONs and against this feature's own Reconciliation section and Work log ("Nine static snippets removed" / "9 static snippets removed"), is nine: 4 fromsystemverilog.json(always_ff,always_comb,case,initial) + 5 fromverilog.json(always,alwayscomb,case,for,initial). The old wording also never namedalwayscomband left its count ambiguous under "and their Verilog twins". Reworded to name all nine explicitly and state the correct count — seeCHANGELOG.md's 0.4.0 section. This is a release-note accuracy issue only; nothing in code or tests was affected.
Verdict
Ship. Every dev claim checked out exactly as stated, including the ones phrased as UX promises rather than test assertions — verified live over stdio with independent scripts, not just by re-running the shipped suite. The one finding (CHANGELOG miscount) was cosmetic, unambiguous, and fixed in place. No gate, attack, or reconciliation check turned up anything that needs dev rework.
2026-08-25 — QA agent, round 2 (the insertTextMode popup fix).
This feature's only change in round 2 is the four-line diff in
The indentation contract above (completion.rs): insert_text_mode: Some(KEEP_MY_INDENTATION) on Items::template
(crates/lucisv_server/src/completion.rs:459) and on item, the
module-instantiation skeleton (:612); layout_at
(crates/lucisv_server/src/completion.rs:326-329) re-privatized because
inline.rs no longer names it. templates.rs is untouched, confirmed by
git diff --stat (absent from the diff entirely). Full attack and gate
detail — the trigger-table work is this round's real surface — is in
docs/features/inline-templates/README.md's 2026-08-25 round-2 QA entry;
this entry covers only what round 2 touched here.
- The wire value.
crates/lucisv_server/src/completion.rs:156inlsp-types0.97.0 (registry source, read directly):pub const AS_IS: InsertTextMode = InsertTextMode(1);ADJUST_INDENTATION = InsertTextMode(2). SoKEEP_MY_INDENTATIONis1, matching LSP 3.17'sInsertTextModeenum (asIs = 1). Both pins intests/e2e.rsassertinsertTextMode == 1— the template item atcrates/lucisv_server/tests/e2e.rs:1258and the module skeleton at:1625— and both are correct. (The QA brief itself floated "asIs(2)" as a parenthetical; that would have beenAdjustIndentation, notAsIs— checked against the source rather than trusted, and the shipped code is right.) - No leak onto single-line items.
grep -n "insert_text_mode" crates/lucisv_server/src/completion.rsreturns exactly the two call sites above.Items::simple(completion.rs:412-430, the keyword/word/index tiers' single-line items) builds itsCompletionItemwith..Default::default(), which leavesinsert_text_mode: None— confirmed by reading the struct literal, not inferred. So plain keyword and word items are unaffected, as required. - Client capability path.
editors/vscode/node_modules/ vscode-languageclient/lib/common/completion.js:59advertisesinsertTextModeSupport.valueSet: [asIs, adjustIndentation]as part of the standard completion capabilities — no code in this repo has to opt into it, unlikeinlineCompletion's proposed-feature registration.protocolConverter.js:342-346turnsinsertTextMode === asIsintoresult.keepWhitespace = true, whichextHostLanguageFeatures.tsturns into theKeepWhitespaceinsert-text rulesuggestController.tschecks before callingadjustWhitespace. Traced end to end; matches the Work log's claim. - Gates, re-run independently:
cargo fmt --all -- --checkclean;cargo clippy --all-targets --workspacezero warnings;cargo test --workspace1644 passed / 0 failed / 4 ignored (up from the round-2 dev's 1633 — 11 new tests, all ininline.rs, none in this feature's own files);node editors/vscode/smoke.js target/debug/lucisv-server→smoke: OK;node --checkonsmoke.jsand aJSON.parseofpackage.jsonboth clean.
No findings against this feature's own round-2 diff. No commit, no push.
Review
2026-08-24 — lead. Reviewed after QA's ship verdict — second clean
first-pass in a row; gates run independently (1292 tests, 0 failures,
clippy silent). The registry-as-data with one renderer for both spellings
is the right shape, and Word::statement_head is a neat, honest gate for
else if (offered after end, refused after an identifier). QA
independently re-derived and re-parsed all 26 template expansions with its
own stripper — exactly the level of distrust the expansion-parses promise
deserves. Dev's three judgment calls approved: the tier-digit shift (all
call sites audited), the conservative Verilog set for pathless buffers
(every Verilog template is legal SV), and removing alwayscomb from the
static set. QA's CHANGELOG miscount fix (eight → nine, alwayscomb named)
accepted. Lead post-review fix: the extension README's relative link to
this doc broke vsce package (no repository URL to resolve it against) —
demoted to plain-text path. M6 checked off in the umbrella plan and
TODO.md §8; ships as 0.4.0.
2026-08-25 — lead review of the insertTextMode fix. The popup's
skeletons were latently double-indented in VS Code since 0.4.0 — same
root cause as inline-templates round 2, different fix because the
completion protocol has the opt-out the inline one lacks:
insertTextMode: asIs (verified = 1 on the wire against lsp-types
source, by QA) on the two multi-line tiers only. templates.rs and the
plain-text fallback untouched, lucisv.indent still meaningful here.
Approved; ships as 0.7.0.