Merge branch 'feature/light-themes' into integration
This commit is contained in:
commit
0300352b3e
|
@ -5,7 +5,7 @@ lua << EOF
|
||||||
* Author: Iron-E (https://github.com/Iron-E)
|
* Author: Iron-E (https://github.com/Iron-E)
|
||||||
* Repository: https://github.com/nvim-highlite
|
* Repository: https://github.com/nvim-highlite
|
||||||
|
|
||||||
Rewrite of RNB, a Vim colorsheme template.
|
Initially forked from vim-rnb, a Vim colorsheme template:
|
||||||
* Author: Romain Lafourcade (https://github.com/romainl)
|
* Author: Romain Lafourcade (https://github.com/romainl)
|
||||||
* Canonical URL: https://github.com/romainl/vim-rnb
|
* Canonical URL: https://github.com/romainl/vim-rnb
|
||||||
]]
|
]]
|
||||||
|
@ -35,8 +35,8 @@ lua << EOF
|
||||||
| colorscheme name | module name | template filename |
|
| colorscheme name | module name | template filename |
|
||||||
|:-----------------:|:-----------:|:-----------------:|
|
|:-----------------:|:-----------:|:-----------------:|
|
||||||
| foobar | foobar | foobar.lua |
|
| foobar | foobar | foobar.lua |
|
||||||
| foo-bar | foo_bar | foo-bar.lua |
|
| foo-bar | foo_bar | foo_bar.lua |
|
||||||
| foo bar | foo_bar | foo-bar.lua or |
|
| foo bar | foo_bar | foo_bar.lua |
|
||||||
| foo_bar | foo_bar | foo_bar.lua |
|
| foo_bar | foo_bar | foo_bar.lua |
|
||||||
|
|
||||||
Rename the following files:
|
Rename the following files:
|
||||||
|
@ -44,13 +44,23 @@ lua << EOF
|
||||||
* `lua/highlite.lua`
|
* `lua/highlite.lua`
|
||||||
|
|
||||||
Where 'highlite' is the name of your colorscheme.
|
Where 'highlite' is the name of your colorscheme.
|
||||||
|
|
||||||
|
TIP: If you are on a Unix-based system (or have WSL on Windows) you can use the setup script at the root of this repo.
|
||||||
|
See the README for more details.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
||||||
--[[ Step 2: Information
|
--[[ Step 2: Information
|
||||||
This is the name of your colorscheme which will be used as per |g:colors_name|.
|
In this step you will define information that helps Neovim process:
|
||||||
|
|
||||||
|
1. How users access your colorscheme;
|
||||||
|
2. How your colorscheme should be rendered.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
-- This is the name of your colorscheme which will be used as per |g:colors_name|.
|
||||||
vim.g.colors_name = 'highlite'
|
vim.g.colors_name = 'highlite'
|
||||||
|
-- This is the kind of colorscheme you are creating. Either 'light' or 'dark'
|
||||||
|
vim.o.background = 'dark'
|
||||||
|
|
||||||
--[[ Step 3: Colors
|
--[[ Step 3: Colors
|
||||||
Next you will define all of the colors that you will use for the color scheme.
|
Next you will define all of the colors that you will use for the color scheme.
|
||||||
|
@ -60,8 +70,8 @@ vim.g.colors_name = 'highlite'
|
||||||
```lua
|
```lua
|
||||||
<color name> = { -- Give each color a distinctive name.
|
<color name> = { -- Give each color a distinctive name.
|
||||||
'#<hex color code>', -- Hexadecimal color used in GVim/MacVim or 'NONE'.
|
'#<hex color code>', -- Hexadecimal color used in GVim/MacVim or 'NONE'.
|
||||||
<256-bit color code>, -- Integer 0–255 used by terminals supporting 256 colors or 'NONE'.
|
<16-bit color code>, -- Integer 0–255 used by terminals supporting 256 colors or 'NONE'.
|
||||||
'<16-bit color code>' -- color name used by less capable color terminals, can be 'darkred',
|
'<ANSI color name>' -- color name used by less capable color terminals, can be 'darkred',
|
||||||
'red', 'darkgreen', 'green', 'darkyellow', 'yellow', 'darkblue',
|
'red', 'darkgreen', 'green', 'darkyellow', 'yellow', 'darkblue',
|
||||||
'blue', 'darkmagenta', 'magenta', 'black', 'darkgrey', 'grey',
|
'blue', 'darkmagenta', 'magenta', 'black', 'darkgrey', 'grey',
|
||||||
'white', or 'NONE'
|
'white', or 'NONE'
|
||||||
|
@ -75,7 +85,7 @@ vim.g.colors_name = 'highlite'
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local black = {'#202020', 0, 'black'}
|
local black = {'#202020', 0, 'black'}
|
||||||
local gray = {'#808080', 244, 'gray' }
|
local gray = {'#808080', 244, 'gray'}
|
||||||
local gray_dark = {'#353535', 236, 'darkgrey'}
|
local gray_dark = {'#353535', 236, 'darkgrey'}
|
||||||
local gray_darker = {'#505050', 244, 'gray'}
|
local gray_darker = {'#505050', 244, 'gray'}
|
||||||
local gray_light = {'#c0c0c0', 251, 'gray'}
|
local gray_light = {'#c0c0c0', 251, 'gray'}
|
||||||
|
@ -114,31 +124,32 @@ local purple_light = {'#af60af', 63, 'magenta'}
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
<highlight group name> = {
|
<highlight group name> = {
|
||||||
bg=<color>, -- The color used for background color, or use 'NONE', 'fg' or 'bg'
|
bg=<color>, -- The color used for background color, or use `NONE`, `FG` or `BG`
|
||||||
fg=<color>, -- The color used for foreground color, or use 'NONE', 'fg' or 'bg'
|
fg=<color>, -- The color used for foreground color, or use `NONE`, `FG` or `BG`
|
||||||
blend=<integer> -- The |highlight-blend| value, if one is desired.
|
blend=<integer> -- The |highlight-blend| value, if one is desired.
|
||||||
-- Style can be 'bold', 'italic', and more. See |attr-list| for more information. It can also have a color, and/or multiple <cterm>s.
|
-- Style can be 'bold', 'italic', and more. See |attr-list| for more information. It can also have a color, and/or multiple <cterm>s.
|
||||||
style=<cterm>|{<cterm> [, <cterm>] [color=<color>]})
|
style=<cterm>|{<cterm> [, <cterm>] [color=<color>]})
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Or you can link an highlight group to another.
|
You can also link one highlight group to another:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
<highlight group name> = '<highlight group name>'
|
<highlight group name> = '<highlight group name>'
|
||||||
```
|
```
|
||||||
|
|
||||||
Here is an example:
|
Here is an example to define `SpellBad` and then link some new group `SpellWorse` to it:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
SpellBad = { -- ← name of the highlight group
|
SpellBad = { -- ← name of the highlight group
|
||||||
bg='NONE', -- background color
|
bg=NONE, -- background color
|
||||||
fg=red, -- foureground color
|
fg=red, -- foureground color
|
||||||
style={ -- the style
|
style={ -- the style
|
||||||
'undercurl', -- undercurl (squiggly line)
|
'undercurl', -- undercurl (squiggly line)
|
||||||
color=red -- the color of the undercurl
|
color=red -- the color of the undercurl
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
SpellWorse = 'SpellBad'
|
||||||
```
|
```
|
||||||
|
|
||||||
If you weren't satisfied with undercurl, and also wanted another effect, you can
|
If you weren't satisfied with undercurl, and also wanted another effect, you can
|
||||||
|
@ -164,7 +175,7 @@ local purple_light = {'#af60af', 63, 'magenta'}
|
||||||
NOTE: |Replace-mode| will probably be useful here.
|
NOTE: |Replace-mode| will probably be useful here.
|
||||||
|
|
||||||
NOTE: /As long as you do not remove any highlight groups or colors/, you can safely
|
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.
|
ignore any highlight groups that are `link`ed to others.
|
||||||
For example, programming languages almost exclusively link to the 1st
|
For example, programming languages almost exclusively link to the 1st
|
||||||
and 2nd sections, so as long as you define everything there you will automatically
|
and 2nd sections, so as long as you define everything there you will automatically
|
||||||
be defining the rest of the highlights, which is one of the benefits of using
|
be defining the rest of the highlights, which is one of the benefits of using
|
||||||
|
|
|
@ -4,9 +4,6 @@ local vim = vim
|
||||||
-- Clear the highlighting.
|
-- Clear the highlighting.
|
||||||
vim.cmd('hi clear')
|
vim.cmd('hi clear')
|
||||||
|
|
||||||
-- Set the background to dark.
|
|
||||||
vim.o.background = 'dark'
|
|
||||||
|
|
||||||
-- Disable automatic coloring for the IndentGuides plugin.
|
-- Disable automatic coloring for the IndentGuides plugin.
|
||||||
vim.g.indent_guides_auto_colors = 0
|
vim.g.indent_guides_auto_colors = 0
|
||||||
|
|
||||||
|
@ -14,17 +11,19 @@ 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 use_hex_and_256 = string.find(vim.fn.expand('$TERM'), '256')
|
local using_hex_or_256 = tonumber(vim.o.t_Co) >= 256
|
||||||
or vim.g.t_Co >= 256
|
or vim.o.termguicolors
|
||||||
or vim.fn.has('gui_running')
|
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 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 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 BIT_16 = 3
|
local PALETTE_ANSI = 3
|
||||||
local BIT_256 = 2
|
local PALETTE_256 = 2
|
||||||
local HEX = 1
|
local PALETTE_HEX = 1
|
||||||
|
local NONE = "NONE"
|
||||||
|
|
||||||
-- 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)
|
||||||
|
@ -33,24 +32,24 @@ local function get(color, index)
|
||||||
elseif type(color) == 'string' then
|
elseif type(color) == 'string' then
|
||||||
return color
|
return color
|
||||||
else
|
else
|
||||||
return "NONE"
|
return NONE
|
||||||
end
|
end
|
||||||
end
|
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 = use_hex_and_256 and function(command, attributes) command[#command + 1] =
|
local colorize = using_hex_or_256 and function(command, attributes) command[#command + 1] =
|
||||||
' ctermbg='..get(attributes.bg, BIT_256)
|
' ctermbg='..get(attributes.bg, PALETTE_256)
|
||||||
..' ctermfg='..get(attributes.fg, BIT_256)
|
..' ctermfg='..get(attributes.fg, PALETTE_256)
|
||||||
..' guibg='..get(attributes.bg, HEX)
|
..' guibg='..get(attributes.bg, PALETTE_HEX)
|
||||||
..' guifg='..get(attributes.fg, HEX)
|
..' guifg='..get(attributes.fg, PALETTE_HEX)
|
||||||
end or function(command, attributes) command[#command + 1] =
|
end or function(command, attributes) command[#command + 1] =
|
||||||
' ctermbg='..get(attributes.bg, BIT_16)
|
' ctermbg='..get(attributes.bg, PALETTE_ANSI)
|
||||||
..' ctermfg='..get(attributes.fg, BIT_16)
|
..' ctermfg='..get(attributes.fg, PALETTE_ANSI)
|
||||||
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 = use_hex_and_256 and function(command, attributes)
|
local stylize = using_hex_or_256 and function(command, attributes)
|
||||||
command[#command + 1] = ' cterm='..attributes..' gui='..attributes
|
command[#command + 1] = ' cterm='..attributes..' gui='..attributes
|
||||||
end or function(command, attributes)
|
end or function(command, attributes)
|
||||||
command[#command + 1] = ' cterm='..attributes
|
command[#command + 1] = ' cterm='..attributes
|
||||||
|
@ -73,13 +72,13 @@ local function highlight(highlight_group, attributes) -- {{{ †
|
||||||
highlight_cmd[#highlight_cmd + 1] = ' blend='..attributes.blend
|
highlight_cmd[#highlight_cmd + 1] = ' blend='..attributes.blend
|
||||||
end
|
end
|
||||||
|
|
||||||
local style = attributes.style
|
local style = attributes.style or NONE
|
||||||
if type(style) == 'table' then
|
if type(style) == 'table' then
|
||||||
-- Concat all of the entries together with a comma between before styling.
|
-- Concat all of the entries together with a comma between before styling.
|
||||||
stylize(highlight_cmd, table.concat(style, ','))
|
stylize(highlight_cmd, table.concat(style, ','))
|
||||||
|
|
||||||
if style.color then -- there won't is a color for undercurl.
|
if style.color then -- there won't is a color for undercurl.
|
||||||
highlight_cmd[#highlight_cmd + 1] = ' guisp='..get(style.color, HEX)
|
highlight_cmd[#highlight_cmd + 1] = ' guisp='..get(style.color, PALETTE_HEX)
|
||||||
end
|
end
|
||||||
else -- just style the single entry.
|
else -- just style the single entry.
|
||||||
stylize(highlight_cmd, style)
|
stylize(highlight_cmd, style)
|
||||||
|
@ -99,7 +98,7 @@ return function(Normal, highlights, terminal_ansi_colors)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set the terminal colors.
|
-- Set the terminal colors.
|
||||||
for index, color in ipairs(terminal_ansi_colors) do
|
if using_hex_or_256 then for index, color in ipairs(terminal_ansi_colors) do
|
||||||
vim.g['terminal_color_'..index] = color[HEX] or color[BIT_256] or color[BIT_16]
|
vim.g['terminal_color_'..index] = vim.o.termguicolors and color[PALETTE_HEX] or color[PALETTE_256]
|
||||||
end
|
end end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue