nvim: Sync with nvim-highlite upstream
This commit is contained in:
parent
1a88bddf19
commit
9a2f273a7d
2 changed files with 164 additions and 138 deletions
|
@ -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',
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue