Update directions

This commit is contained in:
Iron_E 2020-06-19 20:49:05 -04:00
parent 7259ab9df3
commit 87eacb946c
No known key found for this signature in database
GPG Key ID: B0B37DE7EDC2335F
7 changed files with 569 additions and 438 deletions

29
LICENSE
View File

@ -1,21 +1,16 @@
MIT License nvim-highlite A colorscheme template for Neovim.
Copyright © 2020 Iron-E
Copyright (c) 2019 Romain Lafourcade This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Permission is hereby granted, free of charge, to any person obtaining a copy This program is distributed in the hope that it will be useful,
of this software and associated documentation files (the "Software"), to deal but WITHOUT ANY WARRANTY; without even the implied warranty of
in the Software without restriction, including without limitation the rights MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell GNU General Public License for more details.
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all You should have received a copy of the GNU General Public License
copies or substantial portions of the Software. along with this program. If not, see <http://www.gnu.org/licenses/>.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,16 +0,0 @@
####### ## ## #######
## ## ### ## ## ##
## ## #### ## ## ##
####### ## ## ## #######
## ## ## #### ## ##
## ## ## ### ## ##
## ## ## ## #######
VIM_OUTPUTS = $(patsubst %.erb,%.vim,$(wildcard colors/*.erb))
.PHONY: all
all: $(VIM_OUTPUTS)
%.vim: %.erb
erb -T - $< > $@

View File

@ -1,51 +1,30 @@
# Vim-RNB, a Vim colorscheme template # Introduction
## What is this thing? `nvim-highlite` is a colorscheme template repository for Neovim 0.5+.
RNB is a template designed to help vimmers create their own colorschemes without much effort. This project aims to make the following
In reality, Vim colorschemes are not that hard to write but there are several benefits to using a template such as RNB: * You can define/modify variables once instead of messing around with potentially botched substitutions.
* You can distribute a lean colorscheme, free from unnecessary logic.
* You can distribute the source alongside the colorscheme, making it easy for your users to experiment and adapt *your* colorscheme to *their* needs.
* You can focus on the design of your colorscheme rather than its implementation.
* You can start working on new colorscheme ideas very easily.
* you can define/modify variables once instead of messing around with potentially botched substitutions, # Prerequisites
* you can distribute a lean colorscheme, free from unnecessary logic,
* you can distribute the source alongside the colorscheme, making it easy for your users to experiment and adapt *your* colorscheme to *their* needs,
* you can focus on the design of your colorscheme rather than its implementation,
* you can start working on new colorscheme ideas very easily.
## What do I need to use it? 1. Neovim 0.5+
[ERB](https://ruby-doc.org/stdlib-2.6.3/libdoc/erb/rdoc/index.html), the templating engine used here, is part of Ruby's standard library so you will need [Ruby](https://www.ruby-lang.org/) to generate your colorscheme. Neither ERB nor Ruby knowledge is required, though. # Usage
## How do I use it? Usage is simple. This repository should be cloned with `git clone https://github.com/Iron-E/nvim-highlite`, and then:
The process is divided in five steps: 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).
3. Rename `colors/highlite.vim` to `colors/<name of your colorscheme>.vim`.
4. Follow the instructions in [`colors/highlite.vim`](colors/highlite.vim).
1. rename `colors/rnb.erb` to `colors/name_of_your_colorscheme.erb`, ## Examples
2. start by editing your colorscheme's information,
3. define your colors,
4. define your highlight groups and links,
5. and generate your colorscheme.
Steps 2 to 5 are thoroughly described in the colorscheme template itself in an effort to make it portable: if you ever decide to distribute your colorscheme you can simply package the template with it. The following colorschemes are built using `nvim-highlite`:
## Built with RNB * (if you use this, open an issue and I'll add it here!)
The following colorschemes are known to be built with RNB:
* [Apprentice](https://github.com/romainl/Apprentice)
* [Dichromatic](https://github.com/romainl/vim-dichromatic)
* [Bruin](https://git.sr.ht/~romainl/vim-bruin)
* [Sweet16](https://github.com/romainl/vim-sweet16)
* [Paper](https://github.com/swalladge/paper.vim)
* [Journeyman](https://github.com/markeganfuller/vim-journeyman)
* [Warlock](https://github.com/hardselius/warlock)
* [Cyberpunk-Neon](https://github.com/Roboron3042/Cyberpunk-Neon)
* [Tutfish](https://github.com/benwr/tuftish)
* (your colorscheme here, send us a PR!)
## TODO
* `README.md` template
[//]: # ( Vim: set spell spelllang=en: )

2
colors/highlite.vim Normal file
View File

@ -0,0 +1,2 @@
" Change 'highlite' to the name of the file in the `lua/` folder.
lua require('highlite')

View File

@ -1,365 +0,0 @@
<%
# RNB, A VIM COLORSCHEME TEMPLATE
# Author: Romain Lafourcade (https://github.com/romainl)
# Canonical URL: https://github.com/romainl/vim-rnb
# This template is designed to help vimmers create their own colorschemes
# without much effort.
#
# You will need Ruby to generate your colorscheme but Ruby knowledge is
# not needed at all.
#
# The process is divided in five steps:
# 1. rename the template,
# 2. edit your colorscheme's information,
# 3. define your colors,
# 4. define your highlight groups and links,
# 5. and generate your colorscheme.
# Step 1: renaming
#
# If this file is distributed with a colorscheme it's probably already named correctly
# and you can skip this step.
#
# If you forked/cloned/copied this repository to create your own colorscheme, you will have to
# rename this template to match the name of your colorscheme.
#
# NOTE: Vim doesn't really care about whitespace in the name of the colorscheme but it does for
# filenames so make sure your filename doesn't have any whitespace character.
#
# colorscheme name | template filename | colorscheme filename
# ------------------|-------------------|----------------------
# foobar | foobar.erb | foobar.vim
# foo-bar | foo-bar.erb | foo-bar.vim
# foo_bar | foo_bar.erb | foo_bar.vim
# foo bar | foo-bar.erb or | foo-bar.vim or
# | foo_bar.erb | foo_bar.vim
# Step 2: information
#
# Make sure the name of your colorscheme is unique and attractive.
# The description should fit in a single line with no linefeed.
information = {
author: "foo",
email: "foo@foo.foo",
name: "rnb",
description: "Lorem ipsum dolor sit amet.",
webpage: "http://www.example.com"
}
# Step 3: colors
#
# black = [ give each color a distinctive name
# "#000000", hexadecimal color used in GVim/MacVim or "NONE"
# 0, integer between 0 and 255 used by terminals supporting 256 colors
# or "NONE"
# "black" color name used by less capable color terminals, can be "darkred",
# "red", "darkgreen", "green", "darkyellow", "yellow", "darkblue",
# "blue", "darkmagenta", "magenta", "black", "darkgrey", "grey",
# "white", or "NONE"
# ]
#
# 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.
black = ["#000000", 0, "black"]
darkred = ["#800000", 1, "darkred"]
darkgreen = ["#008000", 2, "darkgreen"]
darkyellow = ["#808000", 3, "darkyellow"]
darkblue = ["#000080", 4, "darkblue"]
darkmagenta = ["#800080", 5, "darkmagenta"]
darkcyan = ["#008080", 6, "darkcyan"]
gray = ["#c0c0c0", 7, "gray"]
darkgray = ["#808080", 8, "darkgray"]
red = ["#ff0000", 9, "red"]
green = ["#00ff00", 10, "green"]
yellow = ["#ffff00", 11, "yellow"]
blue = ["#0000ff", 12, "blue"]
magenta = ["#ff00ff", 13, "magenta"]
cyan = ["#00ffff", 14, "cyan"]
white = ["#ffffff", 15, "white"]
# Step 4: highlights
#
# You can define highlight groups like this:
#
# [ "Normal", name of the highlight group
# white, the color used for background color, or use "NONE", "fg" or "bg"
# darkgray, the color used for foreground color, or use "NONE", "fg" or "bg"
# "NONE" style, can be "bold", "underline", "reverse", "italic",
# "standout", "NONE", "undercurl", or a comma-separated list of
# valid attributes like "underline,bold"
# ]
#
# The sample above tells Vim to render normal text in dark gray against a white
# background, without any other styling.
#
# Or you can link an highlight group to another. Here, "Title" will inherit its style from
# "Normal":
#
# [ "Title", "Normal" ]
#
# In GUI Vim, there is an additional color for the undercurl used to
# highlight spelling mistakes:
#
# [ "SpellBad", name of the highlight group
# "NONE", the color used for background color, or use "NONE", "fg" or "bg"
# red, the color used for foreground color, or use "NONE", "fg" or "bg"
# "undercurl", style
# red color used for the undercurl
# ]
#
# The sample above tells Vim to render badly spelled words in red against the current
# background, with a red undercurl.
#
# You can add any custom highlight group to the standard list below but you shouldn't
# 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
# are good reads, by the way.
highlights = [
[ "Normal", white, darkgray, "NONE" ],
[ "NonText", white, darkgray, "NONE" ],
[ "EndOfBuffer","NonText" ],
[ "Comment", white, darkgray, "NONE" ],
[ "Constant", white, darkgray, "NONE" ],
[ "Error", white, darkgray, "NONE" ],
[ "Identifier", white, darkgray, "NONE" ],
[ "Ignore", white, darkgray, "NONE" ],
[ "PreProc", white, darkgray, "NONE" ],
[ "Special", white, darkgray, "NONE" ],
[ "Statement", white, darkgray, "NONE" ],
[ "String", white, darkgray, "NONE" ],
[ "Number", "Constant" ],
[ "Todo", white, darkgray, "NONE" ],
[ "Type", white, darkgray, "NONE" ],
[ "Underlined", white, darkgray, "NONE" ],
[ "StatusLine", white, darkgray, "NONE" ],
[ "StatusLineNC", white, darkgray, "NONE" ],
[ "StatusLineTerm", "StatusLine" ],
[ "StatusLineTermNC", "StatusLineNC" ],
[ "VertSplit", white, darkgray, "NONE" ],
[ "TabLine", white, darkgray, "NONE" ],
[ "TabLineFill", white, darkgray, "NONE" ],
[ "TabLineSel", white, darkgray, "NONE" ],
[ "Title", white, darkgray, "NONE" ],
[ "CursorLine", white, darkgray, "NONE" ],
[ "LineNr", white, darkgray, "NONE" ],
[ "CursorLineNr", white, darkgray, "NONE" ],
[ "helpLeadBlank", white, darkgray, "NONE" ],
[ "helpNormal", white, darkgray, "NONE" ],
[ "Visual", white, darkgray, "NONE" ],
[ "VisualNOS", white, darkgray, "NONE" ],
[ "Pmenu", white, darkgray, "NONE" ],
[ "PmenuSbar", white, darkgray, "NONE" ],
[ "PmenuSel", white, darkgray, "NONE" ],
[ "PmenuThumb", white, darkgray, "NONE" ],
[ "FoldColumn", white, darkgray, "NONE" ],
[ "Folded", white, darkgray, "NONE" ],
[ "WildMenu", white, darkgray, "NONE" ],
[ "SpecialKey", white, darkgray, "NONE" ],
[ "DiffAdd", white, darkgray, "NONE" ],
[ "DiffChange", white, darkgray, "NONE" ],
[ "DiffDelete", white, darkgray, "NONE" ],
[ "DiffText", white, darkgray, "NONE" ],
[ "IncSearch", white, darkgray, "NONE" ],
[ "Search", white, darkgray, "NONE" ],
[ "Directory", white, darkgray, "NONE" ],
[ "MatchParen", white, darkgray, "NONE" ],
[ "SpellBad", white, darkgray, "NONE", red ],
[ "SpellCap", white, darkgray, "NONE", blue ],
[ "SpellLocal", white, darkgray, "NONE", magenta ],
[ "SpellRare", white, darkgray, "NONE", cyan ],
[ "ColorColumn", white, darkgray, "NONE" ],
[ "SignColumn", white, darkgray, "NONE" ],
[ "ErrorMsg", white, darkgray, "NONE" ],
[ "ModeMsg", white, darkgray, "NONE" ],
[ "MoreMsg", white, darkgray, "NONE" ],
[ "Question", white, darkgray, "NONE" ],
[ "WarningMsg", "Error" ],
[ "Cursor", white, darkgray, "NONE" ],
[ "CursorIM", "Cursor" ],
[ "CursorColumn", white, darkgray, "NONE" ],
[ "QuickFixLine", white, darkgray, "NONE" ],
[ "Terminal", "Normal" ],
[ "Conceal", white, darkgray, "NONE" ],
[ "ToolbarLine", white, darkgray, "NONE" ],
[ "ToolbarButton", white, darkgray, "NONE" ],
[ "debugPC", white, darkgray, "NONE" ],
[ "debugBreakpoint", white, darkgray, "NONE" ],
]
# Define the color palette used by :terminal when in GUI Vim
# or in TUI Vim when 'termguicolors' is enabled. If this list
# is empty or if it doesn't contain exactly 16 items, the corresponding
# Vim variable won't be set.
#
# The expected values are colors defined in step 3.
#
# Terminal emulators use a basic palette of 16 colors that can be
# addressed by CLI and TUI tools via their name or their index, from
# 0 to 15. The list is not really standardized but it is generally
# assumed to look like this:
#
# Index | Name
# -------|-------------
# 0 | black
# 1 | darkred
# 2 | darkgreen
# 3 | darkyellow
# 4 | darkblue
# 5 | darkmagenta
# 6 | darkcyan
# 7 | gray
# 8 | darkgray
# 9 | red
# 10 | green
# 11 | yellow
# 12 | blue
# 13 | magenta
# 14 | cyan
# 15 | white
#
# While you are certainly free to make colors 0 to 7 shades of blue,
# this will inevitably cause usability issues so… be careful.
terminal_ansi_colors = [
black,
darkred,
darkgreen,
darkyellow,
darkblue,
darkmagenta,
darkcyan,
gray,
darkgray,
red,
green,
yellow,
blue,
magenta,
cyan,
white
]
# Step 5: generation
#
# From a separate shell:
#
# $ erb -T - bar.erb > bar.vim
#
# From Vim:
#
# :!erb -T - % > %<.vim
#
# If this template comes with a Makefile, you can do it from a separate shell,
# with the make program:
#
# $ make
# These online resources can help you design your colorscheme:
#
# * http://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg
# the xterm palette
# * http://whatcolor.herokuapp.com/
# play with hexadecimal colors right in the address bar (currently down)
# * http://color.hailpixel.com/
# similar concept, fuzzier implementation
# * http://colourco.de/
# similar concept, fancier implementation
# * http://www.colr.org/
# extract a palette from an image
# * http://colores.manugarri.com/
# search for 'word', get images and color palettes
# * http://www.colourlovers.com/palettes
# user-created palettes
# * http://www.perbang.dk/color+scheme/
# a no-nonsense colorscheme generator
# * https://color.adobe.com/
# Adobe's fancy colorscheme generator
# * http://paletton.com/
# The classic 'Color Scheme Designer', rebranded
# * http://vrl.cs.brown.edu/color
# A very smart palette generator
# * https://cmcenroe.me/2018/04/03/colour-scheme.html
# "I Made My Own Colour Scheme and You Can Too!"
# A few general advices:
#
# * The Windows console is limited to the 16 so-called "ANSI" colors but it used to
# have a few of them interverted which makes numbers impractical. Use color names
# instead of numbers: :help cterm-colors
# * The Windows console (yeah…) doesn't do italics, underlines or bolded text;
# it is limited to normal and reverse. Keep that in mind if you want
# your colorscheme to be usable in as many environments as possible by as many
# people as possible.
# * Actually, terminal emulators rarely do italics.
# * All of the terminal emulators in use these days allow their users to
# change the 16 so-called "ANSI" colors. It is also possible on some platforms
# to change some or all of the 256 colors in the xterm palette. Don't take
# anything for granted.
# * When used against a light background, strong colors work better than muted
# ones. Light or dark doesn't really matters. Also, it is harder to discriminate
# between two similar colors on a light background.
# * Both strong and muted colors work well against a dark background. It is also
# easier to work with similar colors, but dark colors don't work at all.
# * Use as many text samples as possible. String-heavy languages may look completely
# different than keyword-heavy ones. This can have an impact on the usability
# of your colorscheme.
# * Most terminal emulators and terminal multiplexers currently in use on unix-like
# systems support 256 colors but they almost always default to a '$TERM' that tells
# Vim otherwise. Your users will need to make sure their terminal emulator/multiplexer
# is correctly set up if they want to enjoy the best possible experience.
# Many thanks to Barry Arthur (https://github.com/dahu) for the original idea.
# You don't need to edit anything beyond this line.
-%>
" <%= information[:name] %>.vim -- Vim color scheme.
" Author: <%= information[:author] %> (<%= information[:email] %>)
" Webpage: <%= information[:webpage] %>
" Description: <%= information[:description] %>
" Last Change: <%= Time.new.strftime "%Y-%m-%d" %>
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "<%= information[:name].downcase %>"
if ($TERM =~ '256' || &t_Co >= 256) || has("gui_running")
<% for highlight in highlights -%>
<% if highlight.length == 4 -%>
hi <%= highlight[0] %> ctermbg=<%= highlight[1].kind_of?(String) ? highlight[1] : highlight[1][1] %> ctermfg=<%= highlight[2].kind_of?(String) ? highlight[2] : highlight[2][1] %> cterm=<%= highlight[3] %> guibg=<%= highlight[1].kind_of?(String) ? highlight[1] : highlight[1][0] %> guifg=<%= highlight[2].kind_of?(String) ? highlight[2] : highlight[2][0] %> gui=<%= highlight[3] %>
<% elsif highlight.length > 4 -%>
hi <%= highlight[0] %> ctermbg=<%= highlight[1].kind_of?(String) ? highlight[1] : highlight[1][1] %> ctermfg=<%= highlight[2].kind_of?(String) ? highlight[2] : highlight[2][1] %> cterm=<%= highlight[3] %> guibg=<%= highlight[1].kind_of?(String) ? highlight[1] : highlight[1][0] %> guifg=<%= highlight[2].kind_of?(String) ? highlight[2] : highlight[2][0] %> gui=<%= highlight[3] %> guisp=<%= highlight[4].kind_of?(String) ? highlight[4] : highlight[4][0] %>
<% end -%>
<% end -%>
elseif &t_Co == 8 || $TERM !~# '^linux' || &t_Co == 16
set t_Co=16
<%= '' %>
<% for highlight in highlights -%>
<% if highlight.length > 2 -%>
hi <%= highlight[0] %> ctermbg=<%= highlight[1].kind_of?(String) ? highlight[1] : highlight[1][2] %> ctermfg=<%= highlight[2].kind_of?(String) ? highlight[2] : highlight[2][2] %> cterm=<%= highlight[3] %>
<% end -%>
<% end -%>
endif
<% links = highlights.select do |highlight| -%>
<% highlight.length == 2 -%>
<% end -%>
<% if links.length > 0 -%>
<%= '' %>
<% for link in links -%>
hi link <%= link[0] %> <%= link[1] %>
<% end -%>
<% end -%>
<% if terminal_ansi_colors.length == 16 -%>
<%= '' %>
let g:terminal_ansi_colors = [
<% for color in terminal_ansi_colors -%>
\ '<%= color[0] %>',
<% end -%>
\ ]
<% end -%>
" Generated with RNB (https://github.com/romainl/vim-rnb)

View File

@ -0,0 +1,102 @@
return function(name, Normal, highlights, terminal_ansi_colors)
-- Clear the highlighting.
vim.cmd('hi clear')
-- If the syntax has been enabled, reset it.
if vim.fn.exists('syntax_on') then vim.cmd('syntax reset') end
-- Set the name of the current colorscheme.
vim.g.colors_name = string.lower(name)
-- Determine which set of colors to use.
local use_hex_and_256 = string.find(vim.fn.expand('$TERM'), '256')
or vim.g.t_Co >= 256
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 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.
local BIT_16 = 3
local BIT_256 = 2
local HEX = 1
-- Get the color value of a color variable, or "NONE" as a default.
local function get(color, index)
if type(color) == 'table' and color[index] then
return color[index]
elseif type(color) == 'string' then
return color
else
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`.
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('Normal', Normal)
-- Highlight everything else.
for highlight_group, attributes in pairs(highlights) do
highlight(highlight_group, attributes)
end
-- Set the terminal colors.
for index, color in ipairs(terminal_ansi_colors) do
vim.g['terminal_color_' .. index] = color[HEX]
end
end

434
lua/highlite/init.lua Normal file
View File

@ -0,0 +1,434 @@
--[[ Highlite, a Neovim colorscheme template.
* Author: Iron-E (https://github.com/Iron-E)
* Repository: https://github.com/nvim-highlite
Rewrite of RNB, a Vim colorsheme template.
* Author: Romain Lafourcade (https://github.com/romainl)
* Canonical URL: https://github.com/romainl/vim-rnb
]]
--[[ Introduction
This template is designed to help vimmers create their own colorschemes
without much effort.
You will not need any additional tooling to run this file. Just open it
in Neovim and follow the instructions the colorscheme will generate
be generated automatically.
The process is divided in five steps:
1. Rename the template,
2. Edit your colorscheme's information,
3. Define your colors,
4. Define your highlight groups and links, and
5. Sourcing your colorscheme.
]]
--[[ Step 1: renaming
If this file is distributed with a colorscheme it's probably already named correctly
and you can skip this step.
If you forked/cloned/copied this repository to create your own colorscheme, you will have to
rename this template to match the name of your colorscheme.
NOTE: Neovim doesn't really care about whitespace in the name of the colorscheme but it does for
filenames so make sure your filename doesn't have any whitespace character.
| colorscheme name | template filename |
|:-----------------:|:-----------------:|
| foobar | foobar.lua |
| foo-bar | foo-bar.lua |
| foo bar | foo-bar.lua or |
| foo_bar | foo_bar.lua |
]]
--[[ Step 2: information
Make sure the name of your colorscheme is unique and attractive.
]]
local name = "highlite"
--[[ Step 3: colors
Next you will define all of the colors that you will use for the color scheme.
Each one should be made up of three parts:
```lua
<color name> = { -- Give each color a distinctive name.
<hex color code>, -- Hexadecimal color used in GVim/MacVim or "NONE".
<256-bit color code>, -- Integer 0255 used by terminals supporting 256 colors or "NONE".
<16-bit color code> -- color name used by less capable color terminals, can be "darkred",
"red", "darkgreen", "green", "darkyellow", "yellow", "darkblue",
"blue", "darkmagenta", "magenta", "black", "darkgrey", "grey",
"white", or "NONE"
}
```
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.
]]
local black = {"#202020", 0, "black"}
local gray = {"#808080", 244, "gray" }
local gray_dark = {"#353535", 236, "darkgrey"}
local gray_darker = {"#505050", 244, "gray" }
local gray_light = {"#c0c0c0", 251, "gray" }
local white = {"#ffffff", 15, "white"}
local brown_light = {"#fca070", 178, "darkyellow"}
local tan = {"#f4c069", 180, "darkyellow"}
local red = {"#ee4a59", 196, "red"}
local red_dark = {"#a80000", 124, "darkred"}
local red_light = {"#ff4090", 203, "red"}
local orange = {"#ff8900", 208, "darkyellow"}
local orange_light = {"#f0af00", 214, "yellow"}
local yellow = {"#f0df33", 220, "yellow"}
local green_dark = {"#50de60", 83, "darkgreen"}
local green = {"#77ff00", 72, "green"}
local green_light = {"#a0ff70", 72, "green"}
local blue = {"#7090ff", 63, "darkblue"}
local cyan = {"#00efff", 87, "cyan"}
local ice = {"#80b5ff", 63, "cyan"}
local teal = {"#6ac0c0", 38, "cyan"}
local turqoise = {"#2bff99", 33, "blue"}
local magenta = {"#d5508f", 126, "magenta"}
local magenta_dark = {"#bb0099", 126, "darkmagenta"}
local pink = {"#ffa6ff", 162, "magenta"}
local pink_light = {"#ffb7b7", 38, "white"}
local purple = {"#cf55f0", 129, "magenta"}
local purple_light = {"#af60af", 63, "magenta"}
local purple_dark = {"#c700ff", 38, "darkmagenta"}
--[[ Step 4: highlights
You can define highlight groups like this:
```lua
<highlight group name> = {
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"
-- Style can be "bold", "italic", and more. See |attr-list| for more information.
style=<cterm>
-- style can also have a color, and/or multiple <cterm>s.
style={<cterm> [, <cterm>] [color=<color>]})
}
```
The sample above tells Vim to render normal text in dark gray against a white
background, without any other styling.
Or you can link an highlight group to another. Here, "Title" will inherit its style from
"Normal":
```lua
Title = {link="Normal"}
```
In GUI Vim, there is an additional color for the undercurl used to
highlight spelling mistakes:
```lua
SpellBad = { -- ← name of the highlight group
bg="NONE", -- background color
fg=red, -- foureground color
style={ -- the style
"undercurl", -- undercurl (squiggly line)
color=red -- the color of the undercurl
}
}
```
If you weren't satisfied with undercurl, and also wanted another effect, you can
add another one below "undercurl" and it will be applied as well:
```lua
SpellBad = { -- ← name of the highlight group
bg="NONE", -- background color
fg=red, -- foureground color
style={ -- the style
"undercurl", -- undercurl (squiggly line)
"standout"
color=red -- the color of the undercurl
}
}
```
The sample above tells Vim to render badly spelled words in red against the current
background, with a red undercurl.
You can add any custom highlight group to the standard list below but you shouldn't
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
are good reads, by the way.
]]
-- This is the only highlight that must be defined separately.
local Normal = {bg=black, fg=gray_light, style="NONE"}
-- This is where the rest of your highlights should go.
local highlights = {
--[[ 1. Text Analysis ]]
Comment = {bg="NONE", fg=gray, style="italic"},
EndOfBuffer = {link="NonText" },
NonText = {bg="NONE", fg=gray_dark, style="NONE" },
Whitespace = {link="NonText" },
--[[ 1.1. Literals]]
Constant = {bg="NONE", fg=orange_light, style="NONE"},
String = {bg="NONE", fg=green, style="NONE"},
Character = {bg="NONE", fg=red_light, style="NONE"},
Number = {bg="NONE", fg=pink_light, style="NONE"},
Boolean = {bg="NONE", fg=yellow, style="NONE"},
Float = {link="Number" },
--[[ 1.2. Identifiers]]
Identifier = {bg="NONE", fg="fg", style="NONE"},
Function = {bg="NONE", fg=purple, style="NONE"},
--[[ 1.3. Syntax]]
Statement = {bg="NONE", fg=ice, style="NONE" },
Conditional = {bg="NONE", fg=ice, style="italic"},
Repeat = {link="Keyword" },
Label = {bg="NONE", fg=pink, style="italic"},
Operator = {bg="NONE", fg=green_dark, style="NONE" },
Keyword = {bg="NONE", fg=turqoise, style="bold" },
Exception = {bg="NONE", fg=red, style="bold" },
--[[ 1.4. Metatextual Information]]
PreProc = {bg="NONE", fg=tan, style="NONE" },
Include = {bg="NONE", fg=green_light, style="nocombine"},
Define = {bg="NONE", fg=blue, style="nocombine"},
Macro = {link='Define' },
PreCondit = {bg="NONE", fg=teal, style="nocombine"},
--[[ 1.5. Semantics]]
Type = {bg="NONE", fg=cyan, style="NONE" },
StorageClass = {bg="NONE", fg=orange_light, style="bold" },
Structure = {bg="NONE", fg=blue, style="bold" },
Typedef = {bg="NONE", fg=cyan, style="italic"},
--[[ 1.6. Edge Cases]]
Special = {bg="NONE", fg=magenta, style="NONE"},
SpecialChar = {link="Character" },
SpecialKey = {link="Character" },
Tag = {link="Underlined" },
Delimiter = {bg="NONE", fg=white, style="NONE"},
SpecialComment = {bg="NONE", fg=gray, style="bold"},
Debug = {link='WarningMsg' },
--[[ 1.7. Help Syntax]]
Underlined = {bg="NONE", fg=turqoise, style="underline" },
Ignore = {bg="NONE", fg=gray, style="NONE" },
Error = {bg=red_dark, fg=white, style="bold" },
Todo = {bg="NONE", fg=yellow, style={"bold", "underline"}},
helpHyperTextJump = {link="Underlined" },
helpSpecial = {link="Function" },
--[[ 2... Editor UI ]]
--[[ 2.1. Status Line]]
StatusLine = {bg=gray_darker, fg=green_light, style="NONE"},
StatusLineNC = {bg=gray_darker, fg=gray, style="NONE"},
StatusLineTerm = {link="StatusLine" },
StatusLineTermNC = {link="StatusLineNC" },
--[[ 2.2. Separators]]
VertSplit = {bg="NONE", fg=gray_darker, style="NONE" },
TabLine = {bg=gray_darker, fg="fg", style="NONE" },
TabLineFill = {bg="NONE", fg="fg", style="NONE" },
TabLineSel = {bg=gray_darker, fg="fg", style="inverse"},
Title = {bg="NONE", fg="NONE", style="bold" },
--[[ 2.3. Conditional Line Highlighting]]
--Conceal={}
CursorLine = {bg=gray_dark, fg="NONE", style="NONE" },
CursorLineNr = {bg=gray_dark, fg=pink, style="NONE" },
debugBreakpoint = {link="ErrorMsg" },
debugPC = {link="ColorColumn" },
LineNr = {bg="NONE", fg=gray, style="NONE" },
QuickFixLine = {bg=gray_darker, fg="NONE", style="NONE" },
Visual = {bg="NONE", fg="NONE", style="inverse"},
VisualNOS = {bg=gray_darker, fg="NONE", style="NONE" },
--[[ 2.4. Popup Menu]]
Pmenu = {bg=gray_dark, fg="fg", style="NONE"},
PmenuSbar = {bg=black, fg="NONE", style="NONE"},
PmenuSel = {bg="NONE", fg="fg", style="NONE"},
PmenuThumb = {bg=white, fg="NONE", style="NONE"},
WildMenu = {bg="NONE", fg="NONE", style="NONE"},
--[[ 2.5. Folds]]
FoldColumn = {bg=gray_darker, fg="NONE", style="bold" },
Folded = {bg=purple_light, fg=black, style="italic"},
--[[ 2.6. Diffs]]
DiffAdd = {bg="NONE", fg=green_dark, style="inverse"},
DiffChange = {bg="NONE", fg=yellow, style="inverse"},
DiffDelete = {bg="NONE", fg=red, style="inverse"},
DiffText = {bg="NONE", fg="NONE", style="inverse"},
--[[ 2.7. Searching]]
IncSearch = {bg="NONE", fg="NONE", style="inverse" },
Search = {bg="NONE", fg="NONE", style={"undercurl", color=white}},
MatchParen = {bg="NONE", fg=green, style="bold,underline" },
--[[ 2.8. Spelling]]
SpellBad = {bg="NONE", fg="NONE", style={"undercurl", color=red }},
SpellCap = {bg="NONE", fg="NONE", style={"undercurl", color=yellow}},
SpellLocal = {bg="NONE", fg="NONE", style={"undercurl", color=green }},
SpellRare = {bg="NONE", fg="NONE", style={"undercurl", color=orange}},
--[[ 2.9. Conditional Column Highlighting]]
ColorColumn = {bg="NONE", fg="NONE", style="inverse"},
SignColumn = {bg="NONE", fg="NONE", style="NONE" },
--[[ 2.10. Messages]]
ErrorMsg = {bg="NONE", fg=red_light, style="bold"},
ModeMsg = {bg="NONE", fg=yellow, style="NONE"},
WarningMsg = {bg="NONE", fg=orange, style="bold"},
Question = {bg="NONE", fg=orange_light, style="underline"},
--[[ 2.11. Cursor ]]
--Cursor = {},
--CursorIM = {link="Cursor"},
CursorColumn = {bg=gray_dark, fg="NONE", style="NONE"},
-- 2.12 Misc.
Directory = {bg="NONE", fg=ice, style="bold"},
Terminal = {link="Normal" },
--[[ 3. Plugin Highlight Groups ]]
-- By default, this section is empty, but feel free to add your own information here.
}
--[[
Define the color palette used by :terminal when in GUI Vim
or in TUI Vim when 'termguicolors' is enabled. If this list
is empty or if it doesn't contain exactly 16 items, the corresponding
Vim variable won't be set.
The expected values are colors defined in step 3.
Terminal emulators use a basic palette of 16 colors that can be
addressed by CLI and TUI tools via their name or their index, from
0 to 15. The list is not really standardized but it is generally
assumed to look like this:
| Index | Name |
|:------:|:-------------:|
| 1 | black |
| 2 | darkred |
| 3 | darkgreen |
| 4 | darkyellow |
| 5 | darkblue |
| 6 | darkmagenta |
| 7 | darkcyan |
| 8 | gray |
| 9 | darkgray |
| 10 | red |
| 11 | green |
| 12 | yellow |
| 13 | blue |
| 14 | magenta |
| 15 | cyan |
| 16 | white |
While you are certainly free to make colors 0 to 7 shades of blue,
this will inevitably cause usability issues so be careful.
]]
local terminal_ansi_colors = {
[1] = black,
[2] = red_dark,
[3] = green_dark,
[4] = orange,
[5] = blue,
[6] = magenta_dark,
[7] = teal,
[8] = gray,
[9] = gray_dark,
[10] = red,
[11] = green,
[12] = yellow,
[13] = turqoise,
[14] = purple,
[15] = cyan,
[16] = gray_light
}
--[[ Step 5: Sourcing
When you wish to load your colorscheme, you will not use the `colorscheme` command like normal.
Instead, you will source this file with `:luafile stdpath('config') . '/lua/<filename>.lua'`
See `:help luafile` and `:help stdpath` for more information.
These online resources can help you design your colorscheme:
1. the xterm palette.
* http://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg
2. play with hexadecimal colors right in the address bar (currently down).
* http://whatcolor.herokuapp.com/
3. similar concept, fuzzier implementation.
* http://color.hailpixel.com/
4. similar concept, fancier implementation.
* http://colourco.de/
5. extract a palette from an image.
* http://www.colr.org/
6. search for 'word', get images and color palettes.
* http://colores.manugarri.com/
7. user-created palettes.
* http://www.colourlovers.com/palettes
8. a no-nonsense colorscheme generator.
* http://www.pluaang.dk/color+scheme/
9. Adobe's fancy colorscheme generator.
* https://color.adobe.com/
10. The classic 'Color Scheme Designer', rebranded.
* http://paletton.com/
11. A very smart palette generator.
* http://vrl.cs.brown.edu/color
12. "I Made My Own Colour Scheme and You Can Too!".
* https://cmcenroe.me/2018/04/03/colour-scheme.html
A few general advices:
* The Windows console is limited to the 16 so-called "ANSI" colors but it used to
have a few of them interverted which makes numbers impractical. Use color names
instead of numbers: :help cterm-colors
* The Windows console (yeah) doesn't do italics, underlines or bolded text;
it is limited to normal and reverse. Keep that in mind if you want
your colorscheme to be usable in as many environments as possible by as many
people as possible.
* Actually, terminal emulators rarely do italics.
* The Windows Terminal, however, is capable of more.
* All of the terminal emulators in use these days allow their users to
change the 16 so-called "ANSI" colors. It is also possible on some platforms
to change some or all of the 256 colors in the xterm palette. Don't take
anything for granted.
* When used against a light background, strong colors work better than muted
ones. Light or dark doesn't really matters. Also, it is harder to discriminate
between two similar colors on a light background.
* Both strong and muted colors work well against a dark background. It is also
easier to work with similar colors, but dark colors don't work at all.
* Use as many text samples as possible. String-heavy languages may look completely
different than keyword-heavy ones. This can have an impact on the usability
of your colorscheme.
* Most terminal emulators and terminal multiplexers currently in use on unix-like
systems support 256 colors but they almost always default to a '$TERM' that tells
Vim otherwise. Your users will need to make sure their terminal emulator/multiplexer
is correctly set up if they want to enjoy the best possible experience.
Many thanks to Barry Arthur (https://github.com/dahu) for the original idea.
* You don't need to edit anything beyond this line. *
]]
require(name .. '/colorscheme')(
name,
Normal,
highlights,
terminal_ansi_colors
)