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

@ -232,43 +232,43 @@ 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',
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',
csUnspecifiedStatement = 'Statement' ,
csXmlTag = 'Define' ,
csXmlTagName = 'Define' ,
--[[ 4.3.4. CSS ]]
cssBraces = 'Delimiter',
cssProp = 'Keyword',
cssSelectorOp = 'Operator',
cssTagName = 'Type',
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',
scssAmpersand = 'Special' ,
scssAttribute = 'Normal' ,
scssBoolean = 'Boolean' ,
scssDefault = 'Keyword' ,
scssElse = 'PreCondit' ,
scssIf = 'PreCondit' ,
scssInclude = 'Include' ,
scssSelectorChar = 'Operator' ,
scssSelectorName = 'Label' ,
scssVariable = 'Define' ,
scssVariableAssignment = 'Operator' ,
--[[ 4.3.5. Dart ]]
dartLibrary = 'Statement',
@ -327,11 +327,11 @@ local highlight_groups = {
jsVariableDef = 'Identifier',
--[[ 4.3.11. JSON ]]
jsonBraces = 'luaBraces',
jsonBraces = 'Structure',
jsonKeywordMatch = 'Delimiter',
jsonNull = 'Constant',
jsonQuote = 'String',
jsonString = 'Normal',
jsonNull = 'Constant' ,
jsonQuote = 'String' ,
jsonString = 'Normal' ,
jsonStringSQError = 'Exception',
--[[ 4.3.12. Make ]]
@ -345,19 +345,18 @@ local highlight_groups = {
markdownH4 = {bg=NONE, fg=purple, style='bold' },
markdownH5 = {bg=NONE, fg=orange, style='bold' },
markdownH6 = {bg=NONE, fg=yellow, style='bold' },
mkdBold = {bg=NONE, fg='green', style='bold' },
mkdBold = 'SpecialComment',
mkdCode = 'Statement',
mkdCodeDelimiter = 'mkdBold',
mkdBold = 'SpecialComment' ,
mkdCode = 'Keyword' ,
mkdCodeDelimiter = 'mkdBold' ,
mkdCodeStart = 'mkdCodeDelimiter',
mkdCodeEnd = 'mkdCodeStart',
mkdHeading = 'Delimiter',
mkdItalic = 'mkdBold',
mkdListItem = 'Special',
mkdRule = 'Underlined',
texMathMatcher = 'Number',
texMathZoneX = 'Number',
texMathZoneY = 'Number',
mkdCodeEnd = 'mkdCodeStart' ,
mkdHeading = 'Delimiter' ,
mkdItalic = 'mkdBold' ,
mkdListItem = 'Special' ,
mkdRule = 'Underlined' ,
texMathMatcher = 'Number' ,
texMathZoneX = 'Number' ,
texMathZoneY = 'Number' ,
--[[ 4.3.14. Python ]]
pythonBrackets = 'Delimiter' ,
@ -397,12 +396,12 @@ local highlight_groups = {
--[[ 4.3.18. shell ]]
shDerefSimple = 'SpecialChar',
shFunctionKey = 'Function',
shLoop = 'Repeat',
shParen = 'Delimiter',
shQuote = 'Delimiter',
shSet = 'Statement',
shTestOpr = 'Debug',
shFunctionKey = 'Function' ,
shLoop = 'Repeat' ,
shParen = 'Delimiter' ,
shQuote = 'Delimiter' ,
shSet = 'Statement' ,
shTestOpr = 'Debug' ,
--[[ 4.3.19. Solidity ]]
solBuiltinType = 'Type' ,
@ -415,16 +414,19 @@ local highlight_groups = {
tomlTable = 'StorageClass',
--[[ 4.3.21. VimScript ]]
helpSpecial = 'Special',
vimFgBgAttrib = 'Constant',
vimHiCterm = 'Label',
helpSpecial = 'Special' ,
vimFgBgAttrib = 'Constant' ,
vimHiCterm = 'Label' ,
vimHiCtermFgBg = 'vimHiCterm',
vimHiGroup = 'Typedef',
vimHiGroup = 'Typedef' ,
vimHiGui = 'vimHiCterm',
vimHiGuiFgBg = 'vimHiGui',
vimHiKeyList = 'Operator',
vimOption = 'Define',
vimSetEqual = 'Operator',
vimHiGuiFgBg = 'vimHiGui' ,
vimHiKeyList = 'Operator' ,
vimOption = 'Keyword' ,
vimScriptDelim = 'Ignore' ,
vimSet = 'String' ,
vimSetEqual = 'Operator' ,
vimSetSep = 'Delimiter' ,
--[[ 4.3.22. XML ]]
xmlAttrib = 'Label' ,
@ -443,42 +445,60 @@ local highlight_groups = {
haskellStatement = 'Statement' ,
--[[ 4.3.24 Lua ]]
luaBraces = 'Structure',
luaBrackets = 'Delimiter',
luaBuiltin = 'Keyword',
luaComma = 'Delimiter',
luaFuncCall = 'Function',
luaFuncId = 'luaNoise',
luaFuncKeyword = 'Function',
luaFuncName = 'Identifier',
luaFuncParens = 'Delimiter',
luaFuncTable = 'Structure',
luaLocal = 'Type',
luaNoise = 'Operator',
luaParens = 'Delimiter',
luaSpecialTable = 'Identifier',
luaSpecialValue = 'Function',
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 = 'Operator' ,
luaParens = 'Delimiter' ,
luaSpecialTable = 'StorageClass',
luaSpecialValue = 'Function' ,
--[[ 4.3.25. SQL ]]
sqlKeyword = 'Keyword',
sqlKeyword = 'Keyword' ,
sqlParen = 'Delimiter',
sqlSpecial = 'Constant',
sqlSpecial = 'Constant' ,
sqlStatement = 'Statement',
sqlParenFunc = 'Function',
sqlParenFunc = 'Function' ,
--[[ 4.3.26. dos INI ]]
dosiniHeader = 'Title',
--[[ 4.3.27. Crontab ]]
crontabDay = 'StorageClass',
crontabDow = 'String',
crontabHr = 'Number',
crontabMin = 'Float',
crontabMnth = 'Structure',
crontabDow = 'String' ,
crontabHr = 'Number' ,
crontabMin = 'Float' ,
crontabMnth = 'Structure' ,
--[[ 4.3.28. PlantUML ]]
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
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

View file

@ -1,4 +1,5 @@
--[[ NOTHING INSIDE THIS FILE NEEDS TO BE EDITED BY THE USER. ]]
local yolokai = {}
local vim = vim
-- 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
-- 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.fn.has('gui_running')
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 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.
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 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] =
' ctermbg='..get(attributes.bg, PALETTE_256)
..' ctermfg='..get(attributes.fg, PALETTE_256)
@ -60,7 +61,7 @@ end or function(command, attributes)
end --}}} ‡
-- 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
if color then -- There is an undercurl color.
@ -71,7 +72,7 @@ end or function(command, style)
end --}}} ‡
-- 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
local highlight_cmd = {'hi! ', highlight_group}
@ -82,8 +83,7 @@ local function highlight(highlight_group, attributes) -- {{{ †
end
-- Determine if there is a highlight link, and if so, assign it.
local link = (type(attributes) == 'string' and attributes)
or attributes.link
local link = (type(attributes) == 'string') and attributes or attributes.link
if link then -- `highlight_group` is a link to another group.
highlight_cmd[3] = highlight_cmd[2]..' '
@ -104,17 +104,23 @@ local function highlight(highlight_group, attributes) -- {{{ †
vim.cmd(table.concat(highlight_cmd))
end --}}} ‡
return function(Normal, highlights, terminal_ansi_colors)
-- Highlight the baseline.
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
function yolokai:highlight_terminal(terminal_ansi_colors)
if self.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]
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
})