nvim: yolokai: Sync with nvim-highlite upstream

This commit is contained in:
Sanchayan Maity 2021-06-13 15:32:00 +05:30
parent 0eb9b86927
commit 3d8ccb4f23
2 changed files with 103 additions and 71 deletions

View file

@ -229,43 +229,78 @@ local highlight_groups = {
cppSTLnamespace = 'String' ,
--[[ 4.3.3 C# ]]
csBraces = 'Delimiter' ,
csClass = 'Structure' ,
csClassType = 'Type' ,
csContextualStatement = 'Conditional' ,
csEndColon = 'Delimiter' ,
csGeneric = 'Typedef' ,
csInterpolation = 'Include' ,
csInterpolationDelimiter = 'SpecialChar' ,
csLogicSymbols = 'Operator' ,
csModifier = 'Keyword' ,
csNew = 'Operator' ,
csNewType = 'Type' ,
csParens = 'Delimiter' ,
csPreCondit = 'PreProc' ,
csRepeat = 'Repeat' ,
csStorage = 'StorageClass',
csUnspecifiedStatement = 'Statement' ,
csXmlTag = 'Define' ,
csXmlTagName = 'Define' ,
csBraces = 'Delimiter',
csClass = 'Structure',
csClassType = 'Type',
csContextualStatement = 'Conditional',
csEndColon = 'Delimiter',
csGeneric = 'Typedef',
csInterpolation = 'Include',
csInterpolationDelimiter = 'SpecialChar',
csLogicSymbols = 'Operator',
csModifier = 'Keyword',
csNew = 'Operator',
csNewType = 'Type',
csParens = 'Delimiter',
csPreCondit = 'PreProc',
csQuote = 'Delimiter',
csRepeat = 'Repeat',
csStorage = 'StorageClass',
csUnspecifiedStatement = 'Statement',
csXmlTag = 'Define',
csXmlTagName = 'Define',
razorCode = 'PreProc',
razorcsLHSMemberAccessOperator = 'Noise',
razorcsRHSMemberAccessOperator = 'razorcsLHSMemberAccessOperator',
razorcsStringDelimiter = 'razorhtmlValueDelimiter',
razorcsTypeNullable = 'Special',
razorcsUnaryOperatorKeyword = 'Operator',
razorDelimiter = 'Delimiter',
razorEventAttribute = 'PreCondit',
razorFor = 'razorIf',
razorhtmlAttribute = 'htmlArg',
razorhtmlAttributeOperator = 'Operator',
razorhtmlTag = 'htmlTag',
razorhtmlValueDelimiter = 'Delimiter',
razorIf = 'PreCondit',
razorImplicitExpression = 'PreProc',
razorLine = 'Constant',
razorUsing = 'Include',
--[[ 4.3.4. CSS ]]
cssBraces = 'Delimiter' ,
cssProp = 'Keyword' ,
cssSelectorOp = 'Operator' ,
cssTagName = 'Type' ,
cssTagName = 'htmlTagName',
scssAmpersand = 'Special' ,
scssAttribute = 'Normal' ,
scssBoolean = 'Boolean' ,
scssDefault = 'Keyword' ,
scssElse = 'PreCondit' ,
scssIf = 'PreCondit' ,
scssInclude = 'Include' ,
scssSelectorChar = 'Operator' ,
scssSelectorName = 'Label' ,
scssVariable = 'Define' ,
scssVariableAssignment = 'Operator' ,
cssAtRule = 'PreCondit',
cssAttr = 'Keyword',
cssAttrComma = 'Noise',
cssAttrRegion = 'Keyword',
cssBraces = 'Delimiter',
cssClassName = 'Identifier',
cssClassNameDot = 'Noise',
cssFlexibleBoxAttr = 'cssAttr',
cssFunctionComma = 'Noise',
cssImportant = 'Exception',
cssNoise = 'Noise',
cssProp = 'Label',
cssPseudoClass = 'Special',
cssPseudoClassId = 'cssSelectorOp',
cssSelectorOp = 'Operator',
cssTagName = 'Structure',
cssUnitDecorators = 'Type',
scssAmpersand = 'Special',
scssAttribute = 'Noise',
scssBoolean = 'Boolean',
scssDefault = 'Keyword',
scssElse = 'scssIf',
scssMixinName = function(self)
local super = self.cssClassName
return {bg = super.bg, fg=super.fg, style='Italic'}
end,
scssIf = 'PreCondit',
scssInclude = 'Include',
scssSelectorChar = 'Delimiter',
scssDefinition = 'PreProc',
scssSelectorName = 'Identifier',
scssVariable = 'Define',
scssVariableAssignment = 'Operator',
--[[ 4.3.5. Dart ]]
dartLibrary = 'Statement',
@ -454,22 +489,27 @@ local highlight_groups = {
haskellStatement = 'Statement' ,
--[[ 4.3.24 Lua ]]
luaBraces = 'Structure' ,
luaBrackets = 'Delimiter' ,
luaBuiltin = 'Keyword' ,
luaComma = 'Delimiter' ,
luaFuncArgName = 'Identifier' ,
luaFuncCall = 'Function' ,
luaFuncId = 'luaNoise' ,
luaFuncKeyword = 'Type' ,
luaFuncName = 'Function' ,
luaFuncParens = 'Delimiter' ,
luaFuncTable = 'Structure' ,
luaLocal = 'Type' ,
luaNoise = 'Delimiter' ,
luaParens = 'Delimiter' ,
luaSpecialTable = 'StorageClass',
luaSpecialValue = 'Function' ,
luaBraces = 'Structure',
luaBrackets = 'Delimiter',
luaBuiltin = 'Keyword',
luaComma = 'Delimiter',
luaFuncArgName = 'Identifier',
luaFuncCall = 'Function',
luaFuncId = 'luaNoise',
luaFuncKeyword = 'Type',
luaFuncName = 'Function',
luaFuncParens = 'Delimiter',
luaFuncTable = 'Structure',
luaIn = 'luaRepeat',
luaLocal = 'Type',
luaNoise = 'Delimiter',
luaParens = 'Delimiter',
luaSpecialTable = 'Structure',
luaSpecialValue = 'Function',
luaStringLongTag = function(self)
local delimiter = self.Delimiter
return {bg = delimiter.bg, fg=delimiter.fg, style='italic'}
end,
--[[ 4.3.25. SQL ]]
sqlKeyword = 'Keyword' ,
@ -480,6 +520,7 @@ local highlight_groups = {
--[[ 4.3.26. dos INI ]]
dosiniHeader = 'Title',
dosiniLabel = 'Label',
--[[ 4.3.27. Crontab ]]
crontabDay = 'StorageClass',
@ -542,16 +583,6 @@ local highlight_groups = {
ALEErrorSign = 'ErrorMsg' ,
ALEWarningSign = 'WarningMsg',
--[[ 4.4.2. coc.nvim ]]
CocErrorHighlight = {bg=NONE, fg=NONE, style={'undercurl', color='red' }},
CocErrorSign = 'ALEErrorSign',
CocHintHighlight = {bg=NONE, fg=NONE, style={'undercurl', color='purple' }},
CocHintSign = 'HintMsg',
CocInfoHighlight = {bg=NONE, fg=NONE, style={'undercurl', color='pink' }},
CocInfoSign = 'InfoMsg',
CocWarningHighlight = {bg=NONE, fg=NONE, style={'undercurl', color='orange' }},
CocWarningSign = 'ALEWarningSign',
--[[ 4.4.2. vim-jumpmotion / vim-easymotion ]]
EasyMotion = 'IncSearch' ,
JumpMotion = 'EasyMotion',

View file

@ -10,6 +10,7 @@ local vim = vim
local api = vim.api
local exe = api.nvim_command
local fn = vim.fn
local go = vim.go
--[[
/*
@ -18,16 +19,16 @@ local fn = vim.fn
--]]
-- These are constants for the indexes in the colors that were defined before.
local _NONE = 'NONE'
local _NONE = 'NONE'
local _PALETTE_256 = 2
local _PALETTE_ANSI = 3
local _PALETTE_HEX = 1
local _TYPE_STRING = 'string'
local _TYPE_TABLE = 'table'
local _TYPE_STRING = 'string'
local _TYPE_TABLE = 'table'
-- Determine which set of colors to use.
local _USE_HEX = vim.o.termguicolors
local _USE_256 = tonumber(vim.o.t_Co) > 255
local _USE_HEX = go.termguicolors
local _USE_256 = tonumber(go.t_Co) > 255
or string.find(vim.env.TERM, '256')
--[[
@ -88,7 +89,7 @@ local function tohex(rgb) return string.format('#%06x', rgb) end
-- Load specific &bg instructions
local function use_background_with(attributes)
return setmetatable(
attributes[vim.o.background],
attributes[go.background],
{['__index'] = attributes}
)
end
@ -102,7 +103,7 @@ end
local yolokai = {}
function yolokai.group(group_name)
local no_errors, group_definition = pcall(api.nvim_get_hl_by_name, group_name, vim.o.termguicolors)
local no_errors, group_definition = pcall(api.nvim_get_hl_by_name, group_name, go.termguicolors)
if not no_errors then group_definition = {} end
@ -132,7 +133,7 @@ function yolokai.highlight(highlight_group, attributes) -- {{{ †
highlight_cmd[5] = attributes
else -- The `highlight_group` is uniquely defined.
-- Take care of special instructions for certain background colors.
if attributes[vim.o.background] then
if attributes[go.background] then
attributes = use_background_with(attributes)
end
@ -154,7 +155,7 @@ end --}}} ‡
function yolokai:highlight_terminal(terminal_ansi_colors)
for index, color in ipairs(terminal_ansi_colors) do vim.g['terminal_color_'..(index-1)] =
vim.o.termguicolors and color[_PALETTE_HEX] or color[_PALETTE_256] or get(color, _PALETTE_ANSI)
go.termguicolors and color[_PALETTE_HEX] or color[_PALETTE_256] or get(color, _PALETTE_ANSI)
end
end
@ -186,7 +187,7 @@ return setmetatable(yolokai, {['__call'] = function(self, normal, highlights, te
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
if not (_USE_HEX or _USE_256) then go.t_Co = '16' end
-- Highlight the baseline.
self.highlight('Normal', normal)