config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config resolves the fzf picker's mode-switch keybindings from (in precedence order) CLI flags, environment variables, a TOML config file, and built-in defaults.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath is the config file location, honoring XDG_CONFIG_HOME. It never creates the file; ccsession only reads config, never writes it.

func Validate

func Validate(kb Keybindings) error

Validate enforces that the three keys are mutually distinct, are not fzf reserved event names, and match the safe key syntax.

Types

type Config

type Config struct {
	Keybindings Keybindings `toml:"keybindings"`
}

Config mirrors the TOML file layout: a single [keybindings] table.

type Keybindings

type Keybindings struct {
	Grep  string `toml:"grep"`
	Dir   string `toml:"dir"`
	Fuzzy string `toml:"fuzzy"`
}

Keybindings holds the three picker mode-switch keys. An empty field means "not set here" and lets a lower-precedence source supply it.

func Defaults

func Defaults() Keybindings

Defaults are the historical hardcoded keys. buildScript(Defaults()) must reproduce the original fzf script (see main_test.go).

func Load

func Load(path string) (*Keybindings, error)

Load decodes the config file at path. A missing file is not an error (the file is optional): it returns (nil, nil) so the caller falls back to env/defaults. An unknown extension is an error so typos surface.

func Resolve

func Resolve(s Sources) (Keybindings, error)

Resolve picks each key from the first non-empty source (flag > env > file > default) and validates the result. It touches no OS state.

type Loader

type Loader func(data []byte, c *Config) error

Loader decodes a config file's bytes into c. Formats are registered by file extension in loaders, so adding e.g. ".pkl" is a one-line change here.

type Sources

type Sources struct {
	Flags Keybindings
	Env   Keybindings
	File  *Keybindings
}

Sources carries the candidate keybindings from each origin. File is a pointer because the config file is optional (nil = no file present).

Jump to

Keyboard shortcuts

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