nvim: Sync with nvim-highlite upstream

This commit is contained in:
Sanchayan Maity 2020-11-21 11:31:25 +05:30
parent 1a88bddf19
commit 9a2f273a7d
2 changed files with 164 additions and 138 deletions

View file

@ -17,28 +17,28 @@ lua << EOF
vim.g.colors_name = 'yolokai' vim.g.colors_name = 'yolokai'
local white = { '#E8E8E3', 252, 'white' } local white = { '#E8E8E3', 252, 'white' }
local white2 = { '#d8d8d3', 250, 'white2' } local white2 = { '#d8d8d3', 250, 'white2' }
local black = { '#000000', 234, 'black' } local black = { '#000000', 234, 'black' }
local lightblack = { '#2D2E27', 235, 'lightblack' } local lightblack = { '#2D2E27', 235, 'lightblack' }
local lightblack2 = { '#383a3e', 236, 'lightblack2' } local lightblack2 = { '#383a3e', 236, 'lightblack2' }
local lightblack3 = { '#3f4145', 237, 'lightblack3' } local lightblack3 = { '#3f4145', 237, 'lightblack3' }
local darkblack = { '#211F1C', 233, 'darkblack' } local darkblack = { '#211F1C', 233, 'darkblack' }
local grey = { '#8F908A', 243, 'grey' } local grey = { '#8F908A', 243, 'grey' }
local lightgrey = { '#575b61', 237, 'lightgrey' } local lightgrey = { '#575b61', 237, 'lightgrey' }
local darkgrey = { '#64645e', 239, 'darkgrey' } local darkgrey = { '#64645e', 239, 'darkgrey' }
local warmgrey = { '#A6A185', 59, 'warmgrey' } local warmgrey = { '#A6A185', 59, 'warmgrey' }
local pink = { '#F92772', 197, 'pink' } local pink = { '#F92772', 197, 'pink' }
local green = { '#A6E22D', 148, 'green' } local green = { '#A6E22D', 148, 'green' }
local darkgreen = { '#50de60', 83, 'darkgreen' } local darkgreen = { '#50de60', 83, 'darkgreen' }
local aqua = { '#66d9ef', 81, 'aqua' } local aqua = { '#66d9ef', 81, 'aqua' }
local yellow = { '#E6DB74', 186, 'yellow' } local yellow = { '#E6DB74', 186, 'yellow' }
local orange = { '#FD9720', 208, 'orange' } local orange = { '#FD9720', 208, 'orange' }
local purple = { '#ae81ff', 141, 'purple' } local purple = { '#ae81ff', 141, 'purple' }
local red = { '#e73c50', 196, 'red' } local red = { '#e73c50', 196, 'red' }
local purered = { '#ff0000', 52, 'purered' } local purered = { '#ff0000', 52, 'purered' }
local darkred = { '#5f0000', 52, 'darkred' } local darkred = { '#5f0000', 52, 'darkred' }
--[[ DO NOT EDIT `BG`, `FG`, or `NONE`. --[[ DO NOT EDIT `BG`, `FG`, or `NONE`.
Feel free to uncomment `BG`. It is not used by default so it is commented out. Feel free to uncomment `BG`. It is not used by default so it is commented out.
@ -232,43 +232,43 @@ local highlight_groups = {
cppSTLnamespace = 'String' , cppSTLnamespace = 'String' ,
--[[ 4.3.3 C# ]] --[[ 4.3.3 C# ]]
csBraces = 'Delimiter', csBraces = 'Delimiter' ,
csClass = 'Structure', csClass = 'Structure' ,
csClassType = 'Type', csClassType = 'Type' ,
csContextualStatement = 'Conditional', csContextualStatement = 'Conditional' ,
csEndColon = 'Delimiter', csEndColon = 'Delimiter' ,
csGeneric = 'Typedef', csGeneric = 'Typedef' ,
csInterpolation = 'Include', csInterpolation = 'Include' ,
csInterpolationDelimiter = 'SpecialChar', csInterpolationDelimiter = 'SpecialChar' ,
csLogicSymbols = 'Operator', csLogicSymbols = 'Operator' ,
csModifier = 'Keyword', csModifier = 'Keyword' ,
csNew = 'Operator', csNew = 'Operator' ,
csNewType = 'Type', csNewType = 'Type' ,
csParens = 'Delimiter', csParens = 'Delimiter' ,
csPreCondit = 'PreProc', csPreCondit = 'PreProc' ,
csRepeat = 'Repeat', csRepeat = 'Repeat' ,
csStorage = 'StorageClass', csStorage = 'StorageClass',
csUnspecifiedStatement = 'Statement', csUnspecifiedStatement = 'Statement' ,
csXmlTag = 'Define', csXmlTag = 'Define' ,
csXmlTagName = 'Define', csXmlTagName = 'Define' ,
--[[ 4.3.4. CSS ]] --[[ 4.3.4. CSS ]]
cssBraces = 'Delimiter', cssBraces = 'Delimiter' ,
cssProp = 'Keyword', cssProp = 'Keyword' ,
cssSelectorOp = 'Operator', cssSelectorOp = 'Operator' ,
cssTagName = 'Type', cssTagName = 'Type' ,
cssTagName = 'htmlTagName', cssTagName = 'htmlTagName',
scssAmpersand = 'Special', scssAmpersand = 'Special' ,
scssAttribute = 'Normal', scssAttribute = 'Normal' ,
scssBoolean = 'Boolean', scssBoolean = 'Boolean' ,
scssDefault = 'Keyword', scssDefault = 'Keyword' ,
scssElse = 'PreCondit', scssElse = 'PreCondit' ,
scssIf = 'PreCondit', scssIf = 'PreCondit' ,
scssInclude = 'Include', scssInclude = 'Include' ,
scssSelectorChar = 'Operator', scssSelectorChar = 'Operator' ,
scssSelectorName = 'Label', scssSelectorName = 'Label' ,
scssVariable = 'Define', scssVariable = 'Define' ,
scssVariableAssignment = 'Operator', scssVariableAssignment = 'Operator' ,
--[[ 4.3.5. Dart ]] --[[ 4.3.5. Dart ]]
dartLibrary = 'Statement', dartLibrary = 'Statement',
@ -301,21 +301,21 @@ local highlight_groups = {
goVarDefs = 'goVarAssign' , goVarDefs = 'goVarAssign' ,
--[[ 4.3.8. HTML ]] --[[ 4.3.8. HTML ]]
htmlArg = 'Label', htmlArg = 'Label',
htmlBold = {bg=NONE, fg=lightgrey, style='bold'}, htmlBold = {bg=NONE, fg=lightgrey, style='bold'},
htmlTitle = 'htmlBold', htmlTitle = 'htmlBold',
htmlEndTag = 'htmlTag', htmlEndTag = 'htmlTag',
htmlH1 = 'markdownH1', htmlH1 = 'markdownH1',
htmlH2 = 'markdownH2', htmlH2 = 'markdownH2',
htmlH3 = 'markdownH3', htmlH3 = 'markdownH3',
htmlH4 = 'markdownH4', htmlH4 = 'markdownH4',
htmlH5 = 'markdownH5', htmlH5 = 'markdownH5',
htmlH6 = 'markdownH6', htmlH6 = 'markdownH6',
htmlItalic = {bg=NONE, fg=NONE, style='italic'}, htmlItalic = {bg=NONE, fg=NONE, style='italic'},
htmlSpecialTagName = 'Keyword', htmlSpecialTagName = 'Keyword',
htmlTag = 'Special', htmlTag = 'Special',
htmlTagN = 'Typedef', htmlTagN = 'Typedef',
htmlTagName = 'Type', htmlTagName = 'Type',
--[[ 4.3.9. Java ]] --[[ 4.3.9. Java ]]
javaClassDecl = 'Structure', javaClassDecl = 'Structure',
@ -327,11 +327,11 @@ local highlight_groups = {
jsVariableDef = 'Identifier', jsVariableDef = 'Identifier',
--[[ 4.3.11. JSON ]] --[[ 4.3.11. JSON ]]
jsonBraces = 'luaBraces', jsonBraces = 'Structure',
jsonKeywordMatch = 'Delimiter', jsonKeywordMatch = 'Delimiter',
jsonNull = 'Constant', jsonNull = 'Constant' ,
jsonQuote = 'String', jsonQuote = 'String' ,
jsonString = 'Normal', jsonString = 'Normal' ,
jsonStringSQError = 'Exception', jsonStringSQError = 'Exception',
--[[ 4.3.12. Make ]] --[[ 4.3.12. Make ]]
@ -345,19 +345,18 @@ local highlight_groups = {
markdownH4 = {bg=NONE, fg=purple, style='bold' }, markdownH4 = {bg=NONE, fg=purple, style='bold' },
markdownH5 = {bg=NONE, fg=orange, style='bold' }, markdownH5 = {bg=NONE, fg=orange, style='bold' },
markdownH6 = {bg=NONE, fg=yellow, style='bold' }, markdownH6 = {bg=NONE, fg=yellow, style='bold' },
mkdBold = {bg=NONE, fg='green', style='bold' }, mkdBold = 'SpecialComment' ,
mkdBold = 'SpecialComment', mkdCode = 'Keyword' ,
mkdCode = 'Statement', mkdCodeDelimiter = 'mkdBold' ,
mkdCodeDelimiter = 'mkdBold',
mkdCodeStart = 'mkdCodeDelimiter', mkdCodeStart = 'mkdCodeDelimiter',
mkdCodeEnd = 'mkdCodeStart', mkdCodeEnd = 'mkdCodeStart' ,
mkdHeading = 'Delimiter', mkdHeading = 'Delimiter' ,
mkdItalic = 'mkdBold', mkdItalic = 'mkdBold' ,
mkdListItem = 'Special', mkdListItem = 'Special' ,
mkdRule = 'Underlined', mkdRule = 'Underlined' ,
texMathMatcher = 'Number', texMathMatcher = 'Number' ,
texMathZoneX = 'Number', texMathZoneX = 'Number' ,
texMathZoneY = 'Number', texMathZoneY = 'Number' ,
--[[ 4.3.14. Python ]] --[[ 4.3.14. Python ]]
pythonBrackets = 'Delimiter' , pythonBrackets = 'Delimiter' ,
@ -397,12 +396,12 @@ local highlight_groups = {
--[[ 4.3.18. shell ]] --[[ 4.3.18. shell ]]
shDerefSimple = 'SpecialChar', shDerefSimple = 'SpecialChar',
shFunctionKey = 'Function', shFunctionKey = 'Function' ,
shLoop = 'Repeat', shLoop = 'Repeat' ,
shParen = 'Delimiter', shParen = 'Delimiter' ,
shQuote = 'Delimiter', shQuote = 'Delimiter' ,
shSet = 'Statement', shSet = 'Statement' ,
shTestOpr = 'Debug', shTestOpr = 'Debug' ,
--[[ 4.3.19. Solidity ]] --[[ 4.3.19. Solidity ]]
solBuiltinType = 'Type' , solBuiltinType = 'Type' ,
@ -415,16 +414,19 @@ local highlight_groups = {
tomlTable = 'StorageClass', tomlTable = 'StorageClass',
--[[ 4.3.21. VimScript ]] --[[ 4.3.21. VimScript ]]
helpSpecial = 'Special', helpSpecial = 'Special' ,
vimFgBgAttrib = 'Constant', vimFgBgAttrib = 'Constant' ,
vimHiCterm = 'Label', vimHiCterm = 'Label' ,
vimHiCtermFgBg = 'vimHiCterm', vimHiCtermFgBg = 'vimHiCterm',
vimHiGroup = 'Typedef', vimHiGroup = 'Typedef' ,
vimHiGui = 'vimHiCterm', vimHiGui = 'vimHiCterm',
vimHiGuiFgBg = 'vimHiGui', vimHiGuiFgBg = 'vimHiGui' ,
vimHiKeyList = 'Operator', vimHiKeyList = 'Operator' ,
vimOption = 'Define', vimOption = 'Keyword' ,
vimSetEqual = 'Operator', vimScriptDelim = 'Ignore' ,
vimSet = 'String' ,
vimSetEqual = 'Operator' ,
vimSetSep = 'Delimiter' ,
--[[ 4.3.22. XML ]] --[[ 4.3.22. XML ]]
xmlAttrib = 'Label' , xmlAttrib = 'Label' ,
@ -443,42 +445,60 @@ local highlight_groups = {
haskellStatement = 'Statement' , haskellStatement = 'Statement' ,
--[[ 4.3.24 Lua ]] --[[ 4.3.24 Lua ]]
luaBraces = 'Structure', luaBraces = 'Structure' ,
luaBrackets = 'Delimiter', luaBrackets = 'Delimiter' ,
luaBuiltin = 'Keyword', luaBuiltin = 'Keyword' ,
luaComma = 'Delimiter', luaComma = 'Delimiter' ,
luaFuncCall = 'Function', luaFuncArgName = 'Identifier' ,
luaFuncId = 'luaNoise', luaFuncCall = 'Function' ,
luaFuncKeyword = 'Function', luaFuncId = 'luaNoise' ,
luaFuncName = 'Identifier', luaFuncKeyword = 'Type' ,
luaFuncParens = 'Delimiter', luaFuncName = 'Function' ,
luaFuncTable = 'Structure', luaFuncParens = 'Delimiter' ,
luaLocal = 'Type', luaFuncTable = 'Structure' ,
luaNoise = 'Operator', luaLocal = 'Type' ,
luaParens = 'Delimiter', luaNoise = 'Operator' ,
luaSpecialTable = 'Identifier', luaParens = 'Delimiter' ,
luaSpecialValue = 'Function', luaSpecialTable = 'StorageClass',
luaSpecialValue = 'Function' ,
--[[ 4.3.25. SQL ]] --[[ 4.3.25. SQL ]]
sqlKeyword = 'Keyword', sqlKeyword = 'Keyword' ,
sqlParen = 'Delimiter', sqlParen = 'Delimiter',
sqlSpecial = 'Constant', sqlSpecial = 'Constant' ,
sqlStatement = 'Statement', sqlStatement = 'Statement',
sqlParenFunc = 'Function', sqlParenFunc = 'Function' ,
--[[ 4.3.26. dos INI ]] --[[ 4.3.26. dos INI ]]
dosiniHeader = 'Title', dosiniHeader = 'Title',
--[[ 4.3.27. Crontab ]] --[[ 4.3.27. Crontab ]]
crontabDay = 'StorageClass', crontabDay = 'StorageClass',
crontabDow = 'String', crontabDow = 'String' ,
crontabHr = 'Number', crontabHr = 'Number' ,
crontabMin = 'Float', crontabMin = 'Float' ,
crontabMnth = 'Structure', crontabMnth = 'Structure' ,
--[[ 4.3.28. PlantUML ]] --[[ 4.3.28. PlantUML ]]
plantumlColonLine = {}, plantumlColonLine = {},
--[[ 4.3.33. YAML ]]
yamlKey = 'Label',
--[[ 4.3.34. Git ]]
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.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
here if you don't want to define it, or add more if there's something here if you don't want to define it, or add more if there's something

View file

@ -1,4 +1,5 @@
--[[ NOTHING INSIDE THIS FILE NEEDS TO BE EDITED BY THE USER. ]] --[[ NOTHING INSIDE THIS FILE NEEDS TO BE EDITED BY THE USER. ]]
local yolokai = {}
local vim = vim local vim = vim
-- Clear the highlighting. -- Clear the highlighting.
@ -11,13 +12,13 @@ vim.g.indent_guides_auto_colors = 0
if vim.fn.exists('syntax_on') then vim.cmd('syntax reset') end if vim.fn.exists('syntax_on') then vim.cmd('syntax reset') end
-- Determine which set of colors to use. -- Determine which set of colors to use.
local using_hex_or_256 = tonumber(vim.o.t_Co) >= 256 yolokai.using_hex_or_256 = tonumber(vim.o.t_Co) >= 256
or vim.o.termguicolors or vim.o.termguicolors
or vim.fn.has('gui_running') or vim.fn.has('gui_running')
or string.find(vim.fn.expand('$TERM'), '256') or string.find(vim.fn.expand('$TERM'), '256')
-- If we aren't using the hex and 256 colorset, then set the &t_Co variable to 16. -- If we aren't using the hex and 256 colorset, then set the &t_Co variable to 16.
if not using_hex_or_256 then vim.o.t_Co = 16 end if not yolokai.using_hex_or_256 then vim.o.t_Co = 16 end
-- These are constants for the indexes in the colors that were defined before. -- These are constants for the indexes in the colors that were defined before.
local PALETTE_ANSI = 3 local PALETTE_ANSI = 3
@ -45,7 +46,7 @@ end --}}} ‡
--[[ If using hex and 256-bit colors, then populate the gui* and cterm* args. --[[ If using hex and 256-bit colors, then populate the gui* and cterm* args.
If using 16-bit colors, just populate the cterm* args. ]] If using 16-bit colors, just populate the cterm* args. ]]
local colorize = using_hex_or_256 and function(command, attributes) -- {{{ † local colorize = yolokai.using_hex_or_256 and function(command, attributes) -- {{{ †
command[#command + 1] = command[#command + 1] =
' ctermbg='..get(attributes.bg, PALETTE_256) ' ctermbg='..get(attributes.bg, PALETTE_256)
..' ctermfg='..get(attributes.fg, PALETTE_256) ..' ctermfg='..get(attributes.fg, PALETTE_256)
@ -60,7 +61,7 @@ end or function(command, attributes)
end --}}} ‡ end --}}} ‡
-- This function appends `selected_attributes` to the end of `highlight_cmd`. -- This function appends `selected_attributes` to the end of `highlight_cmd`.
local stylize = using_hex_or_256 and function(command, style, color) -- {{{ † local stylize = yolokai.using_hex_or_256 and function(command, style, color) -- {{{ †
command[#command + 1] = ' cterm='..style..' gui='..style command[#command + 1] = ' cterm='..style..' gui='..style
if color then -- There is an undercurl color. if color then -- There is an undercurl color.
@ -71,7 +72,7 @@ end or function(command, style)
end --}}} ‡ end --}}} ‡
-- Generate a `:highlight` command from a group and some attributes. -- Generate a `:highlight` command from a group and some attributes.
local function highlight(highlight_group, attributes) -- {{{ † function yolokai.highlight(highlight_group, attributes) -- {{{ †
-- The base highlight command -- The base highlight command
local highlight_cmd = {'hi! ', highlight_group} local highlight_cmd = {'hi! ', highlight_group}
@ -82,8 +83,7 @@ local function highlight(highlight_group, attributes) -- {{{ †
end end
-- Determine if there is a highlight link, and if so, assign it. -- Determine if there is a highlight link, and if so, assign it.
local link = (type(attributes) == 'string' and attributes) local link = (type(attributes) == 'string') and attributes or attributes.link
or attributes.link
if link then -- `highlight_group` is a link to another group. if link then -- `highlight_group` is a link to another group.
highlight_cmd[3] = highlight_cmd[2]..' ' highlight_cmd[3] = highlight_cmd[2]..' '
@ -104,17 +104,23 @@ local function highlight(highlight_group, attributes) -- {{{ †
vim.cmd(table.concat(highlight_cmd)) vim.cmd(table.concat(highlight_cmd))
end --}}} ‡ end --}}} ‡
return function(Normal, highlights, terminal_ansi_colors) function yolokai:highlight_terminal(terminal_ansi_colors)
-- Highlight the baseline. if self.using_hex_or_256 then for index, color in ipairs(terminal_ansi_colors) do
highlight('Normal', Normal)
-- Highlight everything else.
for highlight_group, attributes in pairs(highlights) do
highlight(highlight_group, attributes)
end
-- Set the terminal colors.
if using_hex_or_256 then for index, color in ipairs(terminal_ansi_colors) do
vim.g['terminal_color_'..index] = vim.o.termguicolors and color[PALETTE_HEX] or color[PALETTE_256] vim.g['terminal_color_'..index] = vim.o.termguicolors and color[PALETTE_HEX] or color[PALETTE_256]
end end end end
end end
return setmetatable(yolokai, {
['__call'] = function(self, normal, highlights, terminal_ansi_colors)
-- Highlight the baseline.
self.highlight('Normal', normal)
-- Highlight everything else.
for highlight_group, attributes in pairs(highlights) do
self.highlight(highlight_group, attributes)
end
-- Set the terminal highlight colors.
self:highlight_terminal(terminal_ansi_colors)
end
})