nvim: yolokai: Sync with upstream nvim-highlite

This commit is contained in:
Sanchayan Maity 2021-02-25 13:27:28 +05:30
parent abd22a73db
commit eff13b5225
2 changed files with 94 additions and 67 deletions

View file

@ -109,8 +109,6 @@ local highlight_groups = {
Ignore = {bg=NONE, fg=gray, style=NONE }, Ignore = {bg=NONE, fg=gray, style=NONE },
Error = {bg=black, fg=red, style=NONE }, Error = {bg=black, fg=red, style=NONE },
Todo = {bg=NONE, fg=orange, style={'bold', 'underline'}}, Todo = {bg=NONE, fg=orange, style={'bold', 'underline'}},
helpHyperTextJump = 'Underlined',
helpSpecial = 'Function' ,
Hint = {bg=lightblack3, fg=white, style='bold' }, Hint = {bg=lightblack3, fg=white, style='bold' },
Info = {bg=orange, fg=black, style='bold' }, Info = {bg=orange, fg=black, style='bold' },
Warning = {bg=pink, fg=black, style='bold' }, Warning = {bg=pink, fg=black, style='bold' },
@ -384,10 +382,21 @@ local highlight_groups = {
rubyInterpolationDelimiter = 'Delimiter', rubyInterpolationDelimiter = 'Delimiter',
--[[ 4.3.16. Rust ]] --[[ 4.3.16. Rust ]]
rustKeyword = 'Keyword' , rustAssert = 'Debug' ,
rustModPath = 'Include' , rustConstraint = 'Operator' ,
rustScopeDecl = 'Delimiter' , rustDynKeyword = 'rustStorage',
rustTrait = 'StorageClass', rustGeneric = 'Delimiter' ,
rustEscape = 'SpecialChar',
rustIdentifier = 'Identifier' ,
rustKeyword = 'Keyword' ,
rustLifetime = 'Label' ,
rustModPath = 'Include' ,
rustNoise = 'Delimiter' ,
rustPanic = 'Exception' ,
rustRepeat = 'Repeat' ,
rustScopeDecl = 'Delimiter' ,
rustStructure = 'Structure' ,
rustUnused = 'Special' ,
--[[ 4.3.17. Scala ]] --[[ 4.3.17. Scala ]]
scalaKeyword = 'Keyword' , scalaKeyword = 'Keyword' ,
@ -409,11 +418,12 @@ local highlight_groups = {
--[[ 4.3.20. TOML ]] --[[ 4.3.20. TOML ]]
tomlComment = 'Comment' , tomlComment = 'Comment' ,
tomlDate = 'Special' ,
tomlFloat = 'Float' ,
tomlKey = 'Label' , tomlKey = 'Label' ,
tomlTable = 'StorageClass', tomlTable = 'StorageClass',
--[[ 4.3.21. VimScript ]] --[[ 4.3.21. VimScript ]]
helpSpecial = 'Special' ,
vimFgBgAttrib = 'Constant' , vimFgBgAttrib = 'Constant' ,
vimHiCterm = 'Label' , vimHiCterm = 'Label' ,
vimHiCtermFgBg = 'vimHiCterm', vimHiCtermFgBg = 'vimHiCterm',
@ -456,7 +466,7 @@ local highlight_groups = {
luaFuncParens = 'Delimiter' , luaFuncParens = 'Delimiter' ,
luaFuncTable = 'Structure' , luaFuncTable = 'Structure' ,
luaLocal = 'Type' , luaLocal = 'Type' ,
luaNoise = 'Operator' , luaNoise = 'Delimiter' ,
luaParens = 'Delimiter' , luaParens = 'Delimiter' ,
luaSpecialTable = 'StorageClass', luaSpecialTable = 'StorageClass',
luaSpecialValue = 'Function' , luaSpecialValue = 'Function' ,
@ -479,7 +489,10 @@ local highlight_groups = {
crontabMnth = 'Structure' , crontabMnth = 'Structure' ,
--[[ 4.3.28. PlantUML ]] --[[ 4.3.28. PlantUML ]]
plantumlColonLine = {}, plantumlArrowLR = 'Statement',
plantumlColonLine = NONE ,
plantumlMindmap = 'Label' ,
plantumlMindmap2 = 'Label' ,
--[[ 4.3.33. YAML ]] --[[ 4.3.33. YAML ]]
yamlKey = 'Label', yamlKey = 'Label',
@ -487,18 +500,38 @@ local highlight_groups = {
yamlPlainScalar = { bg=black, fg=green, style=NONE }, yamlPlainScalar = { bg=black, fg=green, style=NONE },
--[[ 4.3.34. Git ]] --[[ 4.3.34. Git ]]
gitrebaseBreak = 'Keyword' , diffAdded = 'DiffAdd' ,
gitrebaseCommit = 'Tag' , diffRemoved = 'DiffDelete' ,
gitrebaseDrop = 'Exception' , gitcommitHeader = 'SpecialComment' ,
gitrebaseEdit = 'Define' , gitcommitDiscardedFile = 'gitcommitSelectedFile',
gitrebaseExec = 'PreProc' , gitcommitOverFlow = 'Error' ,
gitrebaseFixup = 'gitrebaseSquash', gitcommitSelectedFile = 'Directory' ,
gitrebaseMerge = 'PreProc' , gitcommitSummary = 'Title' ,
gitrebasePick = 'Include' , gitcommitUntrackedFile = 'gitcommitSelectedFile',
gitrebaseReset = 'gitrebaseLabel' , gitconfigAssignment = 'String' ,
gitrebaseReword = 'gitrebasePick' , gitconfigEscape = 'SpecialChar' ,
gitrebaseSquash = 'Macro' , gitconfigNone = 'Operator' ,
gitrebaseSummary = 'Normal' , gitconfigSection = 'Structure' ,
gitconfigVariable = 'Label' ,
gitrebaseBreak = 'Keyword' ,
gitrebaseCommit = 'Tag' ,
gitrebaseDrop = 'Exception' ,
gitrebaseEdit = 'Define' ,
gitrebaseExec = 'PreProc' ,
gitrebaseFixup = 'gitrebaseSquash' ,
gitrebaseMerge = 'PreProc' ,
gitrebasePick = 'Include' ,
gitrebaseReset = 'gitrebaseLabel' ,
gitrebaseReword = 'gitrebasePick' ,
gitrebaseSquash = 'Macro' ,
gitrebaseSummary = 'Normal' ,
--[[ 4.3.35 Help ]]
helpHeader = 'Label' ,
helpOption = 'Keyword' ,
helpHeadline = 'Title' ,
helpSectionDelim = 'Delimiter' ,
helpHyperTextJump = 'Underlined',
--[[ 4.4. Plugins --[[ 4.4. Plugins
Everything in this section is OPTIONAL. Feel free to remove everything Everything in this section is OPTIONAL. Feel free to remove everything

View file

@ -153,55 +153,49 @@ function yolokai.highlight(highlight_group, attributes) -- {{{ †
end --}}} ‡ end --}}} ‡
function yolokai:highlight_terminal(terminal_ansi_colors) function yolokai:highlight_terminal(terminal_ansi_colors)
for index, color in ipairs(terminal_ansi_colors) do for index, color in ipairs(terminal_ansi_colors) do vim.g['terminal_color_'..(index-1)] =
vim.g['terminal_color_'..index] = vim.o.termguicolors and color[_PALETTE_HEX] or color[_PALETTE_256] or get(color, _PALETTE_ANSI) vim.o.termguicolors and color[_PALETTE_HEX] or color[_PALETTE_256] or get(color, _PALETTE_ANSI)
end end
end end
return setmetatable(yolokai, { return setmetatable(yolokai, {['__call'] = function(self, normal, highlights, terminal_ansi_colors)
['__call'] = function(self, normal, highlights, terminal_ansi_colors) -- function to resolve function highlight groups being defined by function calls.
-- function to resolve function highlight groups being defined by function calls. local function resolve(tbl, key, resolve_links)
local function resolve(tbl, key, resolve_links) local value = tbl[key]
local value = tbl[key] local value_type = type(value)
local value_type = type(value) if value_type == 'function' then
if value_type == 'function' then -- lazily cache the result; next time, if it isn't a function this step will be skipped
-- lazily cache the result; next time, if it isn't a function this step will be skipped tbl[key] = value(setmetatable({}, {
tbl[key] = value(setmetatable({}, { ['__index'] = function(_, inner_key) return resolve(tbl, inner_key, true) end
['__index'] = function(_, inner_key) return resolve(tbl, inner_key, true) end }))
})) elseif value_type == _TYPE_STRING and not string.find(value, '^#') and resolve_links then
elseif value_type == _TYPE_STRING and not string.find(value, '^#') and resolve_links then return resolve(tbl, tbl[key], resolve_links)
return resolve(tbl, tbl[key], resolve_links)
end
return tbl[key]
end end
return tbl[key]
-- save the colors_name before syntax reset
local color_name = vim.g.colors_name
-- Clear the highlighting.
exe 'hi clear'
-- If the syntax has been enabled, reset it.
if fn.exists 'syntax_on' then exe 'syntax reset' end
-- replace the colors_name
vim.g.colors_name = color_name
color_name = nil
-- If we aren't using hex nor 256 colorsets.
if not (_USE_HEX or _USE_256) then vim.o.t_Co = '16' end
-- Highlight the baseline.
self.highlight('Normal', normal)
-- Highlight everything else.
for highlight_group, _ in pairs(highlights) do
self.highlight(highlight_group, resolve(highlights, highlight_group, false))
end
-- Set the terminal highlight colors.
self:highlight_terminal(terminal_ansi_colors)
end end
})
-- save the colors_name before syntax reset
local color_name = vim.g.colors_name
-- If the syntax has been enabled, reset it.
if fn.exists 'syntax_on' then exe 'syntax reset' end
-- replace the colors_name
vim.g.colors_name = color_name
color_name = nil
-- If we aren't using hex nor 256 colorsets.
if not (_USE_HEX or _USE_256) then vim.o.t_Co = '16' end
-- Highlight the baseline.
self.highlight('Normal', normal)
-- Highlight everything else.
for highlight_group, _ in pairs(highlights) do
self.highlight(highlight_group, resolve(highlights, highlight_group, false))
end
-- Set the terminal highlight colors.
self:highlight_terminal(terminal_ansi_colors)
end})