MingaEditor.UI.Theme (Minga v0.1.0)

Copy Markdown View Source

Unified color theme for the entire editor.

A theme holds every color the UI needs, organized into semantic groups: syntax highlighting, editor chrome, modeline, gutter, picker, minibuffer, search highlights, and popups. Built-in themes are functions that return a populated %Theme{} struct.

Usage in config

use Minga.Config
set :theme, :catppuccin_mocha

Built-in themes

  • :doom_one
  • :catppuccin_frappe
  • :catppuccin_latte
  • :catppuccin_macchiato
  • :catppuccin_mocha
  • :one_dark
  • :one_light

Summary

Types

RGB color as a non-negative integer (e.g., 0xFF6C6B).

A style keyword list compatible with MingaEditor.Frontend.Protocol.style().

Syntax theme: tree-sitter capture name → style.

t()

Functions

Returns a syntax theme map customized for the agent chat buffer.

Returns the agent theme section, falling back to a basic default.

Returns all available theme name atoms (built-in + user-defined).

Returns the dashboard theme section, falling back to a basic default.

Returns the default theme name atom.

Returns the theme struct for the given name atom.

Returns the theme struct for the given name, raising on invalid name.

Registers user-defined themes loaded from disk.

Returns the style for a tree-sitter capture name, using suffix fallback.

Returns the map of registered user themes.

Types

color()

@type color() :: non_neg_integer()

RGB color as a non-negative integer (e.g., 0xFF6C6B).

style()

@type style() :: keyword()

A style keyword list compatible with MingaEditor.Frontend.Protocol.style().

syntax()

@type syntax() :: %{required(String.t()) => style()}

Syntax theme: tree-sitter capture name → style.

t()

Functions

agent_syntax(theme)

@spec agent_syntax(t()) :: syntax()

Returns a syntax theme map customized for the agent chat buffer.

Overrides delimiter and punctuation captures to use the agent theme's delimiter_dim color, so tree-sitter naturally dims markdown syntax characters (**, *, `, #, ```, brackets, list markers). Link text uses link_fg and URLs use delimiter_dim.

The base syntax map comes from the editor's global theme; only the agent-specific overrides are merged on top.

agent_theme(theme)

@spec agent_theme(t()) :: MingaEditor.UI.Theme.Agent.t()

Returns the agent theme section, falling back to a basic default.

available()

@spec available() :: [atom()]

Returns all available theme name atoms (built-in + user-defined).

dashboard_theme(theme)

@spec dashboard_theme(t()) :: MingaEditor.UI.Theme.Dashboard.t()

Returns the dashboard theme section, falling back to a basic default.

default()

@spec default() :: atom()

Returns the default theme name atom.

get(name)

@spec get(atom()) :: {:ok, t()} | :error

Returns the theme struct for the given name atom.

Checks user-defined themes first, then built-in themes.

get!(name)

@spec get!(atom()) :: t()

Returns the theme struct for the given name, raising on invalid name.

register_user_themes(themes)

@spec register_user_themes(%{
  required(atom()) => MingaEditor.UI.Theme.Loader.loaded_theme()
}) :: :ok

Registers user-defined themes loaded from disk.

Called by the theme loader at startup and on reload. Stores themes in :persistent_term for fast reads on the render path.

style_for_capture(syntax, name)

@spec style_for_capture(t() | syntax(), String.t()) :: style()

Returns the style for a tree-sitter capture name, using suffix fallback.

Tries exact match first. If not found, strips the last .segment and retries. Returns [] if no match is found.

Examples

iex> theme = MingaEditor.UI.Theme.get!(:doom_one)
iex> style = MingaEditor.UI.Theme.style_for_capture(theme, "keyword")
iex> Keyword.get(style, :bold)
true

iex> theme = MingaEditor.UI.Theme.get!(:doom_one)
iex> MingaEditor.UI.Theme.style_for_capture(theme, "nonexistent")
[]

user_themes()

@spec user_themes() :: %{
  required(atom()) => MingaEditor.UI.Theme.Loader.loaded_theme()
}

Returns the map of registered user themes.