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

@ -327,7 +327,7 @@ local highlight_groups = {
jsVariableDef = 'Identifier',
--[[ 4.3.11. JSON ]]
jsonBraces = 'luaBraces',
jsonBraces = 'Structure',
jsonKeywordMatch = 'Delimiter',
jsonNull = 'Constant' ,
jsonQuote = 'String' ,
@ -345,9 +345,8 @@ 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',
mkdCode = 'Keyword' ,
mkdCodeDelimiter = 'mkdBold' ,
mkdCodeStart = 'mkdCodeDelimiter',
mkdCodeEnd = 'mkdCodeStart' ,
@ -423,8 +422,11 @@ local highlight_groups = {
vimHiGui = 'vimHiCterm',
vimHiGuiFgBg = 'vimHiGui' ,
vimHiKeyList = 'Operator' ,
vimOption = 'Define',
vimOption = 'Keyword' ,
vimScriptDelim = 'Ignore' ,
vimSet = 'String' ,
vimSetEqual = 'Operator' ,
vimSetSep = 'Delimiter' ,
--[[ 4.3.22. XML ]]
xmlAttrib = 'Label' ,
@ -447,16 +449,17 @@ local highlight_groups = {
luaBrackets = 'Delimiter' ,
luaBuiltin = 'Keyword' ,
luaComma = 'Delimiter' ,
luaFuncArgName = 'Identifier' ,
luaFuncCall = 'Function' ,
luaFuncId = 'luaNoise' ,
luaFuncKeyword = 'Function',
luaFuncName = 'Identifier',
luaFuncKeyword = 'Type' ,
luaFuncName = 'Function' ,
luaFuncParens = 'Delimiter' ,
luaFuncTable = 'Structure' ,
luaLocal = 'Type' ,
luaNoise = 'Operator' ,
luaParens = 'Delimiter' ,
luaSpecialTable = 'Identifier',
luaSpecialTable = 'StorageClass',
luaSpecialValue = 'Function' ,
--[[ 4.3.25. SQL ]]
@ -479,6 +482,23 @@ local highlight_groups = {
--[[ 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
})