nvim: Sync with nvim-highlite upstream
This commit is contained in:
parent
1a88bddf19
commit
9a2f273a7d
2 changed files with 164 additions and 138 deletions
|
@ -327,7 +327,7 @@ 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' ,
|
||||||
|
@ -345,9 +345,8 @@ 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 = 'Statement',
|
mkdCode = 'Keyword' ,
|
||||||
mkdCodeDelimiter = 'mkdBold' ,
|
mkdCodeDelimiter = 'mkdBold' ,
|
||||||
mkdCodeStart = 'mkdCodeDelimiter',
|
mkdCodeStart = 'mkdCodeDelimiter',
|
||||||
mkdCodeEnd = 'mkdCodeStart' ,
|
mkdCodeEnd = 'mkdCodeStart' ,
|
||||||
|
@ -423,8 +422,11 @@ local highlight_groups = {
|
||||||
vimHiGui = 'vimHiCterm',
|
vimHiGui = 'vimHiCterm',
|
||||||
vimHiGuiFgBg = 'vimHiGui' ,
|
vimHiGuiFgBg = 'vimHiGui' ,
|
||||||
vimHiKeyList = 'Operator' ,
|
vimHiKeyList = 'Operator' ,
|
||||||
vimOption = 'Define',
|
vimOption = 'Keyword' ,
|
||||||
|
vimScriptDelim = 'Ignore' ,
|
||||||
|
vimSet = 'String' ,
|
||||||
vimSetEqual = 'Operator' ,
|
vimSetEqual = 'Operator' ,
|
||||||
|
vimSetSep = 'Delimiter' ,
|
||||||
|
|
||||||
--[[ 4.3.22. XML ]]
|
--[[ 4.3.22. XML ]]
|
||||||
xmlAttrib = 'Label' ,
|
xmlAttrib = 'Label' ,
|
||||||
|
@ -447,16 +449,17 @@ local highlight_groups = {
|
||||||
luaBrackets = 'Delimiter' ,
|
luaBrackets = 'Delimiter' ,
|
||||||
luaBuiltin = 'Keyword' ,
|
luaBuiltin = 'Keyword' ,
|
||||||
luaComma = 'Delimiter' ,
|
luaComma = 'Delimiter' ,
|
||||||
|
luaFuncArgName = 'Identifier' ,
|
||||||
luaFuncCall = 'Function' ,
|
luaFuncCall = 'Function' ,
|
||||||
luaFuncId = 'luaNoise' ,
|
luaFuncId = 'luaNoise' ,
|
||||||
luaFuncKeyword = 'Function',
|
luaFuncKeyword = 'Type' ,
|
||||||
luaFuncName = 'Identifier',
|
luaFuncName = 'Function' ,
|
||||||
luaFuncParens = 'Delimiter' ,
|
luaFuncParens = 'Delimiter' ,
|
||||||
luaFuncTable = 'Structure' ,
|
luaFuncTable = 'Structure' ,
|
||||||
luaLocal = 'Type' ,
|
luaLocal = 'Type' ,
|
||||||
luaNoise = 'Operator' ,
|
luaNoise = 'Operator' ,
|
||||||
luaParens = 'Delimiter' ,
|
luaParens = 'Delimiter' ,
|
||||||
luaSpecialTable = 'Identifier',
|
luaSpecialTable = 'StorageClass',
|
||||||
luaSpecialValue = 'Function' ,
|
luaSpecialValue = 'Function' ,
|
||||||
|
|
||||||
--[[ 4.3.25. SQL ]]
|
--[[ 4.3.25. SQL ]]
|
||||||
|
@ -479,6 +482,23 @@ local highlight_groups = {
|
||||||
--[[ 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