Expand description
User config: parse config.toml, resolve its path, and apply
per-segment overrides. Full contract in docs/specs/config.md.
Structs§
- Config
- Parsed
config.toml. Serde ignores unknown keys so a file from a newer linesmith still parses on an older binary; fields this version doesn’t know are dropped rather than rejected. The schema-sideadditionalProperties: falsetightens editor validation so typos likethme = "default"get flagged at the authoring layer; the runtime stays permissive (the unknown-key warning channel lives infrom_str_validated). - Config
Path - Where linesmith found its config path and how.
explicit = truemeans the user named a path directly (--configorLINESMITH_CONFIG); the run-time diagnostics use this to decide whether a missing file is worth warning about (explicit paths warn, implicit XDG fallbacks stay silent for first-run users). - Layout
Options [layout_options]section: render-path tunables that aren’t tied to a specific segment. Seedocs/specs/config.md§layout_options.- Line
Config [line]section: ordered list of segment ids to render in single-line mode, plus any numbered child tables ([line.1],[line.2], …) for multi-line mode. Theflatten-capturednumberedmap carries every other key as a rawtoml::Value. Key validation (positive integer pointing at a table with asegmentsarray) and ordering happen in the segment builder, which keeps the spec’s “unknown keys are warnings, not errors” forward-compat contract: a typo like[line] segmnts = [...]parses as atoml::Value::Array, reaches the builder, and emits a warning rather than failing the config load. Per specdocs/specs/config.md§Multi-line layouts.- Line
Entry Item - Inline-table form of
LineEntry. Typed fields cover today’s known knobs; everything else lands inextraso future fields parse without a schema bump. - Segment
Override [segments.<id>]override block. Each typed field, whenSome, replaces the segment’s built-in default. Any unrecognized keys land inextra, which the segment builder forwards to plugin scripts asctx.config.<key>.styleis stored as a raw string; the segment builder parses it at build time so parse errors emit warnings through the same callback that handles unknown-ID and inverted-bounds diagnostics.- Width
Bounds Config - Width-bounds override. Either side may be omitted; a missing side inherits from the segment’s built-in default.
Enums§
- Color
Policy - Config-level color override.
autohonors CLI flags and env vars;alwaysforces color even in non-TTY output;neverstrips all color. Sits below CLI flags and env vars in the precedence chain. - Config
Error - Failure modes when loading a config. A missing file is not an error; callers treat it as “use defaults.”
- Layout
Mode - Top-level
layout = "..."selector. Defaults toSingleLine(preserves pre-multi-line config behavior).MultiLineinstructs the builder + render loop to consume[line.N]sub-tables. - Line
Entry - One entry in
[line].segments. Per ADR-0024, the array is a mixed shape: bare strings ("model") round-trip asLineEntry::Idfor backward compatibility with the v0.x string- only schema; inline tables ({ type = "separator", character = " | " }) round-trip asLineEntry::Itemand carry per-boundary settings.
Constants§
- SCHEMA_
URL - URL for the published JSON Schema, pinned to
main. Single canonical URL — same shape bacon, starship, and dprint ship. The schema evolves forward-compatibly (fields added, not removed); editors validate “config field is allowed by schema” rather than “binary supports field,” so a schema slightly ahead of the installed binary loosens validation rather than tightens it. Versioned per-tag self-hosted URLs (biome’s model) are the destination oncelinesmithhas its own website plus schemastore.org coverage.
Functions§
- detect_
config_ path - Thin wrapper around
resolve_config_paththat reads the process env directly. Used at startup. - resolve_
config_ path - Where linesmith looks for its config file, in precedence order.
OsStr-typed env args so non-UTF-8 paths (/srv/café-binin a non-UTF-8 locale) survive the cascade rather than collapse toNoneupstream. - with_
schema_ directive - Prepend
#:schema <url>directive (taplo / VS Code / Zed convention) to a freshly-generated config body so editors pick up the published schema without per-user setup.