config

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config loads, parses, and holds Fern's runtime configuration.

Index

Constants

View Source
const Version = "0.2.0"

Version is the current application version string.

Variables

This section is empty.

Functions

func ConfigFilePath

func ConfigFilePath() string

ConfigFilePath returns path to ".config/fern/config".

func DetectEditor

func DetectEditor() (string, error)

DetectEditor returns the user's preferred editor from $EDITOR, $VISUAL, $FCEDIT, or a PATH search of common fallback editors.

func EnsureConfigFileExists

func EnsureConfigFileExists(path string) error

EnsureConfigFileExists creates an empty config file if it doesn't exist.

func EnsureShareDirExists

func EnsureShareDirExists() error

EnsureShareDirExists creates the share directory if it doesn't exist.

func ExpandPath

func ExpandPath(path string) string

ExpandPath expands a leading ~/ and environment variables in path.

func LoadState

func LoadState() fernState

LoadState reads app state from the state file. Returns defaults when the file doesn't exist (fresh install). Paths in the returned struct are expanded.

func SaveState

func SaveState(s fernState) error

SaveState writes app state to the state file.

func ShareDirPath

func ShareDirPath() string

ShareDirPath returns the XDG data directory for fern: ~/.local/share/fern.

func StateFilePath

func StateFilePath() string

StateFilePath returns the path to the fern state file inside the share dir.

Types

type Config

type Config struct {
	Vault              string
	Vaults             []string
	Ext                string
	TodayTemplate      bool
	StartJournals      []string
	ShowSidebar        bool
	NotesDir           string
	JournalsDir        string
	TemplatesDir       string
	BookmarksFile      string
	DailyTemplate      string
	WeeklyTemplate     string
	MonthlyTemplate    string
	YearlyTemplate     string
	FoldLevel          int
	TabSpaces          int
	SortNotes          string
	SortJournals       string
	SortTemplates      string
	Theme              string
	StartMode          string
	WeekStart          string // "monday" or "sunday"
	AutoJournalPeriods bool   // auto-open period logs on startup when today is a period boundary
	LinkFormat         string // "wiki" or "markdown"
	NoteFrontmatter    bool   // true = scaffold new notes with title/date/tags frontmatter
	FuzzySearch        bool   // true = append * to bare FTS query terms (prefix matching)
	CheckboxStates     []string
	Keys               Keys
	ViewerKeys         ViewerKeys
}

Config holds the full runtime configuration for a Fern session.

func Load

func Load() (*Config, error)

Load reads and parses the config file, returning a populated Config.

func (c *Config) FormatLink(title, path string) string

FormatLink returns a link string in the configured format. title is the display name; path is the vault-relative path without extension.

func (*Config) HasMultipleVaults

func (c *Config) HasMultipleVaults() bool

HasMultipleVaults reports whether more than one vault is configured.

func (*Config) SaveState

func (c *Config) SaveState() error

SaveState persists the active vault, vaults list, and sidebar visibility to the share state file.

func (*Config) SwitchVault

func (c *Config) SwitchVault(path string)

SwitchVault updates the active vault path and all derived directory fields in c.

type Keys

type Keys struct {
	Quit             string
	Search           string
	Command          string
	Help             string
	Edit             string
	SectionNotes     string
	SectionJournals  string
	SectionTemplates string
	Sidebar          string
	CloseTab         string
	NextTab          string
	PrevTab          string
	MoveTabLeft      string
	MoveTabRight     string
	SortField        string
	SortDir          string
	Palette          string
}

Keys holds the application-level keybinding strings.

func DefaultKeys

func DefaultKeys() Keys

DefaultKeys returns the built-in default application key bindings.

type ViewerKeys

type ViewerKeys struct {
	MoveDown        string
	MoveUp          string
	MoveLeft        string
	MoveRight       string
	WordForward     string
	WordBackward    string
	LineStart       string
	LineEnd         string
	HalfPageDown    string
	HalfPageUp      string
	GotoPrefix      string
	GotoEnd         string
	Undo            string
	Redo            string
	InsertMode      string
	AppendEnd       string
	AppendAfter     string
	InsertAtStart   string
	ReplaceMode     string
	NewLineBelow    string
	NewLineAbove    string
	ToggleCheckbox  string
	InsertCheckbox  string
	VisualMode      string
	VisualLineMode  string
	Paste           string
	ReplacePrefix   string
	DeleteChar      string
	DeletePrefix    string
	Yank            string
	Cut             string
	Change          string
	SearchSelection string
	FoldPrefix      string
	Escape          string
}

ViewerKeys holds user-configurable keybinding strings for the viewer. Each field is a comma-separated list of key names (e.g. "j,down"). An empty string means "keep the built-in default".

Jump to

Keyboard shortcuts

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