Do you want all the most popular (Neo)Vim colorschemes than only one? Do you want to change them from time to time?
This is it! Let's load all the ultra colorschemes into Neovim player!
shuffle-per-sec-v2.mp4
Click here to see how to configure
require("colorbox").setup({
policy = { seconds = 1, implement = "shuffle" },
timing = "interval",
})It uses GitHub actions to weekly collect/update the colorscheme dataset.
Note
The most popular colorschemes are manually picked from below websites, with GitHub stars β₯ 800:
- Awesome Neovim Colors: https://www.trackawesomelist.com/rockerBOO/awesome-neovim/readme/
- Awesome Vim Colors: https://github.com/rafi/awesome-vim-colorschemes
- GitHub "neovim-colorscheme" topic: https://github.com/topics/neovim-colorscheme
- GitHub "vim-colorscheme" topic: https://github.com/topics/vim-colorscheme
For plugins that conflicts on same color name, the one with more stars or Neovim features are picked.
Please check COLORSCHEMES.md for full colorscheme dataset.
Once before, we used a autobot to crawl colorscheme plugins and automatically update the ranking list, but now the website data sources are no longer pick-able, so we are forced to manual maintenance.
It installs colorschemes via git submodule instead of copy-paste source code, so you get continuously updates from original authors.
It allows you to play them with multiple playback settings(policies):
- Suffle playback.
- Play in order.
- Play in reverse order.
- Single cycle.
And multiple trigger timings:
- On startup.
- Fixed interval.
- Date time (todo).
- By filetype.
Note
This plugin always supports with the latest stable and (possibly) nightly Neovim version.
- Neovim β₯ 0.10.
- Git.
Important
- Don't lazy load it.
- Load it before all other plugins.
Important
Please add below dependencies if your colorschemes need them:
With lazy.nvim
require('lazy').setup({
{
'linrongbin16/colorbox.nvim',
-- don't lazy load and load it before all other plugins.
lazy = false,
priority = 1000,
-- add dependencies if colorschemes need them
dependencies = {"nvim-treesitter/nvim-treesitter", "rktjmp/lush.nvim"},
build = function() require("colorbox").update() end,
config = function()
-- Enable 'termguicolors' option
vim.o.termguicolors = true
require("colorbox").setup()
end,
}
})With pckr.nvim
require('pckr').add({
{
'linrongbin16/colorbox.nvim',
-- add dependencies if colorschemes need them
requires = {"nvim-treesitter/nvim-treesitter", "rktjmp/lush.nvim"},
run = function() require("colorbox").update() end,
config = function()
-- Enable 'termguicolors' option
vim.o.termguicolors = true
require("colorbox").setup()
end,
};
})When loading this plugin, it does below steps:
- Runs the filters, only enables the colors you choose from the dataset (see Filter).
- Registers the triggers to invoke related policies at a proper timing (see Timing).
When a timing is triggered, it does below steps:
- Runs the registered policy and pick a colorscheme (see Policy).
- Refreshes the
backgroundoption (see Background). - Runs the
colorschemecommand to actually apply the colorscheme.
You can use the Colorbox command with below subcommands:
-
update: Update all git submodules. -
info: Show detailed information and configured status.Note: use
scale=0.7to specify popup window's size in range(0, 1], by default isscale=0.7. -
shuffle: Change to a random color.
Note
You can still use the colorscheme command to change a colorscheme.
To configure options, please use:
require("colorbox").setup(opts)The opts is an optional lua table that override the default options. Here we only introduce some of the most options.
For complete default options, please see configs.lua.
The filter option is to help user filter some colorschemes from the dataset, thus they will never show up.
There're 2 kinds of filters:
-
Function filter: A lua function that decides whether to enable/disable a color. It uses the function signature:
function(color_name:string, spec:colorbox.ColorSpec):boolean
The function has two parameters:
color_name: The colorscheme name.spec: The colorscheme's meta info, please see@class colorbox.ColorSpecfor more details.
It returns
trueto enable a color,falseto disable a color. -
List filter: A lua list that contains multiple function filters. A colorscheme will only be enabled if all these filters returns
true.
The timing option is to configure when to change to next colorscheme.
There're 3 kinds of timings:
startup: On nvim start. It works exactly like manually adding the scriptcolorscheme xxxin nvim's init config file.interval: On fixed interval timeout. It registers a background job to schedule on a fixed interval timeout (i.e. every X seconds), and triggers the next colorscheme.filetype: On file type change. It listens to current buffer's file type, and triggers the next colorscheme if the file type changed.
The policy option is to configure how to pick the next colorscheme.
There're 3 kinds of policies (they work with the corresponding timings):
-
Builtin policy: A lua string that presents the name of a builtin policy. For now we have 4 builtin policies (see below). It can works directly with the
startuptiming (see: Choose random color on nvim start).shuffle: Pick a random color.in_order: Pick next color in order, color names are ordered from 'A' to 'Z'.reverse_order: Pick next color in reversed order, color names are ordered from 'Z' to 'A'.single: Always pick the same color, i.e. next color is still the current color.
-
Fixed interval timeout policy: A lua table that contains
secondsandimplementfields. It works with theintervaltiming (see: Change random color per second).seconds: Choose next colorscheme on every X seconds.implement: The name of the builtin policy that choose how to pick the next colorscheme.
-
File type policy: A lua table that contains
mappingand (optional)emptyand (optional)fallbackfields. It works with thefiletypetiming (see: Choose color by file type).mapping: A lua table that maps from file type to color name. When current buffer's file type is hitted, it changes to the mapped color.- (Optional)
empty: The color name when the file type is empty lua string. When set tonil, it does nothing. - (Optional)
fallback: The color name when the file type is not found inmappingfield. When set tonil, it does nothing.
The background option runs set background=dark/light every time before running the colorscheme command (to change a colorscheme).
require("colorbox").setup({
background = "dark",
})Some colors (tokyonight-day, rose-pine-dawn, etc) are forced to be light, i.e. they forced the background option to light inside their internal implementations.
This is no problem, except some user may want all those following colorschemes (after tokyonight-day and rose-pine-dawn) go back to dark background if they're dark-able.
To execute a hook function after policy is triggered and new colorscheme is applied, please use:
require("colorbox").setup({
post_hook = function(color, spec)
vim.notify(string.format("Colorscheme changed to: %s", vim.inspect(color)))
end,
})The hook accepts a lua function with below signature:
function(color:string, spec:colorbox.ColorSpec):nilrequire("colorbox").setup({
policy = "single",
timing = "startup",
})require("colorbox").setup({
policy = "shuffle",
timing = "startup",
})require("colorbox").setup({
policy = { seconds = 1, implement = "shuffle" },
timing = "interval",
})require("colorbox").setup({
timing = "filetype",
policy = {
mapping = {
lua = "PaperColor",
yaml = "everforest",
markdown = "kanagawa",
python = "iceberg",
},
empty = "tokyonight",
fallback = "solarized8",
},
})require("colorbox").setup({
filter = false,
})local function disabled(color_name)
for _, c in ipairs({
"iceberg",
"ayu",
"edge",
"nord",
}) do
if string.lower(c) == string.lower(color_name) then
return true
end
end
return false
end
require("colorbox").setup({
filter = function(color, spec)
return disabled(spec.color_name)
end
})local function plugin_disabled(handle)
for _, p in ipairs({
"cocopon/iceberg.vim",
"folke/tokyonight.nvim",
"ayu-theme/ayu-vim",
"shaunsingh/nord.nvim",
}) do
if string.lower(p) == string.lower(handle) then
return true
end
end
return false
end
require("colorbox").setup({
filter = function(color, spec)
return not plugin_disabled(spec.handle)
end
})To develop the project and make PR, please setup with:
To run unit tests, please install below dependencies:
Then test with vusted ./spec.