Skip to main content

vtcode_theme/
syntax.rs

1use crate::runtime::active_theme_id;
2
3/// Get the recommended syntax highlighting theme for a given UI theme.
4///
5/// For code blocks and syntax highlighting:
6/// ```rust
7/// use vtcode_theme::{active_theme_id, get_syntax_theme_for_ui_theme};
8///
9/// let ui_theme = active_theme_id();
10/// let syntax_theme = get_syntax_theme_for_ui_theme(&ui_theme);
11/// assert!(!syntax_theme.is_empty());
12/// ```
13pub fn get_syntax_theme_for_ui_theme(ui_theme: &str) -> &'static str {
14    match ui_theme.to_lowercase().as_str() {
15        "ayu" => "ayu-dark",
16        "ayu-mirage" => "ayu-mirage",
17        "catppuccin-latte" => "catppuccin-latte",
18        "catppuccin-frappe" => "catppuccin-frappe",
19        "catppuccin-macchiato" => "catppuccin-macchiato",
20        "catppuccin-mocha" => "catppuccin-mocha",
21        "solarized-dark" | "solarized-dark-hc" => "Solarized (dark)",
22        "solarized-light" => "Solarized (light)",
23        "gruvbox-dark" | "gruvbox-dark-hard" => "gruvbox-dark",
24        "gruvbox-light" | "gruvbox-light-hard" => "gruvbox-light",
25        "gruvbox-material" | "gruvbox-material-dark" => "gruvbox-dark",
26        "gruvbox-material-light" => "gruvbox-light",
27        "tomorrow" => "Tomorrow",
28        "tomorrow-night" => "Tomorrow Night",
29        "tomorrow-night-blue" => "Tomorrow Night Blue",
30        "tomorrow-night-bright" => "Tomorrow Night Bright",
31        "tomorrow-night-eighties" => "Tomorrow Night Eighties",
32        "tomorrow-night-burns" => "Tomorrow Night",
33        "github-dark" => "GitHub Dark",
34        "github" => "GitHub",
35        "atom-one-dark" => "OneDark",
36        "atom-one-light" => "OneLight",
37        "atom" => "base16-ocean.dark",
38        "spacegray" | "spacegray-bright" | "spacegray-eighties" | "spacegray-eighties-dull" => {
39            "base16-ocean.dark"
40        }
41        "material-ocean" | "material-dark" | "material" => "Material Dark",
42        "dracula" => "Dracula",
43        "monokai-classic" => "monokai-classic",
44        "night-owl" => "Night Owl",
45        "zenburn" => "Zenburn",
46        "jetbrains-darcula" => "base16-ocean.dark",
47        "man-page" => "base16-ocean.dark",
48        "homebrew" => "base16-ocean.dark",
49        "framer" => "base16-ocean.dark",
50        "espresso" => "base16-ocean.dark",
51        "adventure-time" => "base16-ocean.dark",
52        "afterglow" => "base16-ocean.dark",
53        "apple-classic" => "base16-ocean.dark",
54        "apple-system-colors" => "base16-ocean.dark",
55        "apple-system-colors-light" => "base16-ocean.light",
56        "vitesse-light" | "vitesse-light-soft" => "base16-ocean.light",
57        "ciapre" | "ciapre-dark" | "ciapre-blue" => "base16-ocean.dark",
58        "vitesse-black" | "vitesse-dark" | "vitesse-dark-soft" => "base16-ocean.dark",
59        "mono" | "ansi-classic" => "base16-ocean.dark",
60        _ => "base16-ocean.dark",
61    }
62}
63
64pub fn get_active_syntax_theme() -> &'static str {
65    get_syntax_theme_for_ui_theme(&active_theme_id())
66}