Skip to content
0

colorscheme

This README outlines the logic and design choices behind the refactored colorscheme.lua. The primary goal was to transform a static configuration into a mode-responsive system that syncs perfectly with your environment.

Overview

This configuration provides a unified visual experience across multiple colorschemes (Tokyonight, Catppuccin, Kanagawa, and Gruvbox). It is specifically engineered to respect the light/dark mode transitions of the Ghostty terminal, ensuring that UI elements remain legible and aesthetically consistent regardless of the time of day.

Key Features

  • Dynamic Palette Swapping: Automates the transition between tokyonight-storm (Dark) and tokyonight-day (Light) using Neovim's internal background state.
  • Unified Markdown Styling: Centralizes the look of Markdown headers (H1-H6), bold text, and blockquotes so that documentation looks identical across different themes.
  • Ghostty Integration: Leverages the terminal's theme-switching capability to drive Neovim’s internal color logic.
  • DRY (Don't Repeat Yourself) Architecture: Uses local helper functions to apply the same highlight logic to multiple plugins without duplicating code blocks.

Critical Implementations

1. Dual-Palette Injection (on_colors)

In the Tokyonight configuration, the refactor introduces a conditional palette check. Instead of hardcoded values, it defines dark_p and light_p tables.

Why this matters: Default themes often have search or visual selection colors that are either too jarring or too subtle when transparency is enabled. This implementation allows for manual "surgical" overrides of specific hex codes that adapt to the mode.

2. The Highlight Helper Pattern

The get_markdown_highlights (c) and get_ui_highlights (c) functions are the "brains" of the visual consistency:

  • Color-Agnostic Variables: By using the pattern c.red or c.maroon, the logic remains functional even if different themes use different naming conventions for their palettes.
  • Centralized Modification: To change the color of all H1 headers across every theme in your config, you only need to edit one line in the local function at the top of the file.

3. Background-Aware Logic

The code actively queries vim.o.background within the configuration blocks.

  • In Tokyonight: It determines whether to load the "Storm" or "Day" style.
  • In Catppuccin: It maps "Latte" to light mode and "Frappe" to dark mode.
  • In UI Elements: It adjusts the Folded code block background to ensure it remains distinct from the main buffer background.

Maintenance Tips

  • Adding New Themes: If you add a new theme (like rose-pine), you can simply call get_markdown_highlights (colors) within that plugin's setup to instantly inherit your custom styling.
  • Transparency: The transparent variable is global within the tokyonight config block, allowing you to toggle the "glass" look on or off for the entire UI in one go.
最近更新