# `MingaEditor.UI.Theme.Loader`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_editor/ui/theme/loader.ex#L1)

Discovers and loads user-defined theme files from disk.

Theme files are Elixir scripts (`.exs`) that return a map describing
face overrides, editor chrome colors, and optional inheritance from
a built-in theme. They live in `~/.config/minga/themes/` and are
evaluated at startup and on `:reload_themes`.

## Theme file format

A theme file must return a map with at least a `:name` key:

    # ~/.config/minga/themes/my_dark.exs
    %{
      name: :my_dark,
      inherits: :doom_one,
      faces: %{
        "keyword" => [fg: 0xFF79C6, bold: true],
        "comment" => [fg: 0x6272A4, italic: true],
        "@lsp.type.variable" => [fg: 0xBD93F9]
      },
      editor: %{bg: 0x282A36, fg: 0xF8F8F2}
    }

## Schema

- `:name` (required) — atom identifying the theme
- `:inherits` (optional) — atom name of a built-in theme to extend.
  The built-in theme's syntax map and editor colors are used as the
  base; the file's `:faces` and `:editor` fields override them.
- `:faces` (optional) — map of face name strings to style keyword
  lists. Merged via `Face.Registry.with_overrides/2`.
- `:editor` (optional) — map of editor chrome color overrides
  (`:bg`, `:fg`, `:tilde_fg`, `:split_border_fg`, etc.)

## Discovery

Theme files are found at:
1. `$XDG_CONFIG_HOME/minga/themes/*.exs` (if `$XDG_CONFIG_HOME` is set)
2. `~/.config/minga/themes/*.exs`

# `load_error`

```elixir
@type load_error() :: MingaEditor.UI.Theme.Loader.LoadError.t()
```

An error encountered while loading a theme file.

# `loaded_theme`

```elixir
@type loaded_theme() :: MingaEditor.UI.Theme.Loader.LoadedTheme.t()
```

A loaded user theme with its face registry and metadata.

# `load_all`

```elixir
@spec load_all(String.t()) :: {%{required(atom()) =&gt; loaded_theme()}, [load_error()]}
```

Discovers and loads all theme files from the themes directory.

Returns `{loaded_themes, errors}` where `loaded_themes` is a map
of theme name atoms to loaded theme structs, and `errors` is a
list of load errors.

# `load_file`

```elixir
@spec load_file(String.t()) :: {:ok, loaded_theme()} | {:error, load_error()}
```

Loads a single theme file.

Returns `{:ok, loaded_theme}` or `{:error, load_error}`.

# `themes_dir`

```elixir
@spec themes_dir() :: String.t()
```

Returns the themes directory path.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
