theme

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 13 Imported by: 0

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

View Source
const Default = "gruvbox-dark"

Default is the Theme used when the configured one is unknown.

Variables

View Source
var ErrNotFound = errors.New("theme not found")

ErrNotFound is returned when editing a Theme that has no file.

Functions

func Create

func Create(dir string, t Theme) error

Create writes t to dir as a new Theme file, refusing to replace one.

func Delete

func Delete(dir, id string) error

Delete removes the Theme id's file from dir.

func File

func File(dir, id string) string

File is the path of the Theme id's file in dir.

func ID

func ID(name string) string

ID turns a Theme's name into its ID, the name of its file: "Tokyo Night Storm" becomes "tokyo-night-storm".

func Keys

func Keys() (ui, syntax []string)

Keys are the UI and syntax keys every Theme has.

func Swatch

func Swatch(v string) (hex string, alpha float64, ok bool)

Swatch splits a colour into what a colour picker shows, #rrggbb, and its alpha; ok is false for colours it cannot (hsl()).

func Update

func Update(dir string, t Theme) error

Update replaces t's file in dir, which must exist.

func WithAlpha

func WithAlpha(hex string, alpha float64) string

WithAlpha is hex at alpha, as rgba() when it is see-through.

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 Find

func Find(themes []Theme, id string) (Theme, bool)

Find returns the Theme with id.

func Import

func Import(name, src string) (Theme, error)

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

func Load(dir string) ([]Theme, []error)

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.

func (Theme) CSS

func (t Theme) CSS() string

CSS renders the Theme as custom properties and highlight rules.

func (Theme) TOML

func (t Theme) TOML() string

TOML is t as a Theme file.

Jump to

Keyboard shortcuts

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