Documentation
¶
Overview ¶
Package config loads, parses, and holds Fern's runtime configuration.
Index ¶
- Constants
- Variables
- func ConfigFilePath() string
- func DetectEditor() (string, error)
- func EnsureConfigFileExists(path string) error
- func EnsureShareDirExists() error
- func ExpandPath(path string) string
- func LoadState() fernState
- func SaveState(s fernState) error
- func ShareDirPath() string
- func StateFilePath() string
- func UpdateVaultConfigKey(vaultPath, key, value string) error
- type Config
- type Keys
- type NamedAssetDir
- type VaultConfig
- type ViewerKeys
Constants ¶
const DefaultVaultConfig = `` /* 441-byte string literal not displayed */
DefaultVaultConfig is the template written to a new vault's .fern/config.
Variables ¶
var Version = "dev"
Version is the current application version string. Set at build time via ldflags <tag>.
Functions ¶
func ConfigFilePath ¶
func ConfigFilePath() string
ConfigFilePath returns path to ".config/fern/config".
func DetectEditor ¶
DetectEditor returns the user's preferred editor from $EDITOR, $VISUAL, $FCEDIT, or a PATH search of common fallback editors.
func EnsureConfigFileExists ¶
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 ¶
ExpandPath expands a leading ~/, environment variables, and resolves the result to an absolute path. An empty string is returned unchanged.
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 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.
func UpdateVaultConfigKey ¶ added in v0.9.0
UpdateVaultConfigKey writes key = value to the vault config file, creating the file (and its parent .fern/ directory) if necessary. If the key already exists (active or commented-out), that line is updated in place.
Types ¶
type Config ¶
type Config struct {
Vault string
Vaults []string
Ext string
TodayTemplate bool
StartJournals []string
ShowSidebar bool
NotesDir string
JournalsDir string
TemplatesDir string
AssetsDir string
AssetDirs map[string]string // name to expanded absolute path (external dirs)
BookmarksFile string
DailyTemplate string
WeeklyTemplate string
MonthlyTemplate string
YearlyTemplate string
FoldLevel int
TabSpaces int
ExpandTabs bool // false = Tab inserts \t; true = Tab inserts ShiftWidth spaces
ShiftWidth int // spaces per Tab press when ExpandTabs is true (1-16)
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
// contains filtered or unexported fields
}
Config holds the full runtime configuration for a Fern session.
func LoadConfigs ¶ added in v1.2.0
LoadConfigs composes a full Config for the given vault by layering: configDefaults -> global config file -> vault paths -> vault config overrides. If vaultPath is empty, vault paths and vault overrides are skipped. vaultAssetDirs and Vaults are not set here.
func (*Config) AddAssetDir ¶ added in v1.2.0
AddAssetDir registers a named external asset directory, validates input, adds it to the in-memory map, and persists state.
func (*Config) FormatLink ¶
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 ¶
HasMultipleVaults reports whether more than one vault is configured.
type Keys ¶
type Keys struct {
Quit string
Search string
Command string
Help string
Edit string
Sidebar string
CloseTab string
NextTab string
PrevTab string
MoveTabLeft string
MoveTabRight 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 NamedAssetDir ¶ added in v1.2.0
NamedAssetDir is a device-local directory referenced by alias in asset links.
type VaultConfig ¶ added in v0.9.0
type VaultConfig struct {
Ext *string
StartJournals []string
AutoJournalPeriods *bool
WeekStart *string
NoteFrontmatter *bool
FuzzySearch *bool
CheckboxStates []string
LinkFormat *string
FoldLevel *int
TabSpaces *int
ExpandTabs *bool
ShiftWidth *int
Theme *string
StartMode *string
ShowSidebar *bool
}
VaultConfig holds the subset of Config fields that can be overridden per-vault via {vault}/.fern/config. Pointer fields allow distinguishing "not set" from "explicitly set to zero value"; nil means no override. Slice fields use nil = not overridden.
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
FoldExpand string
FoldCollapse string
SearchNext string
SearchPrev string
Escape string
Indent string
Dedent 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".