diff --git a/lua/github-theme/config.lua b/lua/github-theme/config.lua index 67718e6..6ad5414 100644 --- a/lua/github-theme/config.lua +++ b/lua/github-theme/config.lua @@ -1,8 +1,54 @@ local collect = require('github-theme.lib.collect') local util = require('github-theme.util') - local M = { theme = 'github_dark', has_options = false } +-- TODO: improve type of `specs` and `palettes` +---@class (exact) GhTheme.Config +---@field options? GhTheme.Config.Options +---@field palettes? table +---@field specs? table +---@field groups? table> + +---@class (exact) GhTheme.Config.Module +---@field enable? boolean whether to set plugin-specific highlights for this module/plugin + +---@class (exact) GhTheme.Config.Module.Coc: GhTheme.Config.Module +---@field background? boolean whether to set background color of virtual text + +---@class (exact) GhTheme.Config.Module.Diagnostic: GhTheme.Config.Module +---@field background? boolean whether to set background color of virtual text + +---@class (exact) GhTheme.Config.Module.NativeLSP: GhTheme.Config.Module +---@field background? boolean whether to set background color of virtual text + +---Config for external modules/plugins. +---@class (exact) GhTheme.Config.Options.Modules +---@field cmp? boolean|GhTheme.Config.Module +---@field coc? boolean|GhTheme.Config.Module.Coc +---@field coc_explorer? boolean|GhTheme.Config.Module +---@field dapui? boolean|GhTheme.Config.Module +---@field diffchar? boolean|GhTheme.Config.Module +---@field dashboard? boolean|GhTheme.Config.Module +---@field diagnostic? boolean|GhTheme.Config.Module.Diagnostic +---@field fidget? boolean|GhTheme.Config.Module +---@field fzf? boolean|GhTheme.Config.Module +---@field gitgutter? boolean|GhTheme.Config.Module +---@field gitsigns? boolean|GhTheme.Config.Module +---@field indent_blankline? boolean|GhTheme.Config.Module +---@field lsp_semantic_tokens? boolean|GhTheme.Config.Module +---@field lsp_trouble? boolean|GhTheme.Config.Module +---@field mini? boolean|GhTheme.Config.Module +---@field native_lsp? boolean|GhTheme.Config.Module.NativeLSP +---@field neogit? boolean|GhTheme.Config.Module +---@field neotree? boolean|GhTheme.Config.Module +---@field notify? boolean|GhTheme.Config.Module +---@field nvimtree? boolean|GhTheme.Config.Module +---@field telescope? boolean|GhTheme.Config.Module +---@field treesitter? boolean|GhTheme.Config.Module +---@field treesitter_context? boolean|GhTheme.Config.Module +---@field whichkey? boolean|GhTheme.Config.Module + +---@class GhTheme.Config.Options local defaults = { compile_file_suffix = '_compiled', compile_path = util.join_paths(util.cache_home, 'github-theme'), @@ -13,15 +59,34 @@ local defaults = { dim_inactive = false, module_default = true, styles = { + ---@type GhTheme.HighlightGroup.Style comments = 'NONE', + + ---@type GhTheme.HighlightGroup.Style functions = 'NONE', + + ---@type GhTheme.HighlightGroup.Style keywords = 'NONE', + + ---@type GhTheme.HighlightGroup.Style variables = 'NONE', + + ---@type GhTheme.HighlightGroup.Style conditionals = 'NONE', + + ---@type GhTheme.HighlightGroup.Style constants = 'NONE', + + ---@type GhTheme.HighlightGroup.Style numbers = 'NONE', + + ---@type GhTheme.HighlightGroup.Style operators = 'NONE', + + ---@type GhTheme.HighlightGroup.Style strings = 'NONE', + + ---@type GhTheme.HighlightGroup.Style types = 'NONE', }, inverse = { @@ -33,9 +98,12 @@ local defaults = { floats = true, sidebars = { enable = true, + ---List of (filetype or `'terminal'`) whose bg will be darkened. list = {}, }, }, + + ---@type GhTheme.Config.Options.Modules modules = { coc = { background = true, @@ -55,6 +123,12 @@ local defaults = { }, } +-- The following is done to disallow the addition of any more fields. + +---@type GhTheme.Config.Options +---@diagnostic disable-next-line: redefined-local +local defaults = defaults + M.options = collect.deep_copy(defaults) M.module_names = { @@ -84,10 +158,12 @@ M.module_names = { 'whichkey', } +---@param name GhTheme.Theme function M.set_theme(name) M.theme = name end +---@param opts GhTheme.Config.Options function M.set_options(opts) opts = opts or {} M.options = collect.deep_extend(M.options, opts) @@ -107,7 +183,7 @@ end function M.hash() local hash = require('github-theme.lib.hash')(M.options) - return hash and hash or 0 + return hash or 0 end return M diff --git a/lua/github-theme/group.lua b/lua/github-theme/group.lua index 529501d..bac848f 100644 --- a/lua/github-theme/group.lua +++ b/lua/github-theme/group.lua @@ -3,6 +3,35 @@ local template = require('github-theme.util.template') local override = require('github-theme.override') local M = {} +---A string whose contents is a comma-separated list of styles. +---@alias GhTheme.HighlightGroup.Style +---| "NONE" +---| "bold" +---| "standout" +---| "underline" +---| "undercurl" +---| "underdouble" +---| "underdotted" +---| "underdashed" +---| "strikethrough" +---| "italic" +---| "reverse" +---| "nocombine" +---| string + +---A Neovim highlight-group definition. +---@class (exact) GhTheme.HighlightGroup +---@field fg? GhTheme.Color.CSSHexString +---@field bg? GhTheme.Color.CSSHexString +---@field sp? GhTheme.Color.CSSHexString +---@field style? GhTheme.HighlightGroup.Style +---@field blend? integer +---@field nocombine? boolean +---@field link? string +---@field force? boolean + +---@param spec GhTheme.Spec +---@return table function M.from(spec) local config = require('github-theme.config').options @@ -44,9 +73,11 @@ function M.from(spec) return res end -function M.load(name) - name = name or require('github-theme.config').theme - return M.from(require('github-theme.spec').load(name)) +---@param theme? GhTheme.Theme +---@return table +function M.load(theme) + theme = theme or require('github-theme.config').theme + return M.from(require('github-theme.spec').load(theme)) end return M diff --git a/lua/github-theme/group/modules/cmp.lua b/lua/github-theme/group/modules/cmp.lua index ba3ab3b..e1f8e48 100644 --- a/lua/github-theme/group/modules/cmp.lua +++ b/lua/github-theme/group/modules/cmp.lua @@ -2,11 +2,15 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param config GhTheme.Config.Options +---@param _opts table +function M.get(spec, config, _opts) local has_ts = config.modules.treesitter local syn = spec.syntax -- stylua: ignore + ---@type table return { CmpDocumentation = { fg = spec.fg1, bg = spec.bg0 }, CmpDocumentationBorder = { fg = spec.sel0, bg = spec.bg0 }, diff --git a/lua/github-theme/group/modules/coc.lua b/lua/github-theme/group/modules/coc.lua index e6022df..37271a1 100644 --- a/lua/github-theme/group/modules/coc.lua +++ b/lua/github-theme/group/modules/coc.lua @@ -2,9 +2,13 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param opts table +function M.get(spec, _config, opts) local syn = spec.syntax + ---@type table return { CocInlayHint = { fg = syn.comment, bg = opts.background and spec.bg2 or 'NONE' }, } diff --git a/lua/github-theme/group/modules/coc_explorer.lua b/lua/github-theme/group/modules/coc_explorer.lua index 055a214..3513670 100644 --- a/lua/github-theme/group/modules/coc_explorer.lua +++ b/lua/github-theme/group/modules/coc_explorer.lua @@ -2,7 +2,11 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(spec, _config, _opts) + ---@type table return { CocExplorerNormalFloat = { link = 'NormalSB' }, diff --git a/lua/github-theme/group/modules/dapui.lua b/lua/github-theme/group/modules/dapui.lua index 933deaa..59a4ae0 100644 --- a/lua/github-theme/group/modules/dapui.lua +++ b/lua/github-theme/group/modules/dapui.lua @@ -2,10 +2,14 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(spec, _config, _opts) local c = spec.palette -- stylua: ignore + ---@type table return { DapUIScope = { fg = c.cyan.base }, DapUIType = { fg = c.magenta.base }, diff --git a/lua/github-theme/group/modules/dashboard.lua b/lua/github-theme/group/modules/dashboard.lua index cf05ef9..0cca31d 100644 --- a/lua/github-theme/group/modules/dashboard.lua +++ b/lua/github-theme/group/modules/dashboard.lua @@ -2,8 +2,12 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(spec, _config, _opts) -- stylua: ignore + ---@type table return { DashboardShortCut = { link = 'Identifier' }, DashboardHeader = { link = 'Title' }, diff --git a/lua/github-theme/group/modules/diagnostic.lua b/lua/github-theme/group/modules/diagnostic.lua index 4fd3aee..5a7244b 100644 --- a/lua/github-theme/group/modules/diagnostic.lua +++ b/lua/github-theme/group/modules/diagnostic.lua @@ -1,10 +1,14 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param opts table +function M.get(spec, _config, opts) local d = spec.diag local dbg = spec.diag_bg -- stylua: ignore + ---@type table return { DiagnosticError = { fg = d.error }, DiagnosticWarn = { fg = d.warn }, @@ -17,9 +21,9 @@ function M.get(spec, config, opts) DiagnosticSignHint = { link = 'DiagnosticHint' }, DiagnosticVirtualTextError = { fg = d.error, bg = opts.background and dbg.error or 'NONE' }, - DiagnosticVirtualTextWarn = { fg = d.warn, bg = opts.background and dbg.warn or 'NONE' }, - DiagnosticVirtualTextInfo = { fg = d.info, bg = opts.background and dbg.info or 'NONE' }, - DiagnosticVirtualTextHint = { fg = d.hint, bg = opts.background and dbg.hint or 'NONE' }, + DiagnosticVirtualTextWarn = { fg = d.warn, bg = opts.background and dbg.warn or 'NONE' }, + DiagnosticVirtualTextInfo = { fg = d.info, bg = opts.background and dbg.info or 'NONE' }, + DiagnosticVirtualTextHint = { fg = d.hint, bg = opts.background and dbg.hint or 'NONE' }, DiagnosticUnderlineError = { style = 'undercurl', sp = d.error }, DiagnosticUnderlineWarn = { style = 'undercurl', sp = d.warn }, diff --git a/lua/github-theme/group/modules/diffchar.lua b/lua/github-theme/group/modules/diffchar.lua index f443e62..1dc1678 100644 --- a/lua/github-theme/group/modules/diffchar.lua +++ b/lua/github-theme/group/modules/diffchar.lua @@ -2,7 +2,11 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(spec, _config, _opts) + ---@type table return { DiffAdd = { link = 'diffAdded' }, DiffChange = { link = 'diffChanged' }, diff --git a/lua/github-theme/group/modules/fidget.lua b/lua/github-theme/group/modules/fidget.lua index 38bcdeb..3b1bb21 100644 --- a/lua/github-theme/group/modules/fidget.lua +++ b/lua/github-theme/group/modules/fidget.lua @@ -2,11 +2,15 @@ local M = {} -function M.get(spec, config, opts) +---@param _spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(_spec, _config, _opts) -- stylua: ignore + ---@type table return { FidgetTitle = { link = 'Title' }, - FidgetTask = { link = 'LineNr' }, + FidgetTask = { link = 'LineNr' }, } end diff --git a/lua/github-theme/group/modules/fzf.lua b/lua/github-theme/group/modules/fzf.lua index 5769063..00b7c01 100644 --- a/lua/github-theme/group/modules/fzf.lua +++ b/lua/github-theme/group/modules/fzf.lua @@ -2,8 +2,12 @@ local M = {} -function M.get(spec, config, opts) +---@param _spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(_spec, _config, _opts) -- stylua: ignore + ---@type table return { FzfLuaNormal = { link = 'Normal' }, FzfLuaBorder = { link = 'Normal' }, diff --git a/lua/github-theme/group/modules/gitgutter.lua b/lua/github-theme/group/modules/gitgutter.lua index 9034409..1d34ed1 100644 --- a/lua/github-theme/group/modules/gitgutter.lua +++ b/lua/github-theme/group/modules/gitgutter.lua @@ -2,10 +2,14 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(spec, _config, _opts) local git = spec.git -- stylua: ignore + ---@type table return { GitGutterAdd = { fg = git.add }, -- diff mode: Added line |diff.txt| GitGutterChange = { fg = git.changed }, -- diff mode: Changed line |diff.txt| diff --git a/lua/github-theme/group/modules/gitsigns.lua b/lua/github-theme/group/modules/gitsigns.lua index 5e71812..3852481 100644 --- a/lua/github-theme/group/modules/gitsigns.lua +++ b/lua/github-theme/group/modules/gitsigns.lua @@ -2,10 +2,14 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(spec, _config, _opts) local git = spec.git -- stylua: ignore + ---@type table return { GitSignsAdd = { fg = git.add }, -- diff mode: Added line |diff.txt| GitSignsChange = { fg = git.changed }, -- diff mode: Changed line |diff.txt| diff --git a/lua/github-theme/group/modules/indent_blankline.lua b/lua/github-theme/group/modules/indent_blankline.lua index 06e18e9..7c42d5a 100644 --- a/lua/github-theme/group/modules/indent_blankline.lua +++ b/lua/github-theme/group/modules/indent_blankline.lua @@ -4,13 +4,17 @@ local C = require('github-theme.lib.color') local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(spec, _config, _opts) local p = spec.palette local fg = C(spec.bg1):blend(C(spec.fg1), 0.1):to_css() local cyan_fg = C(spec.bg1):blend(C(p.cyan.bright), 0.35):to_css() -- stylua: ignore + ---@type table return { IndentBlanklineChar = { fg = fg }, IndentBlanklineContextChar = { fg = cyan_fg }, diff --git a/lua/github-theme/group/modules/lsp_semantic_tokens.lua b/lua/github-theme/group/modules/lsp_semantic_tokens.lua index 66f1c9a..c4d8519 100644 --- a/lua/github-theme/group/modules/lsp_semantic_tokens.lua +++ b/lua/github-theme/group/modules/lsp_semantic_tokens.lua @@ -2,7 +2,11 @@ local M = {} -function M.get(spec, config, opts) +---@param _spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(_spec, _config, _opts) + ---@type table return { -- LSP Semantic token highlight groups ['@lsp.type.enum'] = { link = '@type' }, diff --git a/lua/github-theme/group/modules/lsp_trouble.lua b/lua/github-theme/group/modules/lsp_trouble.lua index 4daa898..7f6050a 100644 --- a/lua/github-theme/group/modules/lsp_trouble.lua +++ b/lua/github-theme/group/modules/lsp_trouble.lua @@ -2,10 +2,14 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(spec, _config, _opts) local c = spec.palette -- stylua: ignore + ---@type table return { LspTroubleText = { fg = spec.fg2 }, LspTroubleCount = { fg = c.magenta.base, bg = spec.fg3 }, diff --git a/lua/github-theme/group/modules/mini.lua b/lua/github-theme/group/modules/mini.lua index 592b44a..a90954f 100644 --- a/lua/github-theme/group/modules/mini.lua +++ b/lua/github-theme/group/modules/mini.lua @@ -4,7 +4,10 @@ local C = require('github-theme.lib.color') local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(spec, _config, _opts) local c = spec.palette local function blend(color, a) @@ -12,6 +15,7 @@ function M.get(spec, config, opts) end -- stylua: ignore + ---@type table return { MiniAnimateCursor = { style = 'reverse,nocombine' }, MiniAnimateNormalFloat = { link = 'NormalFloat' }, diff --git a/lua/github-theme/group/modules/native_lsp.lua b/lua/github-theme/group/modules/native_lsp.lua index da761cc..ef8a139 100644 --- a/lua/github-theme/group/modules/native_lsp.lua +++ b/lua/github-theme/group/modules/native_lsp.lua @@ -1,9 +1,13 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param opts table +function M.get(spec, _config, opts) local syn = spec.syntax -- stylua: ignore + ---@type table return { -- These groups are for the native LSP client. Some other LSP clients may -- use these groups, or use their own. Consult your LSP client's diff --git a/lua/github-theme/group/modules/neogit.lua b/lua/github-theme/group/modules/neogit.lua index 039fcc0..cc4767b 100644 --- a/lua/github-theme/group/modules/neogit.lua +++ b/lua/github-theme/group/modules/neogit.lua @@ -2,8 +2,12 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(spec, _config, _opts) -- stylua: ignore + ---@type table return { NeogitBranch = { fg = spec.diag.warn }, NeogitRemote = { fg = spec.diag.hint }, diff --git a/lua/github-theme/group/modules/neotree.lua b/lua/github-theme/group/modules/neotree.lua index cfd149a..1276325 100644 --- a/lua/github-theme/group/modules/neotree.lua +++ b/lua/github-theme/group/modules/neotree.lua @@ -5,7 +5,10 @@ local C = require('github-theme.lib.color') local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param config GhTheme.Config.Options +---@param _opts table +function M.get(spec, config, _opts) local hide_eof = config.hide_end_of_buffer local dark_sb = config.darken.sidebars.enable local c = spec.palette @@ -15,6 +18,7 @@ function M.get(spec, config, opts) end -- stylua: ignore + ---@type table return { NeoTreeNormal = { link = 'NormalSB' }, NeoTreeNormalNC = { link = 'NeoTreeNormal' }, diff --git a/lua/github-theme/group/modules/notify.lua b/lua/github-theme/group/modules/notify.lua index 64e6dda..1d33e20 100644 --- a/lua/github-theme/group/modules/notify.lua +++ b/lua/github-theme/group/modules/notify.lua @@ -2,10 +2,14 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(spec, _config, _opts) local c = spec.palette -- stylua: ignore + ---@type table return { NotifyERRORTitle = { fg = c.red.base }, NotifyWARNTitle = { fg = c.yellow.base }, diff --git a/lua/github-theme/group/modules/nvimtree.lua b/lua/github-theme/group/modules/nvimtree.lua index 04279a8..a97347a 100644 --- a/lua/github-theme/group/modules/nvimtree.lua +++ b/lua/github-theme/group/modules/nvimtree.lua @@ -2,12 +2,16 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param config GhTheme.Config.Options +---@param _opts table +function M.get(spec, config, _opts) local hide_eof = config.hide_end_of_buffer local dark_sb = config.darken.sidebars.enable local c = spec.palette -- stylua: ignore + ---@type table return { NvimTreeNormal = { link = 'NormalSB' }, NvimTreeEndOfBuffer = { fg = (hide_eof and dark_sb) and spec.bg0 or spec.fg0 }, diff --git a/lua/github-theme/group/modules/telescope.lua b/lua/github-theme/group/modules/telescope.lua index 56e8c06..c36f2d9 100644 --- a/lua/github-theme/group/modules/telescope.lua +++ b/lua/github-theme/group/modules/telescope.lua @@ -2,8 +2,12 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(spec, _config, _opts) -- stylua: ignore + ---@type table return { TelescopeSelectionCaret = { fg = spec.palette.accent.fg }, TelescopeSelection = { link = 'CursorLine' }, diff --git a/lua/github-theme/group/modules/treesitter.lua b/lua/github-theme/group/modules/treesitter.lua index 75253e6..e176fb0 100644 --- a/lua/github-theme/group/modules/treesitter.lua +++ b/lua/github-theme/group/modules/treesitter.lua @@ -1,6 +1,9 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param config GhTheme.Config.Options +---@param _opts table +function M.get(spec, config, _opts) -- TODO: Consider refactoring this out once the primitives are finished -- being integrated. local primitives = require( @@ -48,6 +51,7 @@ If you want to stay on nvim 0.7, disable the module, or track on 'v0.0.x' branch end -- stylua: ignore + ---@type table return { -- Identifiers ------------------------------------------------------------- diff --git a/lua/github-theme/group/modules/treesitter_context.lua b/lua/github-theme/group/modules/treesitter_context.lua index 32a5544..6e9c795 100644 --- a/lua/github-theme/group/modules/treesitter_context.lua +++ b/lua/github-theme/group/modules/treesitter_context.lua @@ -1,7 +1,11 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(spec, _config, _opts) -- stylua: ignore + ---@type table return { ['TreesitterContext'] = { bg = spec.palette.accent.subtle }, } diff --git a/lua/github-theme/group/modules/whichkey.lua b/lua/github-theme/group/modules/whichkey.lua index a8d9543..51f6a60 100644 --- a/lua/github-theme/group/modules/whichkey.lua +++ b/lua/github-theme/group/modules/whichkey.lua @@ -2,16 +2,20 @@ local M = {} -function M.get(spec, config, opts) +---@param spec GhTheme.Spec +---@param _config GhTheme.Config.Options +---@param _opts table +function M.get(spec, _config, _opts) -- stylua: ignore + ---@type table return { WhichKey = { link = 'Identifier' }, - WhichKeyGroup = { link = 'Function' }, - WhichKeyDesc = { link = 'Keyword' }, - WhichKeySeperator = { link = 'Comment' }, - WhichKeySeparator = { link = 'Comment' }, - WhichKeyFloat = { bg = spec.bg0 }, - WhichKeyValue = { link = 'Comment' }, + WhichKeyGroup = { link = 'Function' }, + WhichKeyDesc = { link = 'Keyword' }, + WhichKeySeperator = { link = 'Comment' }, + WhichKeySeparator = { link = 'Comment' }, + WhichKeyFloat = { bg = spec.bg0 }, + WhichKeyValue = { link = 'Comment' }, } end diff --git a/lua/github-theme/init.lua b/lua/github-theme/init.lua index 9dcb3fc..9f68d93 100644 --- a/lua/github-theme/init.lua +++ b/lua/github-theme/init.lua @@ -27,7 +27,7 @@ function M.reset() end ---Compiles all themes/styles with their current settings. ----@param force boolean true by default +---@param force boolean don't check the saved hash, compile unconditionally (default true) ---@return nil function M.compile(force) local util = require('github-theme.util') @@ -87,8 +87,9 @@ function M.load(opts) require('github-theme.autocmds').set_autocmds() end ----Applies any new config or overrides then (re)compiles if needed. ----@param opts? table +---Applies any new config or overrides then (re)compiles if needed. Does not switch/load +---colorscheme. +---@param opts? GhTheme.Config function M.setup(opts) opts = opts or {} did_setup = true diff --git a/lua/github-theme/lib/highlight.lua b/lua/github-theme/lib/highlight.lua index 88180aa..bce940d 100644 --- a/lua/github-theme/lib/highlight.lua +++ b/lua/github-theme/lib/highlight.lua @@ -1,30 +1,11 @@ local util = require('github-theme.util') local fmt = string.format - local cmd = util.is_nvim and vim.cmd or vim.command - local M = {} ---#region TYPES - ----@class HighlightSpec ----@field fg string ----@field bg string ----@field style string ----@field sp string ----@field link string ----@field force boolean - ---#endregion - ----Validate input input from opts table and return a hex string if opt exists ----@param input string|GhTheme.Color|nil ----@return string -local function validate(input) - return input and input or 'NONE' -end - -local function parse_style(style) +---@param style string|nil +---@return table +function M.parse_style(style) if not style or style == 'NONE' then return {} end @@ -37,11 +18,6 @@ local function parse_style(style) return result end ----Validate input input from opts table and return a hex string if opt exists ----@param input string|GhTheme.Color|nil ----@return string -M.parse_style = parse_style - local function should_link(link) return link and link ~= '' end @@ -57,10 +33,10 @@ local function viml_hl(highlights) fmt( 'highlight %s guifg=%s guibg=%s gui=%s guisp=%s', group, - validate(opts.fg), - validate(opts.bg), - validate(opts.style), - validate(opts.sp) + opts.fg or 'NONE', + opts.bg or 'NONE', + opts.style or 'NONE', + opts.sp or 'NONE' ) ) end @@ -75,7 +51,7 @@ local function nvim_hl(highlights) link = opts.link, }) else - local values = parse_style(opts.style) + local values = M.parse_style(opts.style) values.bg = opts.bg values.fg = opts.fg values.sp = opts.sp