File watching M9: the index notices the world changing

workspace/didChangeWatchedFiles via dynamic registration (globs for the
four source extensions plus the configured filelist's own path), one
rebuild per notification with the same warning surfacing as save, and
re-registration when vfmt.filelist moves. Registration happens in
Server::new because lsp-server's initialize_finish consumes the
initialized notification - the protocol-suggested handler would be dead
code (verified against the vendored source). Open-buffer overlays
survive rebuilds; malformed and out-of-scope events rebuild nothing.
git pull, external editors and filelist edits now land without a save.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
lucioandClaude Fable 5 committed 2026-08-24 23:51:39 -07:00
1 parent fa38fd9dec
commit ab7beb1e54
9 files changed
+1395 -57

No files matched your search

+16 -1
View File
@@ -32,6 +32,7 @@ looks like language knowledge in here is a bug or a `Handshake` request.
| `textDocument/signatureHelp` | `vlog_refactor::instantiation_plan` | The instantiated module's ports (or, inside `#( ... )`, its parameters) with the active one highlighted — by name for a named list, by position for an ordered one. Triggers: `(` and `,`. Same feature README |
| `textDocument/inlayHint` | `vlog_refactor::instantiation_plan` | Ghost port names on an **ordered** connection list (`u1 (clk, rst_n)`) and parameter names on ordered `#( ... )` overrides, read from the instantiated module's declaration. Range-scoped; named lists, `.*`, omitted positions, connections past the last port, gate primitives and modules the index cannot resolve get nothing at all — a hint is decoration and never guesses. No `resolveProvider`. See `docs/features/inlay-hints/README.md` |
| `workspace/symbol` | `WorkspaceIndex::workspace_symbols` | Capped at 256 hits |
| `workspace/didChangeWatchedFiles` | `Workspace::rebuild_index` | Registered dynamically after the handshake, for a client that advertised it. One rebuild per *notification*, however many files it names. See `docs/features/file-watching/README.md` |
Deferred, deliberately, and named in Status/TODO below: ~~range formatting
(waits on TODO.md §2 `--lines`)~~ **delivered by range-formatting (round 18):
@@ -188,7 +189,7 @@ handler is milliseconds; the complexity of a worker pool buys nothing yet.
| layer | rebuilt when | cost |
|---|---|---|
| a document's `Semantics` + tokens + diagnostics | every `didOpen`/`didChange` | one file, full recompute |
| the `WorkspaceIndex` | `initialize`, and every `didSave` | full re-scan of the roots |
| the `WorkspaceIndex` | `initialize`, every `didSave`, every `workspace/didChangeWatchedFiles`, and a changed `vfmt.exclude`/`vfmt.filelist` | full re-scan of the roots |
**Per-file recompute on every keystroke** is the strategy TODO.md §6 states
("per-file recompute is fine at Verilog file sizes"); salsa is explicitly
@@ -209,6 +210,20 @@ point where the answer is expected to change anyway. Measured cost of a
rebuild: 0.68 s for the 860-file corpus (the workspace index's own baseline),
plus the file reads.
**Changes made outside the editor close on the next notification, not on the
next save** (M9, `docs/features/file-watching/README.md`). The server registers
`workspace/didChangeWatchedFiles` for `**/*.{v,vh,sv,svh}` and for the
configured filelist's own path, so a `git pull`, a checkout, a generated file
or an externally edited `.f` rebuilds the index straight away — one rebuild per
notification, however many files that notification names. **The window that
remains, honestly:** a client that did not advertise
`workspace.didChangeWatchedFiles.dynamicRegistration` cannot be registered
(the protocol has no static form of the capability) and keeps the save-only
model above; nested `-f` filelists are not watched, only the root one;
`vfmt.toml` is not watched either (it is re-read on every rebuild, so the next
rebuild from any cause picks it up); and there is no time-based debouncing, so
a burst arriving as several separate notifications costs one rebuild each.
**Definition targets in other files need that file's text** to turn a
`TextRange` into a `Range`, and the index deliberately keeps no file contents.
The server resolves a target by taking the **open buffer's text if that path