Skip to content

chikof/colors.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

colors.nvim

Inline color swatches for Neovim. Scans your buffer for color literals and renders a colored directly after each one.

Supported formats

  • 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, turn
    • hsl(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.

Requirements

  • Neovim >= 0.10
  • termguicolors enabled:
    vim.o.termguicolors = true

Install

lazy.nvim

{
  "chikof/colors.nvim",
  opts = {},
}

vim.pack (Neovim >= 0.12)

vim.pack.add({ "https://github.com/chikof/colors.nvim" })
require("colors").setup()

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.

Commands

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)

Per-buffer opt-out

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,
})

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages