NvChad base46

repository·v3.0·Indexed 43 days ago

https://github.com/nvchad/base46

A theme engine and plugin for NvChad that provides optimized, structured color schemes. It utilizes a dual-table system, separating UI colors (base_30) from syntax highlighting colors (base_16), the latter of which follows the Base16 styling convention.

Tokens
864
Snippets
1
Records
5
Agent score
5%

What's inside base46

  1. How theme variables work in base46

    v3.0

    Base46 uses two primary tables to define a theme's visual identity:

    1. base_30: Used for general UI elements (backgrounds, statuslines, menus, etc.).
    2. base_16: Used for syntax highlighting. This follows the Base16 styling convention.

    When defining these, it is recommended to use a color lightening/darkening tool to ensure consistent contrast. Note that the values provided in the default theme table are approximate guides rather than strict requirements.

  2. Setup NvChad base46

    v3.0

    Base46 is a theme plugin designed to be used with NvChad. For the best experience, it should be used alongside NvChad's UI plugin.

    To set it up:

    1. Follow the installation documentation for the NvChad UI plugin.
    2. Refer to the Neovim help documentation using :h nvui.base46 for specific details on how the UI plugin interacts with base46.
  3. Inspect and test highlights

    v3.0

    To test your theme or debug specific colors:

    1. Check current highlights: Use the :hi command to list all highlight groups. Use :hi <group_name> to see the specific settings for a group.
    2. Inspect under cursor: Run :Inspect or :InspectTree to see exactly which highlight group is being applied to the text under your cursor.
    3. Manual testing: You can manually set highlights using the Neovim Lua API to test color combinations before committing them to your theme file.

    Testing a new theme file: Place your theme file in your /lua/themes folder, then select it via the NvChad theme switcher or by updating your chadrc configuration.

  4. Define a custom theme table

    v3.0

    To create a new theme, you must define a table containing base_30, base_16, and optionally polish_hl and type. Use the base46.override_theme function to finalize the table for use.

    Key components:

    • base_30: UI colors (e.g., black, grey, statusline_bg).
    • base_16: Syntax colors (e.g., base00 through base0F).
    • polish_hl: Used for overriding or adding specific highlights for integrations like Treesitter or general defaults.
    • type: Set to either "dark" or "light".
    ---@type Base46Table
    local M = {}
    
    -- UI colors
    M.base_30 = {
      black = "#000000",
      white = "#ffffff",
      -- ... other UI colors
    }
    
    -- Syntax colors (Base16)
    M.base_16 = {
      base00 = "#1a1a1a",
      -- ... base01 through base0F
    }
    
    -- Optional: Overriding specific highlights
    M.polish_hl = {
      defaults = {
        Comment = { bg = "#ffffff", italic = true },
      },
      treesitter = {
        ["@variable"] = { fg = "#000000" },
      },
    }
    
    M.type = "dark"
    
    -- Finalize the theme
    M = require("base46").override_theme(M, "my_theme_name")
    
    return M