Skip to main content

vtcode_ui/theme/
syntax.rs

1use crate::theme::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_ui::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" => "base16-ocean.dark",
39        "material-ocean" | "material-dark" | "material" => "Material Dark",
40        "dracula" => "Dracula",
41        "monokai-classic" => "monokai-classic",
42        "night-owl" => "Night Owl",
43        "zenburn" => "Zenburn",
44        "jetbrains-darcula" => "base16-ocean.dark",
45        "man-page" => "base16-ocean.dark",
46        "homebrew" => "base16-ocean.dark",
47        "framer" => "base16-ocean.dark",
48        "espresso" => "base16-ocean.dark",
49        "afterglow" => "base16-ocean.dark",
50        "apple-classic" => "base16-ocean.dark",
51        "apple-system-colors" => "base16-ocean.dark",
52        "nord" => "base16-ocean.dark",
53        "nord-light" => "base16-ocean.light",
54        "apple-system-colors-light" => "base16-ocean.light",
55        "vitesse-light" | "vitesse-light-soft" => "base16-ocean.light",
56        "noir" | "ciapre" | "ciapre-dark" | "ciapre-blue" => "base16-ocean.dark",
57        "vitesse-black" | "vitesse-dark" | "vitesse-dark-soft" => "base16-ocean.dark",
58        // longbridge/gpui-kit ports: dark palettes share the neutral Base16
59        // Ocean Dark ramp, light palettes the Ocean Light ramp.
60        "adventure" | "adventure-time" | "alduin" | "asciinema" | "fahrenheit" | "harper" | "jellybeans" | "kibble"
61        | "spaceduck" | "twilight" | "ayu-dark" | "everforest-dark" | "flexoki-dark" | "hybrid-dark"
62        | "macos-classic-dark" | "mellifluous-dark" | "molokai-dark" | "tokyo-night" | "tokyo-storm" | "tokyo-moon" => {
63            "base16-ocean.dark"
64        }
65        "aurora-light"
66        | "ayu-light"
67        | "everforest-light"
68        | "flexoki-light"
69        | "hybrid-light"
70        | "macos-classic-light"
71        | "mellifluous-light"
72        | "molokai-light" => "base16-ocean.light",
73        "mono" | "ansi-classic" => "base16-ocean.dark",
74        _ => "base16-ocean.dark",
75    }
76}
77
78pub fn get_active_syntax_theme() -> &'static str {
79    get_syntax_theme_for_ui_theme(&active_theme_id())
80}