Skip to content

Rolv-Apneseth/nvim-highlight-colors

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nvim-highlight-colors

Highlight colors within Neovim

Background highlights for hex, rgb, hsl, named colors, and CSS variables

Features

  • Realtime color highlighting
  • Supports hex, rgb, hsl, CSS variables, and Tailwind CSS
  • Multiple rendering modes: background, foreground, and virtual text

Usage

Install via your preferred package manager:

'brenoprata10/nvim-highlight-colors'

Initialize the plugin:

-- Ensure termguicolors is enabled if not already
vim.opt.termguicolors = true

require('nvim-highlight-colors').setup({})

Options

require("nvim-highlight-colors").setup {
	---Render style
	---@usage 'background'|'foreground'|'virtual'
	render = 'background',

	---Set virtual symbol (requires render to be set to 'virtual')
	virtual_symbol = '',

	---Highlight named colors, e.g. 'green'
	enable_named_colors = true,

	---Highlight tailwind colors, e.g. 'bg-blue-500'
	enable_tailwind = false,

	---Set custom colors
	---Label must be properly escaped with '%' to adhere to `string.gmatch`
	--- :help string.gmatch
	custom_colors = {
		{ label = '%-%-theme%-primary%-color', color = '#0f1219' },
		{ label = '%-%-theme%-secondary%-color', color = '#5a5d64' },
	}
}

Render modes

Examples shown use enable_tailwind = true

Background

Background highlights for named colors, CSS variables, and Tailwind CSS colors

Foreground

Foreground highlights for named colors, CSS variables, and Tailwind CSS colors

Virtual text

Virtual text highlights for named colors, CSS variables, and Tailwind CSS colors

Commands

Command Description
:HighlightColors On Turn highlights on
:HighlightColors Off Turn highlights off
:HighlightColors Toggle Toggle highlights

Commands are also available in lua:

require("nvim-highlight-colors").turnOn()
require("nvim-highlight-colors").turnOff()
require("nvim-highlight-colors").toggle()

About

Highlight colors for neovim

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%