Documentation
¶
Overview ¶
Package config loads nook's user configuration from ~/.config/nook/config.toml.
The file has two sections — [editor] for behavior toggles and [theme] for the named palette — and every key is optional. Missing fields fall back to Default(); unknown keys are accepted silently (forward-compat). A malformed file returns an error from Load; the host shows a status hint and falls back to defaults rather than refusing to start.
Live reload is intentionally manual in v0.15.0: the host binds `alt+,` to re-read the file at runtime. fsnotify-based auto-reload is a follow-up.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("config: file not found")
ErrNotFound is returned by Load when the config file is absent. The host treats this as "no settings file" and uses Default() without surfacing an error to the user. Distinct from a parse error, which IS surfaced.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Editor EditorConfig `toml:"editor"`
}
Config is the deserialized user configuration. New fields should default to the zero value that matches Default() so an empty TOML file is equivalent to no file at all.
func Default ¶
func Default() Config
Default returns the baseline configuration. Equivalent to loading an empty file. Use this as the fallback when ~/.config/nook/config.toml does not exist or fails to parse.
func Load ¶
Load reads and parses the config file at path. Returns ErrNotFound when the file doesn't exist (the host should fall back to Default silently); any other error indicates the file exists but is malformed (the host should surface the message and fall back to Default).
Fields missing from the file are filled in from Default — so loading an empty file is identical to calling Default().
type EditorConfig ¶
type EditorConfig struct {
// TabWidth is the column count a hard tab expands to in the rendered
// buffer. Default 4. The on-disk file bytes always stay tabs.
TabWidth int `toml:"tab_width"`
// FormatOnSave runs textDocument/formatting through the attached LSP
// before writing. Default true. Alt+S still forces a no-format save.
FormatOnSave bool `toml:"format_on_save"`
// LineNumbers controls whether the gutter prints the row number.
// Default true.
LineNumbers bool `toml:"line_numbers"`
// InlayHints toggles gopls type / parameter hint glyphs woven into
// the source. Default true. Alt+Y still toggles at runtime.
InlayHints bool `toml:"inlay_hints"`
// Theme is the named palette to apply at startup. Must match one of
// the names registered in components/theme; unknown names fall back
// to "default" and surface a status hint.
Theme string `toml:"theme"`
}
EditorConfig holds the per-pane behavior toggles. Defaults match the hard-coded behavior shipped before settings existed, so an empty file is a no-op for existing users.