Something went wrong. Try again.
fork of https://github.com/xzlee3/nvim-github-theme
Something went wrong. Try again.
16 kB · 326 lines
Lua
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327local M = {}
local function link(group) return { link = group }end
local function apply_style(spec, style) if not style then return spec end
local merged = vim.tbl_extend("force", {}, spec)
for key, value in pairs(style) do merged[key] = value end
return mergedend
function M.build(palette, opts) local p = palette local sign_bg = opts.transparent and "NONE" or p.bg local virtual_text_bg = opts.transparent and "NONE" or p.bg_sidebar local end_of_buffer = p.bg ~= "NONE" and p.bg or p.fg_subtle
return { Normal = { fg = p.fg, bg = p.bg }, NormalNC = { fg = p.fg, bg = p.bg }, NormalFloat = { fg = p.fg, bg = p.bg_float }, FloatBorder = { fg = p.border_float or p.border, bg = p.bg_float }, FloatTitle = { fg = p.accent, bg = p.bg_float, bold = true }, ColorColumn = { bg = p.bg_cursorline }, Conceal = { fg = p.fg_muted }, Cursor = { fg = p.bg == "NONE" and p.fg or p.bg, bg = p.cursor }, lCursor = { fg = p.bg == "NONE" and p.fg or p.bg, bg = p.cursor }, CursorIM = { fg = p.bg == "NONE" and p.fg or p.bg, bg = p.cursor }, CursorColumn = { bg = p.bg_cursorline }, CursorLine = { bg = p.bg_cursorline }, CursorLineNr = { fg = p.line_nr_active, bg = p.bg_cursorline, bold = true }, Directory = { fg = p.accent }, EndOfBuffer = { fg = end_of_buffer, bg = sign_bg }, ErrorMsg = { fg = p.error, bold = true }, WarningMsg = { fg = p.warning }, MoreMsg = { fg = p.info }, ModeMsg = { fg = p.accent, bold = true }, Folded = { fg = p.fg_muted, bg = p.bg_sidebar }, FoldColumn = { fg = p.line_nr, bg = sign_bg }, SignColumn = { fg = p.line_nr, bg = sign_bg }, IncSearch = { fg = p.fg, bg = p.bg_incsearch, bold = true }, Search = { fg = p.fg, bg = p.bg_search }, CurSearch = { fg = p.fg, bg = p.bg_search, bold = true }, LineNr = { fg = p.line_nr, bg = sign_bg }, MatchParen = { bg = p.match_paren_bg, bold = true }, NonText = { fg = p.whitespace, bg = sign_bg }, SpecialKey = { fg = p.whitespace }, StatusLine = { fg = p.fg, bg = p.bg_statusline }, StatusLineNC = { fg = p.fg_muted, bg = p.bg_statusline }, TabLine = { fg = p.fg_muted, bg = p.bg_sidebar }, TabLineFill = { bg = p.bg_sidebar }, TabLineSel = { fg = p.fg, bg = p.bg, bold = true }, Title = { fg = p.accent, bold = true }, VertSplit = { fg = p.border }, WinSeparator = { fg = p.border }, Visual = { fg = p.selection_fg, bg = p.bg_visual }, VisualNOS = { fg = p.selection_fg, bg = p.bg_visual }, Whitespace = { fg = p.whitespace }, WildMenu = { fg = p.fg, bg = p.bg_menu_sel, bold = true }, WinBar = { fg = p.fg, bg = p.bg }, WinBarNC = { fg = p.fg_muted, bg = p.bg }, Pmenu = { fg = p.fg, bg = p.bg_menu }, PmenuSel = { fg = p.fg, bg = p.bg_menu_sel, bold = true }, PmenuSbar = { bg = p.bg_sidebar }, PmenuThumb = { bg = p.whitespace }, Question = { fg = p.info }, QuickFixLine = { bg = p.bg_menu_sel, bold = true }, SpellBad = { sp = p.error, undercurl = true }, SpellCap = { sp = p.info, undercurl = true }, SpellLocal = { sp = p.hint, undercurl = true }, SpellRare = { sp = p.warning, undercurl = true },
Comment = apply_style({ fg = p.comment }, opts.styles.comments), Constant = { fg = p.constant }, String = { fg = p.string }, Character = { fg = p.character or p.string }, Number = { fg = p.constant }, Boolean = { fg = p.constant }, Float = { fg = p.constant }, Identifier = { fg = p.variable_other }, Function = apply_style({ fg = p.func }, opts.styles.functions), Statement = apply_style({ fg = p.keyword }, opts.styles.keywords), Conditional = link("Statement"), Repeat = link("Statement"), Label = { fg = p.accent }, Operator = { fg = p.keyword }, Keyword = apply_style({ fg = p.keyword }, opts.styles.keywords), Exception = link("Statement"), PreProc = { fg = p.keyword }, Include = { fg = p.keyword }, Define = { fg = p.keyword }, Macro = { fg = p.support }, PreCondit = { fg = p.keyword }, Type = apply_style({ fg = p.type }, opts.styles.types), StorageClass = link("Type"), Structure = link("Type"), Typedef = link("Type"), Special = { fg = p.support }, SpecialChar = { fg = p.character or p.string }, Tag = { fg = p.tag }, Delimiter = { fg = p.fg_muted }, SpecialComment = link("Comment"), Debug = { fg = p.warning }, Underlined = { fg = p.link, underline = true }, Ignore = { fg = p.fg_subtle }, Error = { fg = p.error, bold = true }, Todo = { fg = p.accent, bold = true },
DiagnosticError = { fg = p.error }, DiagnosticWarn = { fg = p.warning }, DiagnosticInfo = { fg = p.info }, DiagnosticHint = { fg = p.hint }, DiagnosticOk = { fg = p.git_add }, DiagnosticSignError = { fg = p.error, bg = sign_bg }, DiagnosticSignWarn = { fg = p.warning, bg = sign_bg }, DiagnosticSignInfo = { fg = p.info, bg = sign_bg }, DiagnosticSignHint = { fg = p.hint, bg = sign_bg }, DiagnosticSignOk = { fg = p.git_add, bg = sign_bg }, DiagnosticVirtualTextError = { fg = p.error, bg = virtual_text_bg }, DiagnosticVirtualTextWarn = { fg = p.warning, bg = virtual_text_bg }, DiagnosticVirtualTextInfo = { fg = p.info, bg = virtual_text_bg }, DiagnosticVirtualTextHint = { fg = p.hint, bg = virtual_text_bg }, DiagnosticVirtualTextOk = { fg = p.git_add, bg = virtual_text_bg }, DiagnosticFloatingError = { fg = p.error }, DiagnosticFloatingWarn = { fg = p.warning }, DiagnosticFloatingInfo = { fg = p.info }, DiagnosticFloatingHint = { fg = p.hint }, DiagnosticFloatingOk = { fg = p.git_add }, DiagnosticUnderlineError = { sp = p.error, undercurl = true }, DiagnosticUnderlineWarn = { sp = p.warning, undercurl = true }, DiagnosticUnderlineInfo = { sp = p.info, undercurl = true }, DiagnosticUnderlineHint = { sp = p.hint, undercurl = true }, DiagnosticUnderlineOk = { sp = p.git_add, undercurl = true }, DiagnosticDeprecated = { fg = p.fg_muted, strikethrough = true }, DiagnosticUnnecessary = { fg = p.fg_muted, italic = true },
DiffAdd = { fg = p.diff_add, bg = p.diff_add_bg }, DiffDelete = { fg = p.diff_delete, bg = p.diff_delete_bg }, DiffChange = { fg = p.diff_change, bg = p.diff_change_bg or p.bg_visual }, DiffText = { fg = p.accent, bg = p.bg_visual, bold = true }, Added = { fg = p.git_add }, Changed = { fg = p.git_change }, Removed = { fg = p.git_delete }, GitSignsAdd = { fg = p.git_add, bg = sign_bg }, GitSignsChange = { fg = p.git_change, bg = sign_bg }, GitSignsDelete = { fg = p.git_delete, bg = sign_bg }, GitSignsAddNr = { fg = p.git_add, bg = sign_bg }, GitSignsChangeNr = { fg = p.git_change, bg = sign_bg }, GitSignsDeleteNr = { fg = p.git_delete, bg = sign_bg }, GitSignsAddLn = { bg = p.diff_add_bg }, GitSignsChangeLn = { bg = p.diff_change_bg or p.bg_visual }, GitSignsDeleteLn = { bg = p.diff_delete_bg },
["@comment"] = link("Comment"), ["@comment.documentation"] = link("Comment"), ["@comment.note"] = { fg = p.info, bold = true }, ["@comment.todo"] = link("Todo"), ["@comment.warning"] = { fg = p.warning, bold = true }, ["@constant"] = link("Constant"), ["@constant.builtin"] = { fg = p.constant }, ["@constant.macro"] = { fg = p.constant }, ["@string"] = link("String"), ["@string.documentation"] = link("String"), ["@string.escape"] = { fg = p.character or p.string, bold = true }, ["@string.regex"] = { fg = p.regexp }, ["@string.special"] = { fg = p.character or p.string }, ["@character"] = link("Character"), ["@character.special"] = { fg = p.character or p.string }, ["@number"] = link("Number"), ["@boolean"] = link("Boolean"), ["@float"] = link("Float"), ["@function"] = link("Function"), ["@function.builtin"] = { fg = p.func }, ["@function.call"] = link("Function"), ["@function.macro"] = { fg = p.support }, ["@function.method"] = link("Function"), ["@function.method.call"] = link("Function"), ["@constructor"] = apply_style({ fg = p.type }, opts.styles.types), ["@parameter"] = { fg = p.variable }, ["@parameter.reference"] = { fg = p.variable }, ["@field"] = { fg = p.property }, ["@property"] = { fg = p.property }, ["@variable"] = { fg = p.variable_other }, ["@variable.builtin"] = { fg = p.constant }, ["@variable.member"] = { fg = p.property }, ["@variable.parameter"] = { fg = p.variable }, ["@type"] = apply_style({ fg = p.type }, opts.styles.types), ["@type.builtin"] = { fg = p.support }, ["@type.definition"] = apply_style({ fg = p.type }, opts.styles.types), ["@module"] = { fg = p.type }, ["@module.builtin"] = { fg = p.support }, ["@namespace"] = { fg = p.type }, ["@keyword"] = apply_style({ fg = p.keyword }, opts.styles.keywords), ["@keyword.conditional"] = apply_style({ fg = p.keyword }, opts.styles.keywords), ["@keyword.directive"] = { fg = p.keyword }, ["@keyword.directive.define"] = { fg = p.keyword }, ["@keyword.exception"] = apply_style({ fg = p.keyword }, opts.styles.keywords), ["@keyword.function"] = apply_style({ fg = p.keyword }, opts.styles.keywords), ["@keyword.import"] = apply_style({ fg = p.keyword }, opts.styles.keywords), ["@keyword.operator"] = { fg = p.keyword }, ["@keyword.repeat"] = apply_style({ fg = p.keyword }, opts.styles.keywords), ["@keyword.return"] = apply_style({ fg = p.keyword }, opts.styles.keywords), ["@keyword.storage"] = apply_style({ fg = p.keyword }, opts.styles.keywords), ["@label"] = { fg = p.accent }, ["@operator"] = { fg = p.keyword }, ["@punctuation.bracket"] = { fg = p.fg_muted }, ["@punctuation.delimiter"] = { fg = p.fg_muted }, ["@punctuation.special"] = { fg = p.punctuation_special }, ["@tag"] = { fg = p.tag }, ["@tag.attribute"] = { fg = p.property }, ["@tag.delimiter"] = { fg = p.fg_muted }, ["@attribute"] = { fg = p.support }, ["@attribute.builtin"] = { fg = p.support }, ["@markup.heading"] = { fg = p.heading, bold = true }, ["@markup.heading.1"] = { fg = p.heading, bold = true }, ["@markup.heading.2"] = { fg = p.heading, bold = true }, ["@markup.heading.3"] = { fg = p.heading, bold = true }, ["@markup.heading.4"] = { fg = p.heading, bold = true }, ["@markup.heading.5"] = { fg = p.heading, bold = true }, ["@markup.heading.6"] = { fg = p.heading, bold = true }, ["@markup.italic"] = { italic = true }, ["@markup.bold"] = { bold = true }, ["@markup.underline"] = { underline = true }, ["@markup.strikethrough"] = { strikethrough = true }, ["@markup.quote"] = { fg = p.quote }, ["@markup.raw"] = { fg = p.inline_raw }, ["@markup.link"] = { fg = p.link, underline = true }, ["@markup.link.label"] = { fg = p.link, underline = true }, ["@markup.link.url"] = { fg = p.link, underline = true }, ["@markup.list"] = { fg = p.type }, ["@markup.list.checked"] = { fg = p.git_add }, ["@markup.list.unchecked"] = { fg = p.fg_muted }, markdownH1 = { fg = p.heading, bold = true }, markdownH2 = { fg = p.heading, bold = true }, markdownH3 = { fg = p.heading, bold = true }, markdownH4 = { fg = p.heading, bold = true }, markdownH5 = { fg = p.heading, bold = true }, markdownH6 = { fg = p.heading, bold = true }, markdownBlockquote = { fg = p.quote }, markdownListMarker = { fg = p.type }, markdownOrderedListMarker = { fg = p.type }, markdownLinkText = { fg = p.link, underline = true }, markdownUrl = { fg = p.link, underline = true }, markdownCode = { fg = p.inline_raw }, markdownCodeBlock = { fg = p.inline_raw }, markdownCodeDelimiter = { fg = p.inline_raw },
-- Legacy typescript.vim links many groups to broad defaults that do not match GitHub's TS token intent. typescriptBraces = { fg = p.fg_muted }, typescriptParens = { fg = p.fg_muted }, typescriptEndColons = { fg = p.fg_muted }, typescriptTypeBrackets = { fg = p.fg_muted }, typescriptDotNotation = { fg = p.fg_muted }, typescriptTypeAnnotation = { fg = p.fg_muted }, typescriptFuncComma = { fg = p.fg_muted }, typescriptVariable = apply_style({ fg = p.keyword }, opts.styles.keywords), typescriptUsing = apply_style({ fg = p.keyword }, opts.styles.keywords), typescriptEnumKeyword = apply_style({ fg = p.keyword }, opts.styles.keywords), typescriptOperator = { fg = p.keyword }, typescriptKeywordOp = { fg = p.keyword }, typescriptAssign = { fg = p.keyword }, typescriptMember = { fg = p.property }, typescriptObjectLabel = { fg = p.property }, typescriptMethodAccessor = { fg = p.keyword }, typescriptGlobal = { fg = p.support }, typescriptDOMFormProp = { fg = p.property }, typescriptBOMWindowProp = { fg = p.variable_other }, typescriptVariableDeclaration = { fg = p.variable_other }, typescriptDestructureVariable = { fg = p.variable_other }, typescriptDefaultImportName = { fg = p.variable_other }, typescriptCall = { fg = p.variable }, typescriptParamImpl = { fg = p.variable }, typescriptFuncCallArg = { fg = p.variable }, typescriptArrowFuncArg = { fg = p.variable }, typescriptClassName = apply_style({ fg = p.type }, opts.styles.types), typescriptInterfaceName = apply_style({ fg = p.type }, opts.styles.types), typescriptAliasDeclaration = apply_style({ fg = p.type }, opts.styles.types), typescriptTypeReference = apply_style({ fg = p.type }, opts.styles.types), typescriptTypeParameter = apply_style({ fg = p.type }, opts.styles.types), ["@diff.plus"] = { fg = p.diff_add }, ["@diff.minus"] = { fg = p.diff_delete }, ["@diff.delta"] = { fg = p.diff_change },
["@lsp.type.class"] = apply_style({ fg = p.type }, opts.styles.types), ["@lsp.type.comment"] = apply_style({ fg = p.comment }, opts.styles.comments), ["@lsp.type.decorator"] = { fg = p.support }, ["@lsp.type.enum"] = apply_style({ fg = p.type }, opts.styles.types), ["@lsp.type.enumMember"] = { fg = p.constant }, ["@lsp.type.event"] = { fg = p.type }, ["@lsp.type.function"] = apply_style({ fg = p.func }, opts.styles.functions), ["@lsp.type.interface"] = apply_style({ fg = p.type }, opts.styles.types), ["@lsp.type.keyword"] = apply_style({ fg = p.keyword }, opts.styles.keywords), ["@lsp.type.macro"] = { fg = p.support }, ["@lsp.type.method"] = apply_style({ fg = p.func }, opts.styles.functions), ["@lsp.type.modifier"] = { fg = p.keyword }, ["@lsp.type.namespace"] = { fg = p.type }, ["@lsp.type.number"] = { fg = p.constant }, ["@lsp.type.operator"] = { fg = p.keyword }, ["@lsp.type.parameter"] = { fg = p.variable }, ["@lsp.type.property"] = { fg = p.property }, ["@lsp.type.string"] = { fg = p.string }, ["@lsp.type.struct"] = apply_style({ fg = p.type }, opts.styles.types), ["@lsp.type.type"] = apply_style({ fg = p.type }, opts.styles.types), ["@lsp.type.typeParameter"] = apply_style({ fg = p.type }, opts.styles.types), ["@lsp.type.variable"] = { fg = p.variable_other }, ["@lsp.typemod.class.defaultLibrary"] = { fg = p.type }, ["@lsp.typemod.function.defaultLibrary"] = apply_style({ fg = p.func }, opts.styles.functions), ["@lsp.typemod.keyword.documentation"] = apply_style({ fg = p.keyword }, opts.styles.keywords), ["@lsp.typemod.operator.injected"] = { fg = p.keyword }, ["@lsp.typemod.property.declaration"] = { fg = p.property }, ["@lsp.typemod.variable.defaultLibrary"] = { fg = p.constant }, ["@lsp.typemod.variable.global"] = { fg = p.constant }, ["@lsp.mod.deprecated"] = { strikethrough = true }, }end
return M