Fix several mistakes; update readme
This commit is contained in:
parent
5f89cc8da0
commit
03e2382a30
|
@ -4,13 +4,15 @@
|
||||||
|
|
||||||
This template's focus is on compatability with [semantic highlighting](https://medium.com/@evnbr/coding-in-color-3a6db2743a1e).
|
This template's focus is on compatability with [semantic highlighting](https://medium.com/@evnbr/coding-in-color-3a6db2743a1e).
|
||||||
|
|
||||||
|
It provides a large supply of defaults for plugins and programming languages as a result of defining a smaller set of "categorical" highlights (you can read more about this at Neovim's `group-name` help page).
|
||||||
|
|
||||||
# Prerequisites
|
# Prerequisites
|
||||||
|
|
||||||
1. Neovim 0.5+
|
1. Neovim 0.5+
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
Usage is simple. This repository should be cloned with `git clone https://github.com/Iron-E/nvim-highlite`, and then:
|
This repository should be cloned with `git clone https://github.com/Iron-E/nvim-highlite`, and then:
|
||||||
|
|
||||||
1. Rename `lua/highlite/` to `lua/<name of your colorscheme>/`.
|
1. Rename `lua/highlite/` to `lua/<name of your colorscheme>/`.
|
||||||
2. Follow the directions in [lua/`<name of your colorscheme>`/init.lua](lua/highlite/init.lua).
|
2. Follow the directions in [lua/`<name of your colorscheme>`/init.lua](lua/highlite/init.lua).
|
||||||
|
|
|
@ -1,93 +1,96 @@
|
||||||
--[[ NOTHING IN THIS FILE NEEDS TO BE EDITED BY THE USER. ]]
|
--[[ NOTHING IN THIS FILE NEEDS TO BE EDITED BY THE USER. ]]
|
||||||
|
|
||||||
return function(name, Normal, highlights, terminal_ansi_colors)
|
-- Clear the highlighting.
|
||||||
-- Clear the highlighting.
|
vim.cmd('hi clear')
|
||||||
vim.cmd('hi clear')
|
|
||||||
|
|
||||||
-- If the syntax has been enabled, reset it.
|
vim.o.background = 'dark'
|
||||||
if vim.fn.exists('syntax_on') then vim.cmd('syntax reset') end
|
vim.g.indent_guides_auto_colors = 0
|
||||||
|
|
||||||
-- Set the name of the current colorscheme.
|
-- If the syntax has been enabled, reset it.
|
||||||
vim.g.colors_name = string.lower(name)
|
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 use_hex_and_256 = string.find(vim.fn.expand('$TERM'), '256')
|
local use_hex_and_256 = string.find(vim.fn.expand('$TERM'), '256')
|
||||||
or vim.g.t_Co >= 256
|
or vim.g.t_Co >= 256
|
||||||
or vim.fn.has("gui_running")
|
or vim.fn.has("gui_running")
|
||||||
|
|
||||||
-- 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 use_hex_and_256 then vim.g.t_Co = 16 end
|
if not use_hex_and_256 then vim.g.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 BIT_16 = 3
|
local BIT_16 = 3
|
||||||
local BIT_256 = 2
|
local BIT_256 = 2
|
||||||
local HEX = 1
|
local HEX = 1
|
||||||
|
|
||||||
-- Get the color value of a color variable, or "NONE" as a default.
|
-- Get the color value of a color variable, or "NONE" as a default.
|
||||||
local function get(color, index)
|
local function get(color, index)
|
||||||
if type(color) == 'table' and color[index] then
|
if type(color) == 'table' and color[index] then
|
||||||
return color[index]
|
return color[index]
|
||||||
elseif type(color) == 'string' then
|
elseif type(color) == 'string' then
|
||||||
return color
|
return color
|
||||||
else
|
else
|
||||||
return "NONE"
|
return "NONE"
|
||||||
|
end
|
||||||
|
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
|
||||||
|
|
||||||
|
-- If the `highlight_group` is a link to another group.
|
||||||
|
if attributes.link then
|
||||||
|
highlight_cmd[3] = highlight_cmd[2] .. ' '
|
||||||
|
highlight_cmd[2] = 'link '
|
||||||
|
highlight_cmd[4] = attributes.link
|
||||||
|
else -- the `highlight_group` is uniquely defined.
|
||||||
|
local bg = attributes.bg
|
||||||
|
local fg = attributes.fg
|
||||||
|
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, ',')
|
||||||
|
|
||||||
|
-- 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)
|
||||||
|
end
|
||||||
|
else append_style(style)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Generate a `:highlight` command from a group and some attributes.
|
vim.cmd(table.concat(highlight_cmd))
|
||||||
local function highlight(highlight_group, attributes) -- {{{ †
|
end --}}} ‡
|
||||||
local highlight_cmd = {'hi! ', highlight_group}
|
|
||||||
local link = attributes.link
|
|
||||||
|
|
||||||
-- If the `highlight_group` is a link to another group.
|
return function(name, Normal, highlights, terminal_ansi_colors)
|
||||||
if attributes.link then
|
-- Set the name of the current colorscheme.
|
||||||
highlight_cmd[3] = highlight_cmd[2] .. ' '
|
vim.g.colors_name = string.lower(name)
|
||||||
highlight_cmd[2] = 'link '
|
|
||||||
highlight_cmd[4] = attributes.link
|
|
||||||
else -- the `highlight_group` is uniquely defined.
|
|
||||||
local bg = attributes.bg
|
|
||||||
local fg = attributes.fg
|
|
||||||
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`.
|
|
||||||
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, ',')
|
|
||||||
|
|
||||||
-- 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)
|
|
||||||
end
|
|
||||||
else append_style(style)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.cmd(table.concat(highlight_cmd))
|
|
||||||
end --}}} ‡
|
|
||||||
|
|
||||||
-- Highlight the baseline.
|
-- Highlight the baseline.
|
||||||
highlight('Normal', Normal)
|
highlight('Normal', Normal)
|
||||||
|
@ -101,7 +104,4 @@ return function(name, Normal, highlights, terminal_ansi_colors)
|
||||||
for index, color in ipairs(terminal_ansi_colors) do
|
for index, color in ipairs(terminal_ansi_colors) do
|
||||||
vim.g['terminal_color_' .. index] = color[HEX]
|
vim.g['terminal_color_' .. index] = color[HEX]
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.o.background = 'dark'
|
|
||||||
vim.g.indent_guides_auto_colors = 0
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -65,6 +65,8 @@ local name = 'highlite'
|
||||||
|
|
||||||
If your colors are defined correctly, the resulting colorscheme is guaranteed
|
If your colors are defined correctly, the resulting colorscheme is guaranteed
|
||||||
to work in GVim (Windows/Linux), MacVim (MacOS), and any properly set up terminal emulator.
|
to work in GVim (Windows/Linux), MacVim (MacOS), and any properly set up terminal emulator.
|
||||||
|
|
||||||
|
NOTE: |Replace-mode| will probably be useful here.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local black = {'#202020', 0, 'black'}
|
local black = {'#202020', 0, 'black'}
|
||||||
|
@ -164,6 +166,14 @@ local purple_dark = {'#c700ff', 38, 'darkmagenta'}
|
||||||
remove any if you want a working colorscheme. Most of them are described under
|
remove any if you want a working colorscheme. Most of them are described under
|
||||||
:help highlight-default, the others are taken from :help group-name. Both help sections
|
:help highlight-default, the others are taken from :help group-name. Both help sections
|
||||||
are good reads, by the way.
|
are good reads, by the way.
|
||||||
|
|
||||||
|
NOTE: |Replace-mode| will probably be useful here.
|
||||||
|
|
||||||
|
NOTE: /As long as you do not remove any highlight groups or colors/, you can safely
|
||||||
|
ignore any highlight groups that are `link`ed others.
|
||||||
|
For example, programming languages almost exclusively link to the 1st
|
||||||
|
and 2nd sections, so as long as you define everything there you will automatically
|
||||||
|
be defining the rest of the highlights.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
--[[ DO NOT EDIT THESE. You can use them instead of string literals. ]]
|
--[[ DO NOT EDIT THESE. You can use them instead of string literals. ]]
|
||||||
|
@ -222,7 +232,7 @@ local highlights = {
|
||||||
SpecialChar = {link='Character' },
|
SpecialChar = {link='Character' },
|
||||||
SpecialKey = {link='Character' },
|
SpecialKey = {link='Character' },
|
||||||
Tag = {link='Underlined' },
|
Tag = {link='Underlined' },
|
||||||
Delimiter = {bg=NONE, fg=gray, style=NONE },
|
Delimiter = {link='Normal' },
|
||||||
SpecialComment = {bg=NONE, fg=gray, style={'bold', 'nocombine'}},
|
SpecialComment = {bg=NONE, fg=gray, style={'bold', 'nocombine'}},
|
||||||
Debug = {link='WarningMsg' },
|
Debug = {link='WarningMsg' },
|
||||||
|
|
||||||
|
@ -380,20 +390,21 @@ local highlights = {
|
||||||
makeSpecTarget = {link='Type' },
|
makeSpecTarget = {link='Type' },
|
||||||
|
|
||||||
--[[ 4.3.13. Markdown ]]
|
--[[ 4.3.13. Markdown ]]
|
||||||
markdownH1 = {bg=NONE, fg=green_dark, style='bold' },
|
markdownH1 = {bg=NONE, fg=green_dark, style='bold' },
|
||||||
markdownH2 = {bg=NONE, fg=red_light, style='bold' },
|
markdownH2 = {bg=NONE, fg=red_light, style='bold' },
|
||||||
markdownH3 = {bg=NONE, fg=green, style='bold' },
|
markdownH3 = {bg=NONE, fg=green, style='bold' },
|
||||||
markdownH4 = {bg=NONE, fg=magenta, style='bold' },
|
markdownH4 = {bg=NONE, fg=magenta, 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' },
|
||||||
htmlBold = {link='mkdBold' },
|
htmlBold = {link='mkdBold' },
|
||||||
htmlItalic = {link='mkdItalic' },
|
htmlItalic = {link='mkdItalic' },
|
||||||
mkdBold = {bg=NONE, fg='green', style='bold' },
|
mkdBold = {bg=NONE, fg='green', style='bold' },
|
||||||
mkdCode = {link='Comment' },
|
mkdCode = {link='Comment' },
|
||||||
mkdCodeDelimiter = {link='Delimiter' },
|
mkdCodeDelimiter = {link='Delimiter' },
|
||||||
mkdItalic = {bg=NONE, fg=green, style='italic'},
|
mkdItalic = {bg=NONE, fg=green, style='italic'},
|
||||||
mkdListItem = {link='Special' },
|
mkdListItem = {link='Special' },
|
||||||
texMathZoneY = {link='String' },
|
mkdNonListItemBlock = {bg=NONE, fg=gray, style=NONE },
|
||||||
|
texMathZoneY = {link='String' },
|
||||||
|
|
||||||
--[[ 4.3.20. Python ]]
|
--[[ 4.3.20. Python ]]
|
||||||
pythonBrackets = {link='Delimiter' },
|
pythonBrackets = {link='Delimiter' },
|
||||||
|
|
Loading…
Reference in New Issue