{"id":13411455,"url":"https://github.com/brenoprata10/nvim-highlight-colors","last_synced_at":"2025-12-25T09:56:47.586Z","repository":{"id":46143548,"uuid":"514820316","full_name":"brenoprata10/nvim-highlight-colors","owner":"brenoprata10","description":"Highlight colors for neovim","archived":false,"fork":false,"pushed_at":"2024-05-21T12:37:47.000Z","size":130,"stargazers_count":486,"open_issues_count":9,"forks_count":25,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-05-21T13:49:40.371Z","etag":null,"topics":["colors","neovim","nvim","plugin","vim"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brenoprata10.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["brenoprata10"],"patreon":"brenoprata","custom":"paypal.me/brenoprata"}},"created_at":"2022-07-17T11:09:45.000Z","updated_at":"2024-05-27T12:24:04.679Z","dependencies_parsed_at":"2024-01-02T19:47:41.266Z","dependency_job_id":"70bd7433-2a9a-48d9-941a-389c2e7a186a","html_url":"https://github.com/brenoprata10/nvim-highlight-colors","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brenoprata10%2Fnvim-highlight-colors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brenoprata10%2Fnvim-highlight-colors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brenoprata10%2Fnvim-highlight-colors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brenoprata10%2Fnvim-highlight-colors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brenoprata10","download_url":"https://codeload.github.com/brenoprata10/nvim-highlight-colors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243618632,"owners_count":20320268,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["colors","neovim","nvim","plugin","vim"],"created_at":"2024-07-30T20:01:13.833Z","updated_at":"2025-12-25T09:56:47.578Z","avatar_url":"https://github.com/brenoprata10.png","language":"Lua","funding_links":["https://github.com/sponsors/brenoprata10","https://patreon.com/brenoprata","paypal.me/brenoprata"],"categories":["Color","Lua"],"sub_categories":["Markdown and LaTeX","Assembly"],"readme":"# nvim-highlight-colors\n\u003ca href=\"https://dotfyle.com/plugins/brenoprata10/nvim-highlight-colors\"\u003e\n    \u003cimg src=\"https://dotfyle.com/plugins/brenoprata10/nvim-highlight-colors/shield?style=flat-square\" /\u003e\n\u003c/a\u003e\n\u003c/br\u003e\n\n\u003e Highlight colors within Neovim\n  \n\u003cimg width=\"640\" src=\"https://github.com/mvllow/nvim-highlight-colors/assets/1474821/d99a800c-0ea9-44f9-bc1c-986236adf44a\" alt=\"Background highlights for hex, rgb, hsl, named colors, and CSS variables\" /\u003e\n\n## Features\n\n- Realtime color highlighting\n- Supports hex, rgb, hsl, CSS variables, and Tailwind CSS\n- LSP support! For any LSP that supports `textDocument/documentColor` like [tailwindcss](https://github.com/tailwindlabs/tailwindcss-intellisense) and [csslsp](https://github.com/microsoft/vscode-css-languageservice)\n- Multiple rendering modes: background, foreground, and virtual text\n\n## Usage\n\nInstall via your preferred package manager:\n\n```lua\n'brenoprata10/nvim-highlight-colors'\n```\n\nInitialize the plugin:\n\n```lua\n-- Ensure termguicolors is enabled if not already\nvim.opt.termguicolors = true\n\nrequire('nvim-highlight-colors').setup({})\n```\n\n### `nvim-cmp` integration\n\n```lua\nrequire(\"cmp\").setup({\n        ... other configs\n        formatting = {\n                format = require(\"nvim-highlight-colors\").format\n        }\n})\n```\n\nor\n\n```lua\nrequire(\"cmp\").setup({\n        ... other configs\n        formatting = {\n                format = function(entry, item)\n                        item = -- YOUR other configs come first\n                        return require(\"nvim-highlight-colors\").format(entry, item)\n                end\n        }\n})\n```\n\n#### `lspkind` integration\n\nThe out of the box `format` function does not necessarily play nicely with `lspkind` and potentially other formatters provided by plugins and may require manual intervention. Here is an example of making the integration work nicely with `lspkind`:\n\n```lua\nrequire(\"cmp\").setup({\n        ... other configs\n        formatting = {\n                format = function(entry, item)\n                        local color_item = require(\"nvim-highlight-colors\").format(entry, { kind = item.kind })\n                        item = require(\"lspkind\").cmp_format({\n                                -- any lspkind format settings here\n                        })(entry, item)\n                        if color_item.abbr_hl_group then\n                                item.kind_hl_group = color_item.abbr_hl_group\n                                item.kind = color_item.abbr\n                        end\n                        return item\n                end\n        }\n})\n```\n\n### `blink.cmp` integration\n\n```lua\nrequire(\"blink.cmp\").setup {\n\tcompletion = {\n\t\tmenu = {\n\t\t\tdraw = {\n\t\t\t\tcomponents = {\n\t\t\t\t\t-- customize the drawing of kind icons\n\t\t\t\t\tkind_icon = {\n\t\t\t\t\t\ttext = function(ctx)\n\t\t\t\t\t\t  -- default kind icon\n\t\t\t\t\t\t  local icon = ctx.kind_icon\n\t\t\t\t\t\t\t-- if LSP source, check for color derived from documentation\n\t\t\t\t\t\t\tif ctx.item.source_name == \"LSP\" then\n\t\t\t\t\t\t\t\tlocal color_item = require(\"nvim-highlight-colors\").format(ctx.item.documentation, { kind = ctx.kind })\n\t\t\t\t\t\t\t\tif color_item and color_item.abbr ~= \"\" then\n\t\t\t\t\t\t\t\t  icon = color_item.abbr\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\treturn icon .. ctx.icon_gap\n\t\t\t\t\t\tend,\n\t\t\t\t\t\thighlight = function(ctx)\n\t\t\t\t\t\t\t-- default highlight group\n\t\t\t\t\t\t\tlocal highlight = \"BlinkCmpKind\" .. ctx.kind\n\t\t\t\t\t\t\t-- if LSP source, check for color derived from documentation\n\t\t\t\t\t\t\tif ctx.item.source_name == \"LSP\" then\n\t\t\t\t\t\t\t\tlocal color_item = require(\"nvim-highlight-colors\").format(ctx.item.documentation, { kind = ctx.kind })\n\t\t\t\t\t\t\t\tif color_item and color_item.abbr_hl_group then\n\t\t\t\t\t\t\t\t  highlight = color_item.abbr_hl_group\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\treturn highlight\n\t\t\t\t\t\tend,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n}\n```\n\n## Options\n\n```lua\nrequire(\"nvim-highlight-colors\").setup {\n\t---Render style\n\t---@usage 'background'|'foreground'|'virtual'\n\trender = 'background',\n\n\t---Set virtual symbol (requires render to be set to 'virtual')\n\tvirtual_symbol = '■',\n\n\t---Set virtual symbol suffix (defaults to '')\n\tvirtual_symbol_prefix = '',\n\n\t---Set virtual symbol suffix (defaults to ' ')\n\tvirtual_symbol_suffix = ' ',\n\n\t---Set virtual symbol position()\n \t---@usage 'inline'|'eol'|'eow'\n \t---inline mimics VS Code style\n \t---eol stands for `end of column` - Recommended to set `virtual_symbol_suffix = ''` when used.\n \t---eow stands for `end of word` - Recommended to set `virtual_symbol_prefix = ' ' and virtual_symbol_suffix = ''` when used.\n\tvirtual_symbol_position = 'inline',\n\n\t---Highlight hex colors, e.g. '#FFFFFF'\n\tenable_hex = true,\n\n    \t---Highlight short hex colors e.g. '#fff'\n\tenable_short_hex = true,\n\n\t---Highlight rgb colors, e.g. 'rgb(0 0 0)'\n\tenable_rgb = true,\n\n\t---Highlight hsl colors, e.g. 'hsl(150deg 30% 40%)'\n\tenable_hsl = true,\n\t\n\t---Highlight ansi colors, e.g '\\033[0;34m'\n\tenable_ansi = true,\n\n  -- Highlight hsl colors without function, e.g. '--foreground: 0 69% 69%;'\n  enable_hsl_without_function = true,\n\n\t---Highlight CSS variables, e.g. 'var(--testing-color)'\n\tenable_var_usage = true,\n\n\t---Highlight named colors, e.g. 'green'\n\tenable_named_colors = true,\n\n\t---Highlight tailwind colors, e.g. 'bg-blue-500'\n\tenable_tailwind = false,\n\n\t---Set custom colors\n\t---Label must be properly escaped with '%' to adhere to `string.gmatch`\n\t--- :help string.gmatch\n\tcustom_colors = {\n\t\t{ label = '%-%-theme%-primary%-color', color = '#0f1219' },\n\t\t{ label = '%-%-theme%-secondary%-color', color = '#5a5d64' },\n\t},\n\n \t-- Exclude filetypes or buftypes from highlighting e.g. 'exclude_buftypes = {'text'}'\n    \texclude_filetypes = {},\n    \texclude_buftypes = {},\n \t-- Exclude buffer from highlighting e.g. 'exclude_buffer = function(bufnr) return vim.fn.getfsize(vim.api.nvim_buf_get_name(bufnr)) \u003e 1000000 end'\n    \texclude_buffer = function(bufnr) end\n}\n```\n\n### Render modes\n\n\u003e Examples shown use `enable_tailwind = true`\n\n**Background**\n\n\u003cimg width=\"640\" src=\"https://github.com/mvllow/nvim-highlight-colors/assets/1474821/bf8c0d2d-552c-485a-aeba-b3d281c8c333\" alt=\"Background highlights for named colors, CSS variables, and Tailwind CSS colors\" /\u003e\n\n**Foreground**\n\n\u003cimg width=\"640\" src=\"https://github.com/mvllow/nvim-highlight-colors/assets/1474821/4e2e9c7d-552b-4558-ab79-4fe37738f869\" alt=\"Foreground highlights for named colors, CSS variables, and Tailwind CSS colors\" /\u003e\n\n**Virtual text**\n\n\u003cimg width=\"640\" src=\"https://github.com/mvllow/nvim-highlight-colors/assets/1474821/536b16e4-04ad-4ede-95f5-c1855386c294\" alt=\"Virtual text highlights for named colors, CSS variables, and Tailwind CSS colors\" /\u003e\n\n**nvim-cmp integration**\n\n![image](https://github.com/brenoprata10/nvim-highlight-colors/assets/26099427/0f6858fe-f7e2-4710-a22f-c3b3a455f74b)\n\n\n## Commands\n\n| Command                     | Description                  |\n| :-------------------------- | :--------------------------- |\n| `:HighlightColors On`       | Turn highlights on           |\n| `:HighlightColors Off`      | Turn highlights off          |\n| `:HighlightColors Toggle`   | Toggle highlights            |\n| `:HighlightColors IsActive` | Highlights active / disabled |\n\nCommands are also available in lua:\n\n```lua\nrequire(\"nvim-highlight-colors\").turnOn()\nrequire(\"nvim-highlight-colors\").turnOff()\nrequire(\"nvim-highlight-colors\").toggle()\nrequire(\"nvim-highlight-colors\").is_active()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrenoprata10%2Fnvim-highlight-colors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrenoprata10%2Fnvim-highlight-colors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrenoprata10%2Fnvim-highlight-colors/lists"}