config

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config loads the mdp TOML configuration and the small helpers (browser command resolution, fzf picker, extra CSS) that consume it. A missing config file is silent; malformed values produce warnings on the supplied error writer rather than failing the run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BrowserCmd

func BrowserCmd(browser any, url string, lookPath func(string) (string, error), goos string, errLog io.Writer) []string

BrowserCmd builds the argv used to open url. The lookPath and goos arguments are injected so tests don't have to touch the real PATH or runtime.GOOS.

func EnsureDefault

func EnsureDefault() error

EnsureDefault writes a commented default config file to Path() when one does not already exist. Existing files are left untouched. Failures (permission denied, etc.) are non-fatal: callers should ignore the returned error or surface it as a warning.

func ExpandTilde

func ExpandTilde(p string) string

ExpandTilde replaces a leading "~/" with the user's home directory. Bare "~" and other inputs are returned unchanged.

func ExtraCSS

func ExtraCSS(cfg Config, errLog io.Writer) string

ExtraCSS builds the CSS string contributed by the user's config. Errors are non-fatal: bad values are reported on errLog and skipped.

func FzfPick

func FzfPick(ctx context.Context, cwd string) (string, error)

FzfPick pipes a list of markdown files (cwd, recursive) into fzf and returns the user's pick. Cancellation returns "", nil.

func Path

func Path() string

Path returns the resolved config file path, honoring XDG_CONFIG_HOME and falling back to ~/.config when it is unset.

Types

type Config

type Config struct {
	Theme     string   `toml:"theme"`
	FontSize  *float64 `toml:"font_size"`
	CustomCSS string   `toml:"custom_css"`
	Browser   any      `toml:"browser"`
	Edit      bool     `toml:"edit"`
	Colemak   bool     `toml:"colemak"`
}

Config is the parsed TOML config. Fields use zero values / nil pointers to distinguish "unset" from explicitly-set values where it matters.

func Load

func Load() (Config, error)

Load reads and parses the config from Path(). A missing file is not an error: callers get a zero Config and nil. Parse errors return a zero Config plus the error so callers can warn the user.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL