Expand description
File-watcher subscription compilation + matching (4.4.l).
Servers dynamically register workspace/didChangeWatchedFiles
via client/registerCapability (the matrix entry for that
method in docs/dev/notes/lsp-features.md). Each registration
carries a DidChangeWatchedFilesRegistrationOptions containing
a list of FileSystemWatcher { glob_pattern, kind }.
This module is the pure piece of the file-watcher pipeline:
it walks the dynamic registry, compiles each registration’s
patterns into a globset::GlobSet, and produces a per-server
WatcherSubscriptions snapshot. The fs-event source itself
(the notify crate driver, debounce timer, fan-out) lives in
lattice-ui-tui::app::lsp_watcher; that module imports
WatcherSubscriptions and asks “does this absolute path
match any registered glob, and if so what FileChangeType do
we synthesise?”.
Keeping the pure parts here means:
- The matching logic is testable in isolation (no fs
integration in unit tests; no
notifyruntime). - Future renderers (GPU, web) reuse the same compilation path – only the event source changes.
- Plugins that want to participate in watched-file dispatch (post-1.0 WIT bridge) see one shape, not a tui-only one.
§Glob semantics
LSP 3.17 GlobPattern is either:
- a plain string (workspace-relative globs like
**/*.rs), or - a
RelativePattern { base_uri, pattern }wherebase_urianchors the pattern to a specific workspace folder or URI.
We normalise both shapes to (base, pattern) – the pure
string case anchors to the server’s workspace root supplied
at compile time; relative patterns honour their declared
base. WatchKind defaults to Create|Change|Delete (= 7)
when omitted, per spec.
§Path conventions
Glob matching runs against the path relative to the subscription’s base. Absolute paths are normalised by stripping the base prefix before matching; paths outside the base never match a relative-anchored pattern. This matches VSCode’s behaviour, which is what most servers exercise their globs against.
Structs§
- Watcher
Subscriptions - Snapshot of every active file-watcher registration for one
server. Built by
compile_for_serverfrom the dynamic registry; consumed by the host’s notify-driven dispatcher.
Functions§
- compile_
for_ server - Compile the dynamic-registration entries on
capsfor the givenserver_idinto aWatcherSubscriptionssnapshot.workspace_rootis the absolute path the server was attached to; plain-string globs (noRelativePatternbase) anchor here. - compile_
with_ workspace_ root - Build a
WatcherSubscriptionswhose plain-string globs all anchor toworkspace_root. The barecompile_for_servercaptures the path verbatim because some callers (tests, future per-folder workspace roots) want a custom anchor. Public entry-point most call sites use.