Expand description
Static config-file loader (DESIGN.md §5.12; first slice of the TOML surface called out in the design doc’s “TOML covers static option overrides only” line).
Reads lattice.toml from the XDG config home
(~/.config/lattice/lattice.toml on all Unix incl. macOS, honouring
$XDG_CONFIG_HOME; see config_home) and .lattice/config.toml
from the workspace root, in that precedence order. Project beats
user; :set writes after startup beat both.
§Design (read-only, walk-and-set)
The loader walks the parsed TOML table breadth-first. For each
sub-table, it asks: does its dotted path match a registered
structural prefix (e.g. completion.per-language)? If so, the
table is recorded verbatim in LoadOutcome::structural and
descent stops there – the caller (App, plugin host) owns the
interpretation of structural sections. If not, descent continues
and any scalar leaf becomes a parse_and_set_command("key=value")
call against the supplied ConfigRegistry.
This keeps the loader policy-free for everything map-shaped:
plugins (Phase 7), per-language overrides (Phase 4.2.g.5 (3b)),
and any future structurally-typed config all flow through the
same structural bucket.
§Errors are warnings
Parse failures, unknown keys, and validation rejects all
produce LoadMessages the caller surfaces in its message
buffer. Nothing here panics or aborts startup – a bad config
file is recoverable with an editor and a re-launch.
§What this is NOT
- Hot reload. The loader runs once at startup;
:reload-configis a future addition (will share the walk-and-set core). - A writer.
:customizepost-1.0 is the round-trip surface; it’ll move totoml_editfor write-preserving edits. - A keymap loader. Keymaps are a separate registry; their loader will compose with this one.
Structs§
- Load
Message - One diagnostic from the loader. Caller decides how to surface it (echo, message buffer, log line); the loader stays IO-agnostic.
- Load
Outcome - Outcome of loading one or more TOML files. The caller drains
messagesinto its echo / message buffer and walksstructuralto dispatch sub-tables to their owners.
Enums§
- Load
Message Level - Severity of a
LoadMessage.
Functions§
- cache_
home - The cache root,
<config-home>/lattice/cache/. - cache_
home_ from - Pure resolver behind
cache_home. - config_
home - The XDG config base directory for lattice’s config root.
- default_
user_ config_ path - Default user config path:
<config_home>/lattice/lattice.toml, i.e.~/.config/lattice/lattice.toml(honouring$XDG_CONFIG_HOME). Seeconfig_homefor the cross-platform resolution.Nonewhen no config home resolves (no$XDG_CONFIG_HOMEoverride and no$HOME). - load_
default_ paths - Load both default paths in standard precedence order: user
first, then project. Missing files are silent (no message).
structural_prefixeslists dotted prefixes the caller wants to handle itself (e.g.&["completion.per-language", "plugin"]). - load_
file - Load a single TOML file, applying scalar leaves to
registryand bucketing structural sub-tables. The path is recorded in every emitted message so the caller can surfacepath:reason-style diagnostics. - lookup_
dotted_ path - Walk a TOML table by a dotted path, returning the value at
the leaf or
Noneif any segment is missing or steps through a non-table. Used byworkspace/configurationto look up server-namespaced keys (e.g."rust-analyzer.cargo.features"walkstree["rust-analyzer"]["cargo"]["features"]). - migrate_
path - Move
oldtonewifoldexists andnewdoes not, returning whether anything moved. Works for a file or a directory. - project_
config_ path - Default project config path:
<workspace_root>/.lattice/config.toml. Caller suppliesworkspace_root(typically the directory the editor was launched in, walked up to the first.git/.lattice/marker if desired).