-- Paper Tonic Modern - Main Module -- Provides colorscheme loading and highlight helper functions local M = {} -- Import color palette local colors = require('paper-tonic-modern.colors') -- ============================================================================ -- Helper Functions -- ============================================================================ -- Convert color table {hex, 256, ansi} to usable formats local function get_color(color_def, mode) if type(color_def) == 'string' then -- Already a string like 'NONE', 'FG', 'BG' return color_def end if type(color_def) ~= 'table' then return 'NONE' end -- mode: 'gui' for hex, 'cterm' for 256-color if mode == 'gui' then return color_def[1] or 'NONE' elseif mode == 'cterm' then return color_def[2] or 'NONE' else return 'NONE' end end -- Set a highlight group -- spec = { -- fg = color_def, -- Foreground color -- bg = color_def, -- Background color -- sp = color_def, -- Special color (for undercurl, etc.) -- bold = boolean, -- italic = boolean, -- underline = boolean, -- undercurl = boolean, -- strikethrough = boolean, -- reverse = boolean, -- standout = boolean, -- } function M.highlight(group, spec) if type(spec) == 'string' then -- Link to another group vim.api.nvim_set_hl(0, group, { link = spec }) return end local hl = {} -- Colors if spec.fg then hl.fg = get_color(spec.fg, 'gui') hl.ctermfg = get_color(spec.fg, 'cterm') end if spec.bg then hl.bg = get_color(spec.bg, 'gui') hl.ctermbg = get_color(spec.bg, 'cterm') end if spec.sp then hl.sp = get_color(spec.sp, 'gui') end -- Styles if spec.bold then hl.bold = true end if spec.italic then hl.italic = true end if spec.underline then hl.underline = true end if spec.undercurl then hl.undercurl = true end if spec.strikethrough then hl.strikethrough = true end if spec.reverse then hl.reverse = true end if spec.standout then hl.standout = true end vim.api.nvim_set_hl(0, group, hl) end -- Convenience function to set multiple highlight groups function M.highlight_all(groups) for group, spec in pairs(groups) do M.highlight(group, spec) end end -- ============================================================================ -- Load Colorscheme -- ============================================================================ function M.load() -- Load highlight groups in order -- Each module returns a table of { group_name = spec } -- Base editor highlights (Normal, StatusLine, etc.) local editor = require('paper-tonic-modern.groups.editor') M.highlight_all(editor) -- Syntax highlights (Comment, Function, String, etc.) local syntax = require('paper-tonic-modern.groups.syntax') M.highlight_all(syntax) -- TreeSitter highlights (@variable, @function, etc.) local treesitter = require('paper-tonic-modern.groups.treesitter') M.highlight_all(treesitter) -- Semantic highlights (custom captures for CSS/HTML) local semantic = require('paper-tonic-modern.groups.semantic') M.highlight_all(semantic) -- LSP highlights (diagnostics, references) local lsp = require('paper-tonic-modern.groups.lsp') M.highlight_all(lsp) -- Plugin highlights (Telescope, Gitsigns, cmp, etc.) local plugins = require('paper-tonic-modern.groups.plugins') M.highlight_all(plugins) end -- Export colors for use in other modules M.colors = colors return M