nvim: yolokai: Sync with upstream

Sync with upstream to use the new nvim_set_hl API. The white color was
actually wrong, so fix it.
This commit is contained in:
Sanchayan Maity 2022-04-21 11:37:16 +05:30
parent bc55909a12
commit 3e9ed93517
2 changed files with 155 additions and 221 deletions

View File

@ -17,7 +17,7 @@ lua << EOF
vim.g.colors_name = 'yolokai'
local white = { '#DOBFA1', 252, 'white' }
local white = { '#ffffff', 252, 'white' }
local white2 = { '#d8d8d3', 250, 'white2' }
local black = { '#000000', 234, 'black' }
local lightblack = { '#2D2E27', 235, 'lightblack' }
@ -40,144 +40,137 @@ local red = { '#e73c50', 196, 'red' }
local purered = { '#ff0000', 52, 'purered' }
local darkred = { '#5f0000', 52, 'darkred' }
--[[ DO NOT EDIT `BG`, `FG`, or `NONE`.
Feel free to uncomment `BG`. It is not used by default so it is commented out.
]]
local BG = 'bg'
local FG = 'fg'
local NONE = 'NONE'
--[[ These are the ones you should edit. ]]
-- This is the only highlight that must be defined separately.
local highlight_group_normal = {bg=black, fg=white, style=NONE}
local highlight_group_normal = {bg=black, fg=white}
-- This is where the rest of your highlights should go.
local highlight_groups = {
--[[ 4.1. Text Analysis ]]
Comment = {bg=NONE, fg=warmgrey, style='italic'},
EndOfBuffer = 'NonText',
NonText = {bg=NONE, fg=lightgrey, style=NONE },
Whitespace = 'NonText',
EndOfBuffer = 'NonText' ,
Whitespace = 'NonText' ,
Comment = { fg=warmgrey , style='italic' },
NonText = { fg=lightgrey },
--[[ 4.1.1. Literals]]
Constant = {bg=NONE, fg=purple, style=NONE},
String = {bg=NONE, fg=yellow, style=NONE},
Character = {bg=NONE, fg=yellow, style=NONE},
Number = {bg=NONE, fg=purple, style=NONE},
Boolean = {bg=NONE, fg=purple, style=NONE},
Float = 'Number',
Constant = { fg=purple },
String = { fg=yellow },
Character = { fg=yellow },
Number = { fg=purple },
Boolean = { fg=purple },
Float = 'Number' ,
--[[ 4.1.2. Identifiers]]
Identifier = {bg=NONE, fg=green, style=NONE},
Function = {bg=NONE, fg=darkgreen, style=NONE},
Identifier = { fg=green },
Function = { fg=darkgreen },
--[[ 4.1.3. Syntax]]
Statement = {bg=NONE, fg=pink, style=NONE },
Conditional = {bg=NONE, fg=pink, style='italic'},
Repeat = 'Keyword',
Label = {bg=NONE, fg=pink, style='italic'},
Operator = {bg=NONE, fg=pink, style=NONE },
Keyword = {bg=NONE, fg=pink, style='bold' },
Exception = {bg=NONE, fg=red, style='bold' },
Noise = 'Delimiter',
Statement = { fg=pink },
Conditional = { fg=pink, style='italic' },
Label = { fg=pink, style='italic' },
Operator = { fg=pink },
Keyword = { fg=pink, style='bold' },
Exception = { fg=red, style='bold' },
--[[ 4.1.4. Metatextual Information]]
PreProc = {bg=NONE, fg=green, style=NONE },
Include = {bg=NONE, fg=pink, style='nocombine'},
Define = {bg=NONE, fg=pink, style='nocombine'},
Macro = {bg=NONE, fg=orange, style={'bold', 'nocombine'}},
PreCondit = {bg=NONE, fg=green, style='nocombine'},
PreProc = { fg=green },
Include = { fg=pink, style='nocombine' },
Define = { fg=pink, style='nocombine' },
Macro = { fg=orange, style={'bold', 'nocombine' }},
PreCondit = { fg=green, style='nocombine' },
--[[ 4.1.5. Semantics]]
Type = {bg=NONE, fg=aqua, style=NONE },
StorageClass = {bg=NONE, fg=aqua, style='bold' },
Structure = {bg=NONE, fg=aqua, style='bold' },
Typedef = {bg=NONE, fg=aqua, style='italic'},
Type = { fg=aqua },
StorageClass = { fg=aqua, style='bold' },
Structure = { fg=aqua, style='bold' },
Typedef = { fg=aqua, style='italic' },
--[[ 4.1.6. Edge Cases]]
Special = {bg=NONE, fg=purple, style=NONE },
SpecialChar = 'Character' ,
SpecialKey = 'Character' ,
Tag = 'Underlined',
Delimiter = {bg=NONE, fg=red, style=NONE },
Special = { fg=purple },
Delimiter = { fg=red },
-- SpecialComment affects Haskell Language Extension
SpecialComment = {bg=NONE, fg=orange, style={'bold', 'nocombine'}},
SpecialComment = { fg=orange , style={'bold', 'nocombine'}},
Debug = 'WarningMsg',
--[[ 4.1.7. Help Syntax]]
Underlined = {bg=NONE, fg=green, style='underline' },
Ignore = {bg=NONE, fg=gray, style=NONE },
Error = {bg=black, fg=red, style=NONE },
Todo = {bg=NONE, fg=orange, style={'bold', 'underline'}},
Hint = {bg=black, fg=white, style='bold' },
Info = {bg=orange, fg=black, style='bold' },
Warning = {bg=pink, fg=black, style='bold' },
Ignore = { fg=gray },
Error = { bg=black , fg=red },
Underlined = { fg=green , style='underline' },
Todo = { fg=orange, style={'bold', 'underline' }},
Hint = { bg=black , fg=white, style='bold' },
Info = { bg=orange, fg=black, style='bold' },
Warning = { bg=pink , fg=black, style='bold' },
--[[ 4.2... Editor UI ]]
--[[ 4.2.1. Status Line]]
StatusLine = {bg=black, fg=warmgrey, style=NONE},
StatusLineNC = {bg=black, fg=darkgrey, style=NONE},
StatusLine = { bg=black, fg=warmgrey },
StatusLineNC = { bg=black, fg=darkgrey },
StatusLineTerm = 'StatusLine' ,
StatusLineTermNC = 'StatusLineNC',
--[[ 4.2.2. Separators]]
VertSplit = {bg=darkblack, fg=darkgrey, style=NONE },
TabLine = {bg=darkblack, fg=white, style=NONE },
TabLineFill = {bg=NONE, fg=FG, style=NONE },
TabLineSel = {bg=darkgrey, fg=FG, style='inverse'},
Title = {bg=NONE, fg=NONE, style='bold' },
VertSplit = { bg=darkblack, fg=darkgrey },
TabLine = { bg=darkblack, fg=white },
TabLineFill = { fg=white },
TabLineSel = { bg=darkgrey, fg=white, style='inverse' },
Title = { style='bold' },
--[[ 4.2.3. Conditional Line Highlighting]]
--Conceal={}
CursorLine = {bg=lightblack2, fg=NONE, style=NONE },
CursorLineNr = {bg=lightblack, fg=orange,style=NONE },
debugBreakpoint = 'ErrorMsg' ,
debugPC = 'ColorColumn',
LineNr = {bg=black, fg=grey, style=NONE },
QuickFixLine = {bg=darkgrey, fg=NONE, style=NONE },
Visual = {bg=NONE, fg=NONE, style='inverse'},
VisualNOS = {bg=darkgrey, fg=NONE, style=NONE },
CursorLine = { bg=lightblack2 },
CursorLineNr = { bg=lightblack, fg=orange },
LineNr = { bg=black, fg=grey },
QuickFixLine = { bg=darkgrey },
Visual = { style='inverse' },
VisualNOS = { bg=darkgrey },
--[[ 4.2.4. Popup Menu]]
Pmenu = {bg=black, fg=aqua, style=NONE },
PmenuSbar = {bg=black, fg=NONE, style=NONE },
PmenuSel = {bg=warmgrey, fg=white, style='bold' },
PmenuThumb = {bg=grey, fg=lightblack, style=NONE },
WildMenu = {bg=NONE, fg=NONE, style=NONE },
Pmenu = { bg=black, fg=aqua },
PmenuSbar = { bg=black },
PmenuSel = { bg=warmgrey, fg=white, style='bold' },
PmenuThumb = { bg=grey, fg=lightblack },
WildMenu = {},
--[[ 4.2.5. Folds]]
FoldColumn = {bg=darkblack, fg=NONE, style='bold' },
Folded = {bg=darkblack, fg=warmgrey, style='italic'},
FoldColumn = { bg=darkblack, style='bold' },
Folded = { bg=darkblack, fg=warmgrey, style='italic' },
--[[ 4.2.6. Diffs]]
DiffAdd = {bg=black, fg=darkgreen, style=NONE},
DiffChange = {bg=black, fg=yellow, style=NONE},
DiffDelete = {bg=black, fg=red, style=NONE},
DiffText = {bg=black, fg=NONE, style=NONE},
DiffAdd = { bg=black, fg=darkgreen },
DiffChange = { bg=black, fg=yellow },
DiffDelete = { bg=black, fg=red },
DiffText = { bg=black },
--[[ 4.2.7. Searching]]
IncSearch = {bg=NONE, fg=NONE, style='inverse' },
Search = {bg=yellow,fg=black, style={'underline', color=white}},
CurSearch = {bg=pink, fg=black, style={'underline', color=white}},
MatchParen = {bg=NONE, fg=orange, style={'bold', 'underline' }},
IncSearch = { style='inverse' },
Search = { bg=yellow,fg=black, style={'underline', color=white }},
CurSearch = { bg=pink, fg=black, style={'underline', color=white }},
MatchParen = { fg=orange, style={'bold', 'underline' }},
--[[ 4.2.8. Spelling]]
SpellBad = {bg=NONE, fg=NONE, style={'undercurl', color=red }},
SpellCap = {bg=NONE, fg=NONE, style={'undercurl', color=purple}},
SpellLocal = {bg=NONE, fg=NONE, style={'undercurl', color=pink }},
SpellRare = {bg=NONE, fg=NONE, style={'undercurl', color=aqua }},
SpellBad = { style={'undercurl', color=red }},
SpellCap = { style={'undercurl', color=purple }},
SpellLocal = { style={'undercurl', color=pink }},
SpellRare = { style={'undercurl', color=aqua }},
--[[ 4.2.9. Conditional Column Highlighting]]
ColorColumn = {bg=lightblack, fg=NONE, style=NONE },
SignColumn = {bg=black, fg=NONE, style=NONE },
ColorColumn = { bg=lightblack },
SignColumn = { bg=black },
--[[ 4.2.10. Messages]]
ErrorMsg = {bg=black, fg=red, style=NONE },
HintMsg = {bg=black, fg=purple, style='bold' },
InfoMsg = {bg=black, fg=orange, style='bold' },
ModeMsg = {bg=black, fg=yellow, style=NONE },
WarningMsg = {bg=black, fg=pink, style='bold' },
Question = {bg=black, fg=yellow, style='underline'},
ErrorMsg = { bg=black, fg=red },
HintMsg = { bg=black, fg=purple, style='bold' },
InfoMsg = { bg=black, fg=orange, style='bold' },
ModeMsg = { bg=black, fg=yellow },
WarningMsg = { bg=black, fg=pink, style='bold' },
Question = { bg=black, fg=yellow, style='underline' },
--[[ 4.2.11. Diagnostics ]]
DiagnosticError = 'ErrorMsg' ,
@ -206,14 +199,14 @@ local highlight_groups = {
DiagnosticVirtualTextHint = 'HintMsg' ,
--[[ 4.2.12. Cursor ]]
Cursor = {bg=white, fg=black, style='inverse'},
CursorIM = 'Cursor',
CursorColumn = {bg=lightblack2,fg=NONE, style=NONE },
CursorIM = 'Cursor',
Cursor = { bg=white, fg=black, style='inverse' },
CursorColumn = { bg=lightblack2 },
--[[ 4.2.13. Misc ]]
Directory = {bg=NONE, fg=aqua, style='bold'},
Terminal = 'Normal',
NormalFloat = {bg=black, fg=white, style=NONE },
Directory = { fg=aqua, style='bold' },
NormalFloat = { bg=black, fg=white },
--[[ 4.2.14. LSP Highlight ]]
LspReferenceText = 'InfoMsg',
@ -298,7 +291,7 @@ local highlight_groups = {
scssElse = 'scssIf',
scssMixinName = function(self)
local super = self.cssClassName
return {bg = super.bg, fg=super.fg, style='Italic'}
return {bg = super.bg, fg=super.fg, style='italic'}
end,
scssIf = 'PreCondit',
scssInclude = 'Include',
@ -324,7 +317,7 @@ local highlight_groups = {
goFormatSpecifier = 'Character' ,
goFunction = 'Function' ,
goFunctionCall = 'goFunction',
goFunctionReturn = {bg=NONE, fg=NONE, style=NONE},
goFunctionReturn = {},
goMethodCall = 'goFunctionCall',
goParamType = 'goReceiverType',
goPointerOperator = 'SpecialChar' ,
@ -340,7 +333,7 @@ local highlight_groups = {
--[[ 4.3.8. HTML ]]
htmlArg = 'Label',
htmlBold = {bg=NONE, fg=lightgrey, style='bold'},
htmlBold = { fg=lightgrey, style='bold' },
htmlTitle = 'htmlBold',
htmlEndTag = 'htmlTag',
htmlH1 = 'markdownH1',
@ -349,7 +342,7 @@ local highlight_groups = {
htmlH4 = 'markdownH4',
htmlH5 = 'markdownH5',
htmlH6 = 'markdownH6',
htmlItalic = {bg=NONE, fg=NONE, style='italic'},
htmlItalic = { style='italic' },
htmlSpecialTagName = 'Keyword',
htmlTag = 'Special',
htmlTagN = 'Typedef',
@ -377,12 +370,12 @@ local highlight_groups = {
makeSpecTarget = 'Type' ,
--[[ 4.3.13. Markdown ]]
markdownH1 = {bg=NONE, fg=green_dark, style='bold' },
markdownH2 = {bg=NONE, fg=red_light, style='bold' },
markdownH3 = {bg=NONE, fg=green, style='bold' },
markdownH4 = {bg=NONE, fg=purple, style='bold' },
markdownH5 = {bg=NONE, fg=orange, style='bold' },
markdownH6 = {bg=NONE, fg=yellow, style='bold' },
markdownH1 = { fg=green_dark, style='bold' },
markdownH2 = { fg=red_light, style='bold' },
markdownH3 = { fg=green, style='bold' },
markdownH4 = { fg=purple, style='bold' },
markdownH5 = { fg=orange, style='bold' },
markdownH6 = { fg=yellow, style='bold' },
mkdBold = 'SpecialComment' ,
mkdCode = 'Keyword' ,
mkdCodeDelimiter = 'mkdBold' ,
@ -537,14 +530,14 @@ local highlight_groups = {
--[[ 4.3.28. PlantUML ]]
plantumlArrowLR = 'Statement',
plantumlColonLine = NONE ,
plantumlColonLine = {} ,
plantumlMindmap = 'Label' ,
plantumlMindmap2 = 'Label' ,
--[[ 4.3.33. YAML ]]
yamlKey = 'Label',
yamlBlockMappingKey = { bg=black, fg=red, style=NONE },
yamlPlainScalar = { bg=black, fg=green, style=NONE },
yamlBlockMappingKey = { bg=black, fg=red },
yamlPlainScalar = { bg=black, fg=green },
--[[ 4.3.34. Git ]]
diffAdded = 'DiffAdd' ,
@ -602,10 +595,10 @@ local highlight_groups = {
htmlH6 = 'markdownH6',
--[[ 4.4.4. vim-gitgutter / vim-signify ]]
GitGutterAdd = {bg=NONE, fg=green, style=NONE},
GitGutterChange = {bg=NONE, fg=yellow, style=NONE},
GitGutterDelete = {bg=NONE, fg=red, style=NONE},
GitGutterChangeDelete = {bg=NONE, fg=orange, style=NONE},
GitGutterAdd = { fg=green },
GitGutterChange = { fg=yellow },
GitGutterDelete = { fg=red },
GitGutterChangeDelete = { fg=orange },
SignifySignAdd = 'GitGutterAdd' ,
SignifySignChange = 'GitGutterChange' ,
@ -613,8 +606,8 @@ local highlight_groups = {
SignifySignChangeDelete = 'GitGutterChangeDelete',
--[[ 4.4.5. vim-indent-guides ]]
IndentGuidesOdd = {bg=darkgrey, fg=NONE, style=NONE},
IndentGuidesEven = {bg=grey, fg=NONE, style=NONE},
IndentGuidesOdd = { bg=darkgrey },
IndentGuidesEven = { bg=grey },
--[[ 4.4.7. NERDTree ]]
NERDTreeCWD = 'Label' ,
@ -677,25 +670,25 @@ local highlight_groups = {
TSVariableBuiltin = 'Identifier',
--[[ 4.4.9 SearchLight ]]
SearchLight = {bg=black, fg=orange, style={'bold', 'italic', 'underline'}},
SearchLight = { bg=black, fg=orange, style={'bold', 'italic', 'underline' }},
--[[ 4.4.10 Sneak ]]
Sneak = {bg=red, fg=black, style='bold' },
SneakScope = {bg=black, fg=orange, style={'bold', 'underline'}},
Sneak = { bg=red, fg=black, style='bold' },
SneakScope = { bg=black, fg=orange, style={'bold', 'underline' }},
--[[ 4.4.11 Which key ]]
WhichKey = 'Function' ,
WhichKeySeperator = {bg=black, fg=green, style=NONE },
WhichKeySeperator = {bg=black, fg=green},
WhichKeyGroup = 'Keyword' ,
WhichKeyDesc = {bg=black, fg=orange, style=NONE },
WhichKeyDesc = {bg=black, fg=orange},
WhichKeyFloating = 'Pmenu' ,
--[[ 4.4.12 conflict-marker ]]
ConflictMarkerBegin = {bg=black, fg=purple, style=NONE },
ConflictMarkerEnd = {bg=black, fg=purple, style=NONE },
ConflictMarkerOurs = {bg=black, fg=green, style=NONE },
ConflictMarkerTheirs = {bg=black, fg=red, style=NONE },
ConflictMarkerCommonAncestorsHunk = {bg=black, fg=orange, style=NONE },
ConflictMarkerBegin = { bg=black, fg=purple },
ConflictMarkerEnd = { bg=black, fg=purple },
ConflictMarkerOurs = { bg=black, fg=green },
ConflictMarkerTheirs = { bg=black, fg=red },
ConflictMarkerCommonAncestorsHunk = { bg=black, fg=orange },
--[[ 4.4.13 hlslens ]]
HlSearchLensCur = 'SearchLight',
@ -703,13 +696,13 @@ local highlight_groups = {
HlSearchCur = 'SearchLight',
--[[ 4.4.14 pandoc ]]
pandocAtxHeader = { bg=black, fg=aqua, style=NONE },
pandocAtxStart = { bg=black, fg=orange, style=NONE },
pandocDelimitedCodeBlockStart = { bg=black, fg=green, style=NONE },
pandocDelimitedCodeBlockEnd = { bg=black, fg=green, style=NONE },
pandocAtxHeader = { bg=black, fg=aqua },
pandocAtxStart = { bg=black, fg=orange },
pandocDelimitedCodeBlockStart = { bg=black, fg=green },
pandocDelimitedCodeBlockEnd = { bg=black, fg=green },
pandocDelimitedCodeBlockLanguage = 'Comment',
pandocListItemBullet = { bg=black, fg=purple, style=NONE },
pandocUListItemBullet = { bg=black, fg=purple, style=NONE },
pandocListItemBullet = { bg=black, fg=purple },
pandocUListItemBullet = { bg=black, fg=purple },
pandocReferenceURL = { bg=black, fg=pink, style={'underline' }},
pandocReferenceDefinition = { bg=black, fg=aqua, style={'bold' }},
pandocEmphasis = { bg=black, fg=purple, style={'italic' }},
@ -718,45 +711,12 @@ local highlight_groups = {
pandocStrongInEmphasis = 'pandocStrongEmphasis',
pandocEmphasisInStrong = 'pandocStrongEmphasis',
--[[ 4.4.15 nvim-cmp ]]
CmpItemMenu = {bg=black, fg=NONE, style=NONE },
CmpItemAbbr = {bg=black, fg=aqua, style=NONE },
CmpItemAbbrMatch = {bg=black, fg=red, style='underline' },
CmpItemAbbrMatchFuzzy = {bg=black, fg=aqua, style='bold' },
CmpItemAbbrDeprecated = {bg=black, fg=purple, style=NONE },
CmpItemKind = {bg=black, fg=orange, style=NONE },
CmpItemKindText = 'String',
CmpItemKindMethod = 'CmpItemKindFunction',
CmpItemKindFunction = 'Function',
CmpItemKindConstructor = 'CmpItemKindMethod',
CmpItemKindField = 'Identifier',
CmpItemKindVariable = 'Identifier',
CmpItemKindClass = 'CmpItemKindStruct',
CmpItemKindInterface = 'Type',
CmpItemKindModule = 'Include',
CmpItemKindProperty = 'CmpItemKindField',
CmpItemKindUnit = 'CmpItemKindStruct',
CmpItemKindValue = 'CmpItemKindConstant',
CmpItemKindEnum = 'CmpItemKindStruct',
CmpItemKindKeyword = 'Keyword',
CmpItemKindSnippet = 'Special',
CmpItemKindColor = 'Label',
CmpItemKindFile = 'Directory',
CmpItemKindReference = 'StorageClass',
CmpItemKindFolder = 'CmpItemKindFile',
CmpItemKindEnumMember = 'CmpItemKindConstant',
CmpItemKindConstant = 'Constant',
CmpItemKindStruct = 'Structure',
CmpItemKindEvent = 'Repeat',
CmpItemKindOperator = 'Operator',
CmpItemKindTypeParameter = 'Typedef',
--[[ 4.4.16 Hop ]]
HopNextKey = {bg=red , fg=black , style='bold'},
HopNextKey1 = {bg=black, fg=orange , style='bold'},
HopNextKey2 = {bg=black, fg=purple , style='bold'},
HopUnmatched = {bg=black, fg=lightgrey, style='bold'},
HopCursor = {bg=black, fg=aqua , style='bold'},
--[[ 4.4.15 Hop ]]
HopNextKey = { bg=red , fg=black , style='bold' },
HopNextKey1 = { bg=black, fg=orange , style='bold' },
HopNextKey2 = { bg=black, fg=purple , style='bold' },
HopUnmatched = { bg=black, fg=lightgrey, style='bold' },
HopCursor = { bg=black, fg=aqua , style='bold' },
}
-- We do not care about terminals which do not support 256 colors

View File

@ -16,9 +16,6 @@
--- Which set of colors to use.
local _USE_256 = tonumber(vim.go.t_Co) > 255 or string.find(vim.env.TERM, '256')
--- Indicating nothing for a highlight field.
local _NONE = 'NONE'
--- Which index to use for `cterm` highlights.
local _PALETTE_CTERM = _USE_256 and 2 or 3
@ -42,36 +39,8 @@ local function get(color, index) -- {{{ †
elseif type(color) == _TYPE_STRING then
return color
end
return _NONE
end --}}} ‡
--- Take a `command` and add color-specifying components to it.
--- @param command table the in-progress `:highlight` command
--- @param definition Yolokai.Definition the definition of the highlight group
local function colorize(command, definition) -- {{{ †
command[#command+1]=' guibg='..get(definition.bg, _PALETTE_HEX)..' guifg='..get(definition.fg, _PALETTE_HEX)
..' ctermbg='..get(definition.bg, _PALETTE_CTERM)..' ctermfg='..get(definition.fg, _PALETTE_CTERM)
-- Add the `blend` parameter if it is present
if definition.blend then -- There is a value for the `highlight-blend` field.
command[#command+1]=' blend='..definition.blend
end
end --}}} ‡
--- This function appends `selected_definition` to the end of `highlight_cmd`.
--- @param command table the in-progress `:highlight` command
--- @param style string the `gui`/`cterm` arguments to apply
--- @param color string|table a `guisp` argument; same arg as `get`
--- @see get
local function stylize(command, style, color)
command[#command+1]=' gui='..style..' cterm='..style
if color then -- There is an undercurl color.
command[#command+1]=' guisp='..get(color, _PALETTE_HEX)
end
end
--- @param rgb string some string of RGB colors.
--- @return string hex
local function tohex(rgb) return string.format('#%06x', rgb) end
@ -108,10 +77,10 @@ function yolokai.group(name)
return
{
fg = definition.foreground and tohex(definition.foreground) or _NONE,
bg = definition.background and tohex(definition.background) or _NONE,
fg = definition.foreground and tohex(definition.foreground),
bg = definition.background and tohex(definition.background),
blend = definition.blend,
style = style or _NONE
style = style,
}
end
@ -121,31 +90,36 @@ end
--- @param group_name string the `{group-name}` argument for `:highlight`
--- @param definition Yolokai.Definition|string a link or an attribute map
function yolokai.highlight(group_name, definition) -- {{{ †
local highlight = {}
if type(definition) == _TYPE_STRING then -- `highlight_group` is a link to another group.
vim.api.nvim_command('hi! link '..group_name..' '..definition)
return
highlight.link = definition
else
-- Take care of special instructions for certain background colors.
if definition[vim.go.background] then
definition = use_background_with(definition)
end
highlight.bg = get(definition.bg, _PALETTE_HEX)
highlight.fg = get(definition.fg, _PALETTE_HEX)
highlight.ctermbg = get(definition.bg, _PALETTE_CTERM)
highlight.ctermfg = get(definition.fg, _PALETTE_CTERM)
highlight.blend = definition.blend
local style = definition.style
if type(style) == _TYPE_TABLE then
for _, option in ipairs(style) do highlight[option] = true end
highlight.special = get(style.color, _PALETTE_HEX)
elseif style then
highlight[style] = true
end
highlight.reverse = highlight.inverse
highlight.inverse = nil
end
-- The base highlight command
local highlight_cmd = {'hi! ', group_name}
-- Take care of special instructions for certain background colors.
if definition[vim.go.background] then
definition = use_background_with(definition)
end
colorize(highlight_cmd, definition)
local style = definition.style or _NONE
if type(style) == _TYPE_TABLE then
-- Concat all of the entries together with a comma between before styling.
stylize(highlight_cmd, table.concat(style, ','), style.color)
else -- The style is just a single entry.
stylize(highlight_cmd, style)
end
vim.api.nvim_command(table.concat(highlight_cmd))
vim.api.nvim_set_hl(0, group_name, highlight)
end --}}} ‡
--- Set `g:terminal_color_`s based on `terminal_colors`.