Documentation
¶
Overview ¶
Package theme loads Themes: named colours for the interface and for syntax highlighting. Gruvbox Dark and Gruvbox Light are built in; more can be dropped into $XDG_CONFIG_HOME/scrutiny/themes as TOML files.
Index ¶
- Constants
- Variables
- func Create(dir string, t Theme) error
- func Delete(dir, id string) error
- func File(dir, id string) string
- func ID(name string) string
- func Keys() (ui, syntax []string)
- func Swatch(v string) (hex string, alpha float64, ok bool)
- func Update(dir string, t Theme) error
- func WithAlpha(hex string, alpha float64) string
- type Theme
Constants ¶
const Default = "gruvbox-dark"
Default is the Theme used when the configured one is unknown.
Variables ¶
var ErrNotFound = errors.New("theme not found")
ErrNotFound is returned when editing a Theme that has no file.
Functions ¶
func ID ¶
ID turns a Theme's name into its ID, the name of its file: "Tokyo Night Storm" becomes "tokyo-night-storm".
func Swatch ¶
Swatch splits a colour into what a colour picker shows, #rrggbb, and its alpha; ok is false for colours it cannot (hsl()).
Types ¶
type Theme ¶
type Theme struct {
ID string `toml:"-"` // the file name without .toml
Custom bool `toml:"-"` // its file is in the themes directory, so it can be edited
Name string `toml:"name"`
Scheme string `toml:"scheme"` // "dark" or "light"
UI map[string]string `toml:"ui"`
Syntax map[string]string `toml:"syntax"`
}
Theme is a named set of colours. UI keys are the interface's CSS custom properties (e.g. "bg0", "add-bg"); Syntax keys are highlight capture names (e.g. "keyword", "function.method").
func Import ¶
Import makes a Theme called name from a pasted colour scheme: a Scrutiny Theme in TOML, or a Vim or Neovim one. Vim schemes are read from their `highlight` commands (or the output of `:highlight`), Neovim ones from `nvim_set_hl` calls or tables of groups; colours computed at runtime are not seen, but `local red = "#..."` style palettes are. Values the scheme does not give are derived from the ones it does.
func Load ¶
Load returns the built-in Themes overlaid with those in dir, sorted by ID, and an error for each file in dir that is not a valid Theme. Values a Theme leaves out fall back to Gruvbox Dark's.