nvim: Sync with changes to nvim-highlite upstream

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2020-07-29 13:24:20 +05:30
parent 57b888e2dd
commit 5b4ed5f9c6
2 changed files with 106 additions and 48 deletions

View file

@ -1,7 +1,7 @@
lua << EOF
--[[ Build using Highlite, a Neovim colorscheme template.
* Author: Iron-E (https://github.com/Iron-E)
* Repository: https://github.com/nvim-highlite
* Repository: https://github.com/Iron-E/nvim-highlite
Rewrite of RNB, a Vim colorsheme template.
* Author: Romain Lafourcade (https://github.com/romainl)
@ -79,6 +79,7 @@ local highlight_groups = {
Operator = {bg=NONE, fg=pink, style=NONE },
Keyword = {bg=NONE, fg=pink, style='bold' },
Exception = {bg=NONE, fg=red, style='bold' },
Noise = 'Delimiter',
--[[ 4.1.4. Metatextual Information]]
PreProc = {bg=NONE, fg=green, style=NONE },
@ -221,11 +222,40 @@ local highlight_groups = {
cppSTLnamespace = {link='String' },
--[[ 4.3.3 C# ]]
csLogicSymbols = {link='Operator'},
csBraces = 'Delimiter',
csClass = 'Structure',
csClassType = 'Type',
csContextualStatement = 'Conditional',
csEndColon = 'Delimiter',
csLogicSymbols = 'Operator',
csModifier = 'Keyword',
csNew = 'Operator',
csNewType = 'Type',
csParens = 'Delimiter',
csPreCondit = 'PreProc',
csRepeat = 'Repeat',
csStorage = 'StorageClass',
csUnspecifiedStatement = 'Statement',
csXmlTag = 'Define',
csXmlTagName = 'Define',
--[[ 4.3.4. CSS ]]
cssProp = {link='Keyword'},
cssTagName = {link='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',
--[[ 4.3.5. Dart ]]
dartLibrary = {link='Statement'},
@ -258,9 +288,21 @@ local highlight_groups = {
goVarDefs = {link='goVarAssign' },
--[[ 4.3.8. HTML ]]
htmlBold = {bg=NONE, fg=NONE, style='bold' },
htmlArg = 'Label',
htmlBold = {bg=NONE, fg=lightgrey, style='bold'},
htmlTitle = 'htmlBold',
htmlEndTag = 'htmlTag',
htmlH1 = 'markdownH1',
htmlH2 = 'markdownH2',
htmlH3 = 'markdownH3',
htmlH4 = 'markdownH4',
htmlH5 = 'markdownH5',
htmlH6 = 'markdownH6',
htmlItalic = {bg=NONE, fg=NONE, style='italic'},
htmlSpecialTagName = {link='Tag' },
htmlSpecialTagName = 'Keyword',
htmlTag = 'Special',
htmlTagN = 'Typedef',
htmlTagName = 'Type',
--[[ 4.3.9. Java ]]
javaClassDecl = {link='Structure'},
@ -272,7 +314,12 @@ local highlight_groups = {
jsVariableDef = {link='Identifier'},
--[[ 4.3.11. JSON ]]
jsonStringSQError = {link='Exception'},
jsonBraces = 'luaBraces',
jsonKeywordMatch = 'Delimiter',
jsonNull = 'Constant',
jsonQuote = 'String',
jsonString = 'Normal',
jsonStringSQError = 'Exception',
--[[ 4.3.12. Make ]]
makeCommands = {link='Statment'},
@ -370,6 +417,23 @@ local highlight_groups = {
haskellImportKeywords = {link='Include' },
haskellStatement = {link='Statement' },
--[[ 4.3.30 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',
--[[ 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 vim = vim
-- Clear the highlighting.
vim.cmd('hi clear')
@ -36,55 +37,48 @@ local function get(color, index)
end
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 = use_hex_and_256 and function(command, attributes) command[#command + 1] =
' ctermbg='..get(attributes.bg, BIT_256)
..' ctermfg='..get(attributes.fg, BIT_256)
..' guibg='..get(attributes.bg, HEX)
..' guifg='..get(attributes.fg, HEX)
end or function(command, attributes) command[#command + 1] =
' ctermbg='..get(attributes.bg, BIT_16)
..' ctermfg='..get(attributes.fg, BIT_16)
end
-- This function appends `selected_attributes` to the end of `highlight_cmd`.
local stylize = use_hex_and_256 and function(command, attributes)
command[#command + 1] = ' cterm='..attributes..' gui='..attributes
end or function(command, attributes)
command[#command + 1] = ' cterm='..attributes
end
-- Generate a `:highlight` command from a group and some attributes.
local function highlight(highlight_group, attributes) -- {{{ †
local highlight_cmd = {'hi! ', highlight_group}
local link = attributes.link
local link = (type(attributes) == 'string' and attributes)
or attributes.link
-- If the `highlight_group` is a link to another group.
if attributes.link then
highlight_cmd[3] = highlight_cmd[2] .. ' '
if link then -- `highlight_group` is a link to another group.
highlight_cmd[3] = highlight_cmd[2]..' '
highlight_cmd[2] = 'link '
highlight_cmd[4] = attributes.link
highlight_cmd[4] = link
else -- the `highlight_group` is uniquely defined.
local bg = attributes.bg
local fg = attributes.fg
colorize(highlight_cmd, attributes)
local style = attributes.style
-- If using hex and 256-bit colors, then populate the gui* and cterm* args.
if use_hex_and_256 then highlight_cmd[#highlight_cmd + 1] =
' ctermbg=' .. get(bg, BIT_256)
.. ' ctermfg=' .. get(fg, BIT_256)
.. ' guibg=' .. get(bg, HEX)
.. ' guifg=' .. get(fg, HEX)
-- If using 16-bit colors, just populate the cterm* args.
else highlight_cmd[#highlight_cmd + 1] =
' ctermbg=' .. get(bg, BIT_16)
.. ' ctermfg=' .. get(fg, BIT_16)
end
-- This function appends `selected_attributes` to the end of the `highlight_cmd`.
local function append_style(selected_attributes)
highlight_cmd[#highlight_cmd + 1] = ' cterm=' .. selected_attributes
-- If we're using hex populate the gui* attr args.
if use_hex_and_256 then highlight_cmd[#highlight_cmd + 1] =
' gui=' .. selected_attributes
end
end
if type(style) == 'table' then
-- Concat all of the entries together with a comma between.
local style_all = table.concat(style, ',')
-- Concat all of the entries together with a comma between before styling.
stylize(highlight_cmd, table.concat(style, ','))
-- There will always be a cterm attr arg.
append_style(style_all)
-- There won't always be a `guisp`.
if style.color then highlight_cmd[#highlight_cmd + 1] =
' guisp=' .. get(style.color, HEX)
if style.color then -- there won't is a color for undercurl.
highlight_cmd[#highlight_cmd + 1] = ' guisp='..get(style.color, HEX)
end
else append_style(style)
else -- just style the single entry.
stylize(highlight_cmd, style)
end
end
@ -102,6 +96,6 @@ return function(Normal, highlights, terminal_ansi_colors)
-- Set the terminal colors.
for index, color in ipairs(terminal_ansi_colors) do
vim.g['terminal_color_' .. index] = get(color, HEX)
vim.g['terminal_color_'..index] = color[HEX] or color[BIT_256] or color[BIT_16]
end
end