23 KiB
editor-settings
Goal
Expose the three keys lucisv.toml supports — line-length, indent,
exclude — as VS Code settings (lucisv.lineLength, lucisv.indent,
lucisv.exclude), for the users who asked for them: people with no config file
checked into the tree, who until now could set the indent only by accident
(VS Code's tabSize leaked in through FormattingOptions) and could not set
a line length at all, because LSP carries no line-length option. The
settings are transported by workspace/didChangeConfiguration, validated at
the server, and folded in one rung below a lucisv.toml — which stays
authoritative, so a project that checks one in keeps exactly one source of
truth and format-on-save cannot drift from CI's lucisv --check.
Assumptions
lucisv.tomlhas exactly three keys, and that is the whole surface.lucisv_core::config::parse_entryacceptsline-length,indentandexcludeand rejects everything else by name. Rule selection (--select/--ignore) has no config key yet, so there is nothing to expose for the linter; when it grows one, it grows a setting here in the same shape.- A repository outranks an editor. The precedence decision (below) is the
one thing in this feature that is a judgement call rather than mechanics. It
extends the reasoning
format::settings_foralready carried fortabSize: the further a setting is from the code it governs, the less it should win. - Nothing the client sends is trusted.
package.json's JSON schema bounds the settings UI, but the notification is JSON on a socket and other editors have no schema at all — the Neovim setup ineditors/nvim/README.mdwrites the same section by hand. Out-of-range, wrong-typed and missing values are all dropped, leaving that rung silent. Same philosophy as the existingtabSizeguard: honouring half of a nonsensical request is worse than ignoring it. - The accepted ranges must match
lucisv.toml's. A value has to be exactly as acceptable from the settings UI as it is in a config file, or the two front ends would disagree about what is valid.lucisv_coreexports no constant for its bounds, sosettings.rscopies them andthe_accepted_ranges_are_the_ones_lucisv_toml_acceptschecks the copy against the real parser (lucisv_core::config::parse) rather than against another hard-coded number. If a range ever widens inlucisv_core, that test fails. - Only
excludecan invalidate anything.lineLengthandindentare read afresh by every formatting request, so a change to them needs no cache work at all.excludechanges which files exist as far as the workspace index is concerned, so it — and only it — triggers a rescan. - A non-integral number cannot arrive from VS Code. JavaScript serializes
4.0as4, soserde_json'sas_u64rejecting fractions costs nothing real; there is no "close enough" case worth forgiving. - The
lucisv.excludepatterns are matched by the same engine as the config's. They are appended to the sameVec<String>that reacheslucisv_core::walk::collect_files, so the glob syntax, the trailing-component matching and the.gitignoreinteraction are whatever the CLI already does. An empty-string pattern is harmless (walk::matchesreturns false for one), so it is not filtered out.
Handshakes
The precedence ladder (the contract this feature is)
Highest first. Each rung applies only where every rung above it is silent, and
each key climbs independently — a lucisv.toml naming only indent leaves
lucisv.lineLength in charge of the width.
| # | Source | Why here |
|---|---|---|
| 1 | lucisv.toml |
The project speaking. Must stay authoritative or format-on-save disagrees with lucisv --check in CI — the divergence that lifting the config into lucisv_core exists to remove. |
| 2 | lucisv.lineLength / lucisv.indent |
Typed on purpose into a settings UI, so more deliberate than a tab size — but it is one user's editor, and the repository outranks it. |
| 3 | FormattingOptions::tab_size |
Sent on every request whether or not the user ever chose it (it is the editor's default, or its guess from the file). The weakest thing that is still a signal. |
| 4 | Built-in defaults | indent 2, width 100. |
Two paths use a shortened ladder, and both are unchanged in spirit:
format::indent_width(theno-tabsquick fix) has no rung 3 — atextDocument/codeActionrequest carries noFormattingOptions.- Rung 1 is absent for an
untitled:buffer, which has no directory to discover a config from. Such a buffer therefore honours rung 2 now, where before it had only the tab size.
A broken lucisv.toml contributes nothing at all (as before), so rung 2 is
what answers under it — the user still gets the warning, and still gets their
settings.
The wire shape
Consumed: workspace/didChangeConfiguration, whose settings field carries
{ "settings": { "lucisv": { "lineLength": 120, "indent": 4, "exclude": ["vendor"] } } }
settings.rs::from_payload reads settings.lucisv and nothing else. A payload
without that section — including the {"settings": null} form — means "no
opinion about anything" and resets every key. Keys may be absent, null, or
garbage; each is dropped independently.
Verified against the real client library, not assumed (the plan required
this): [email protected],
node_modules/vscode-languageclient/lib/common/configuration.js. Its
SyncConfigurationFeature.initialize() registers when
clientOptions.synchronize.configurationSection is set, and register() ends
with an unconditional this.onDidChangeConfiguration(section, undefined) —
with event === undefined the affectsConfiguration filter is skipped, so
the notification is sent immediately at startup as well as on every later
change. No initializationOptions fallback is needed, and none was added.
extractSettingsInformation(['lucisv']) calls
workspace.getConfiguration(undefined).get('lucisv'), which returns the whole
section with every key at its effective value — so the server sees
serverPath and rainbowBeginEnd in the payload too, and ignores them.
Other editors: anything that can send workspace/didChangeConfiguration with
that settings shape works. Neovim's vim.lsp.config sends its settings
table verbatim, so settings = { lucisv = { indent = 4 } } is the whole setup.
Within the server
- Consumed from
lucisv_core:config::parse(in a test, to pin the ranges),config::FileConfig,walk::collect_files'sexcludeparameter. - Promised to
state.rs:Workspace::client_settings()andset_client_settings(), the latter returningtrueexactly when the caller mustrebuild_index(). - Promised to
server.rs:settings::from_payload. TheDidChangeConfigurationarm is the only caller. - Changed signatures (all callers updated in the same change):
format::settings_for(doc, client, options),format::indent_width(path, client), and the privateformat::config_from(file, client, options).
Request to the lead (outside this feature's scope, unchanged from M2/M3):
docs/features/lucisv-server/README.md and TODO.md §6 still understate the
server (documentHighlight, the missing-closer diagnostics, lucisv/scopePairs,
and now these settings). Separately,
docs/features/editor-packaging/README.md's What was deliberately left out
table has a row reading "Settings beyond serverPath — formatter options
belong in lucisv.toml, one source of truth", which this feature supersedes: the
one-source-of-truth rule is now enforced by precedence rather than by absence.
editors/vscode/README.md said the same thing and was updated here, because
this feature owns that file's settings table.
Status / TODO
settings.rs:ClientSettings,from_payload, validation.Workspacestores them;set_client_settingsreports whether a rescan is needed.- Folded into
settings_for/config_from/indent_width. excludeappended to the workspace scan's excludes; a change rebuilds the index and republishes.extension.jssynchronize.configurationSection: 'lucisv'; initial-push behaviour verified against the library source.- Three settings in
package.jsonwith schema bounds. editors/vscode/README.mdsettings table and precedence ladder.- Tests: precedence per rung, invalid values, exclude append, mid-session
change (e2e), untitled buffers,
smoke.js. - Not done, deliberately: no per-language or per-folder override
(
[verilog]-scoped settings). VS Code resolves those per resource, and the server holds one workspace-wideClientSettings; alucisv.tomlis the per-directory mechanism and it already works. - Not done, deliberately: no
workspace/configurationpull. The push arrives at startup and on every change, which is all that is needed; pulling would add a request per document to answer the same question. - Not done, deliberately: no setting for lint rule selection — there is no
lucisv.tomlkey for it yet, and inventing one here would put the editor ahead of the CLI.
Work log
2026-08-24 — M4: lucisv.toml's three keys as VS Code settings
The thing that had to be checked first. The plan said to verify, not
assume, whether [email protected]'s synchronize emits an initial
push — because if it did not, the settings would only reach the server after
the user edited them, and the whole feature would look broken on a fresh
window. Read lib/common/configuration.js in node_modules: initialize()
registers the section, and register() unconditionally calls
onDidChangeConfiguration(section, undefined), whose undefined event skips
the affectsConfiguration filter and sends the notification straight away.
It does push at startup, so no initializationOptions fallback was added.
The finding, with file and function names, is in Handshakes so the next person
does not have to re-derive it.
Server. New settings.rs — ClientSettings plus from_payload, which is
all the validation. Workspace gained the field, a getter, and
set_client_settings returning "you must rescan", which is true only for
exclude. format.rs grew one rung in the ladder, written weakest-first so
the last writer wins and the code reads in the same order as the doc comment.
server.rs gained the DidChangeConfiguration arm and a small reindex()
helper, since rebuild-and-republish now has two callers (a save, and a new
exclude); the comment on the save path saying the index is rebuilt "on save
and nowhere else" was true before this change and is now corrected rather than
left to rot.
Two decisions worth recording.
- Settings sit below
lucisv.toml, not above. This is the opposite of the CLI's flag-beats-config order, and it is the same callsettings_foralready made fortabSize, for the same reason: a CLI flag is typed for one run, while an editor setting persists silently and belongs to one machine. If alucisv.lineLengthof 80 could override a project'sline-length = 120, every save would reflow files that CI then rejects. Pinned byrung_1_a_config_file_beats_a_pushed_setting. - Ranges are checked against the real config parser. Copying
40..=400and1..=8intosettings.rsis a duplication hazard —lucisv_coreexports no constant, and CLAUDE.md says not to reach into another module for this feature's convenience. Rather than leave the copy unguarded, the test askslucisv_core::config::parsewhether each edge is accepted. That is strictly better than a shared constant would have been: it tests the behaviour, not the number.
Tests. 190 unit (was 177) and 9 e2e (was 7) in this crate:
format.rs— one test per rung of the ladder, plus each-key-independence, a broken config falling through to rung 2, the untitled buffer, the quick-fix path's shortened ladder, and the capability that did not exist before:a_pushed_line_length_is_the_only_way_to_set_a_width_without_a_configasserts the text actually reflows, not just that a number was stored.settings.rs— the exact VS Code payload shape at its defaults (must be "no opinion"), out-of-range numbers, wrong types, a non-arrayexclude, a mixed array, a payload with nolucisvsection,settings: null, and the range cross-check above.state.rs— a pushedexcludehiding a file from the index; appended, not substituted, so a user's setting cannot put the project's vendored code back in the index for them alone; and that only anexcludechange asks for a rescan.tests/e2e.rs—pushed_settings_reach_the_formatter_and_can_change_mid_sessiondrives five formats over one session: tab size → pushed 4 → pushed 8 → back to null → a garbage payload, asserting the emitted text each time. This is the mid-session requirement and the ignore-invalid requirement in one place.a_pushed_exclude_rebuilds_the_index_mid_sessioncovers the one link no unit test can reach — that the notification handler re-scans — by watchingworkspace/symbolhits appear and disappear as the setting is pushed and cleared. It was written after a hand-driven session proved the path worked; the check is worth keeping, because aset_client_settingsthat returnedfalseforexcludewould break this silently and nothing else would notice.smoke.js— pushesindent: 4in the real payload shape while asking fortabSize: 2, and asserts the returned edit is 4-space indented. Mutation-checked: changing the pushed value tonullfails the assertion with the 2-space output, so it is live rather than vacuous.
Deviations from the plan. None on substance. Two notes: (a) the plan
allowed the mid-session test to be a unit test "if the harness does not support
notifications" — it does, so it is an e2e; (b) the plan's conditional
initializationOptions fallback was not implemented, because the verification
it was conditioned on came back negative-for-need (the library does push).
Verification. cargo fmt --all clean, cargo clippy --all-targets clean,
cargo test --workspace green, node smoke.js against a freshly built
target/debug/lucisv-server OK, npx @vscode/vsce ls still accepts the
manifest, node --check on both JS files.
QA log
2026-08-24 — round 3, Sonnet QA (M4)
Scope: the uncommitted working tree only (git diff/status vs HEAD;
everything through aa26e5e already QA'd). Verified settings.rs,
format.rs, state.rs, server.rs, main.rs, tests/e2e.rs, extension.js,
package.json, smoke.js, editors/vscode/README.md, and this README.
1. Precedence ladder. Read every rung's test in format.rs (rung_1..
rung_4, each_key_climbs_the_ladder_independently,
a_broken_config_leaves_the_pushed_settings_in_charge,
an_untitled_buffer_honours_pushed_settings). Every mixed case the charter
named is present and passes: toml-names-indent-only + settings-names-lineLength-
only (each_key_climbs_the_ladder_independently); settings-indent vs. differing
tabSize (rung_2_a_pushed_setting_beats_the_editors_tab_size); a broken
lucisv.toml falls through to the pushed settings (rung 2), not straight to
default — pinned by format.rs:499 and documented, not just tested: the
Handshakes section states it explicitly ("A broken lucisv.toml contributes
nothing at all... so rung 2 is what answers under it"). No undocumented hole
found.
2. Validation hostility. Every value the charter listed (indent 0, 9, -1,
400.5-equivalent via 4.5, "4" string; lineLength 39, 401, 39.9-equivalent;
exclude as a string, exclude with non-string entries; settings: null; missing
lucisv section; extra unknown keys) is covered in settings.rs's unit tests.
Went further and hand-drove the built binary (not just unit tests) with a
script sending all of the above plus indent: 400.5, lineLength: 39.9,
exclude: [1,2,3], a params with no settings key at all, and a payload
mixing valid siblings (indent: 4, lineLength: 120) with an unknown nested key
and a dirty exclude array — the server processed the whole session, kept the
valid siblings (final format came back 4-space indented, confirming
lineLength/indent both survived alongside the garbage), and answered
shutdown cleanly. No panics anywhere in the pipeline (deserialization included,
not just from_payload).
3. exclude append + re-index + republish. state.rs unit tests
(a_pushed_exclude_is_appended_to_the_configs_and_does_not_replace_it,
only_an_exclude_change_asks_for_a_rescan) correctly prove append-not-replace
and the "only exclude triggers rescan" contract.
Finding (non-blocking, test-coverage gap):
crates/lucisv_server/tests/e2e.rs:690-746
(a_pushed_exclude_rebuilds_the_index_mid_session) opens no document — it
only drives workspace/symbol queries before/after the exclude push. That
proves the scan half of reindex() (server.rs:319-324) ran, but nothing in
this test, or anywhere else in the diff, asserts the republish half: that
self.publish(&uri) actually fires a new textDocument/publishDiagnostics for
an open buffer when an exclude-triggered rebuild — as opposed to a
didSave-triggered one — happens. The dev's own work-log entry is honest about
this ("covers... that the notification handler re-scans"); it does not claim
the republish is covered, and it isn't.
Traced the actual runtime impact: diagnostics::all() (diagnostics.rs:26-31)
composes parse diagnostics, missing-end diagnostics and lint diagnostics — none
of which read doc.external or the workspace index. Only hover.rs:106 and
nav.rs:16 consume doc.external. So today a republish after an exclude
change is content-identical to the previous publish for any open buffer whose
own text didn't change; the only observable proof available to a test is that
a second publishDiagnostics notification for that uri was sent at all (or,
more usefully, that a goto-definition/hover result for an open buffer changes
after the exclude flips a file in or out of the index — that would exercise
doc.external and be a stronger test than diagnostics republish). This
reindex() helper and its two callers are not new logic invented for this
gap — the rebuild+republish loop already existed for didSave before this
diff and had (and still has) no e2e assertion of its own either, so this is not
a regression this feature introduced, just a required test from the plan
("exclude... change triggers re-index + republish... e2e") that is not
actually closed. Suggested fix for the dev: extend
a_pushed_exclude_rebuilds_the_index_mid_session (or add a sibling test) that
opens a buffer referencing a symbol in the file being excluded/un-excluded and
asserts a goto-definition (or a second publishDiagnostics) reflects the
change, so the republish half has a real assertion rather than an implicit one.
4. The real client library claim. Read
editors/vscode/node_modules/vscode-languageclient/lib/common/configuration.js
directly (installed version confirmed 9.0.1 via node_modules/vscode- languageclient/package.json). SyncConfigurationFeature.initialize() (line
109) registers when clientOptions.synchronize.configurationSection is set;
register() (line 121-128) ends with an unconditional
this.onDidChangeConfiguration(data.registerOptions.section, undefined) —
the event === undefined case skips the affectsConfiguration filter, so the
notification is sent immediately. Confirmed: the dev's claim is accurate, and
so is the wire shape claim — extractSettingsInformation(['lucisv'])
(line 174-207) calls workspace.getConfiguration(undefined).get('lucisv') and
wraps it under result.lucisv, i.e. exactly {settings: {lucisv: {...every declared key at its effective value...}}}, matching settings.rs's
vscode_payload() test helper and the README's documented shape.
extension.js's synchronize: { configurationSection: 'lucisv' } and
package.json's three new properties are all spelled lucisv.lineLength /
lucisv.indent / lucisv.exclude — the prefix matches. No mismatch found.
5. smoke.js. Built fresh with cargo build -p lucisv_server, ran
node smoke.js ../../target/debug/lucisv-server — OK. Mutation-checked the
pushed-indent assertion: changed indent: 4 to indent: 2 in the
didChangeConfiguration push, reran — got a clean FAIL reporting the
2-space (tabSize) output instead of 4-space, confirming the assertion is live;
restored the edit and reran — OK again, and md5sum before/after the
round-trip matched byte-for-byte (a33792c93538b89b8d64debe117f2ab1).
6. Untitled buffers. format.rs's
an_untitled_buffer_honours_pushed_settings pins both lucisv.indent and
lucisv.lineLength applying with no path and no toml. Confirmed.
7. Invariants.
cargo test --workspace: all green, includinglucisv_server's 190 unit + 9 e2e (matches the work log's claimed counts).cargo fmt --all -- --check: clean.cargo clippy --all-targets: clean (touchedsettings.rsto force a recheck rather than trust a stale cache; still clean).node --checkon bothextension.jsandsmoke.js: OK.package.jsonparses as JSON.git diff --stat HEAD -- crates/vlog_formatter crates/vlog_parser crates/verify: empty — nothing under those paths touched.- No
unwrap()/expect()/panic!in the non-test portions ofsettings.rs,format.rs,state.rs,server.rs(grepped each file up to its#[cfg(test)]marker). - package.json schema bounds (
minimum/maximum40/400 and 1/8) cross-checked againstsettings.rs'sLINE_LENGTH_RANGE/INDENT_RANGEand againstlucisv_core::config::parse_entry(crates/lucisv_core/src/config.rs:56-57, which is the real source of truth) — all three agree. - Cross-checked the "exclude append mirrors the CLI" claim in Assumptions
against
crates/lucisv/src/args.rs:103-107(exclude_with) — the CLI does extend its own--excludewith the config's, same append-not-replace pattern. Accurate.
Verdict: PASS. One finding, non-blocking (test-coverage gap in the
exclude-republish e2e path, item 3 above) — the underlying behavior was
independently verified by code reading to be correct and shares its
implementation with the already-shipped didSave path, so this is a request
to close a documented required test, not a functional defect.
Review
2026-08-24 — lead review of M4 (after QA round 3)
Read settings.rs in full plus the format.rs, server.rs, state.rs
and extension.js diffs. Approved and committed. Notes:
- Settings-below-
lucisv.tomlis the right call and the rewrittensettings_forladder doc states it well; thethe_accepted_ranges_are_the_ones_lucisv_toml_acceptstest (asking the real parser about the copied bounds) is a pattern worth reusing. - QA's non-blocking finding stands: the exclude e2e proves the rescan but
not the republish half of
reindex(). Functionally moot today (nothing indiagnostics::allreads the index), so accepted as-is; the next round touchinge2e.rsshould close it per QA's suggested fix. extractSettingsInformationsending the wholelucisvsection (so the server sees and ignoresserverPath/rainbowBeginEnd) is correctly mirrored in the tests' payload shape rather than an idealized one.