Inline color swatches for Neovim. Scans your buffer for color literals and renders a colored ■ directly after each one.
- Hex —
#RGB,#RGBA,#RRGGBB,#RRGGBBAA - RGB / RGBA — comma and space syntax, percentage components
rgb(255, 0, 128)·rgb(100% 0% 50% / 80%)·rgba(255 0 0 / 0.5)
- HSL / HSLA — hue units:
deg,rad,grad,turnhsl(210 20% 40%)·hsl(0.5turn 100% 50% / 75%)
- OKLCH
oklch(0.62 0.18 264)·oklch(62% 0.18 264 / 0.8)
Note
Alpha is parsed but not rendered. Swatches always display the opaque base color.
- Neovim >= 0.10
termguicolorsenabled:vim.o.termguicolors = true
lazy.nvim
{
"chikof/colors.nvim",
opts = {},
}vim.pack (Neovim >= 0.12)
vim.pack.add({ "https://github.com/chikof/colors.nvim" })
require("colors").setup()All options with their defaults:
require("colors").setup({
enabled = true,
symbol = "■",
debounce_ms = 80,
scan_mode = "visible", -- "visible" | "buffer"
max_file_lines = 10000,
max_file_bytes = 1024 * 1024, -- 1 MB
filetypes_allow = nil, -- nil = all filetypes; { "css", "lua" } = allowlist
filetypes_deny = {}, -- { "markdown" } = blocklist
})scan_mode = "visible" only scans lines currently on screen. "buffer" scans the entire file on every change - more accurate but heavier on large files.
| Command | Description |
|---|---|
:ColorsEnable |
Enable and render swatches in all buffers |
:ColorsDisable |
Disable and clear all swatches |
:ColorsToggle |
Toggle on/off |
:ColorsRefresh [bufnr] |
Re-scan a buffer (default: current) |
Set vim.b.colors_nvim_disable = true to disable highlighting in a specific buffer without affecting others. Useful in ftplugins or autocmds:
vim.api.nvim_create_autocmd("FileType", {
pattern = "bigfile",
callback = function()
vim.b.colors_nvim_disable = true
end,
})