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

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`

# `color`

```elixir
@type color() :: non_neg_integer()
```

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

# `style`

```elixir
@type style() :: keyword()
```

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

# `syntax`

```elixir
@type syntax() :: %{required(String.t()) =&gt; style()}
```

Syntax theme: tree-sitter capture name → style.

# `t`

```elixir
@type t() :: %MingaEditor.UI.Theme{
  agent: MingaEditor.UI.Theme.Agent.t() | nil,
  dashboard: MingaEditor.UI.Theme.Dashboard.t() | nil,
  editor: MingaEditor.UI.Theme.Editor.t(),
  git: MingaEditor.UI.Theme.Git.t(),
  gutter: MingaEditor.UI.Theme.Gutter.t(),
  minibuffer: MingaEditor.UI.Theme.Minibuffer.t(),
  modeline: MingaEditor.UI.Theme.Modeline.t(),
  name: atom(),
  picker: MingaEditor.UI.Theme.Picker.t(),
  popup: MingaEditor.UI.Theme.Popup.t(),
  search: MingaEditor.UI.Theme.Search.t(),
  syntax: syntax(),
  tab_bar: MingaEditor.UI.Theme.TabBar.t() | nil,
  tree: MingaEditor.UI.Theme.Tree.t()
}
```

# `agent_syntax`

```elixir
@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`

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

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

# `available`

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

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

# `dashboard_theme`

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

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

# `default`

```elixir
@spec default() :: atom()
```

Returns the default theme name atom.

# `get`

```elixir
@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!`

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

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

# `register_user_themes`

```elixir
@spec register_user_themes(%{
  required(atom()) =&gt; 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`

```elixir
@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`

```elixir
@spec user_themes() :: %{
  required(atom()) =&gt; MingaEditor.UI.Theme.Loader.loaded_theme()
}
```

Returns the map of registered user themes.

---

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