| name | nvim-highlight |
| description | Add custom highlight groups for plugins. |
| TRIGGER | add highlight, customize theme, theme colors, highlight group |
Theme Highlight Customization
Add custom highlight groups for plugins in lua/plugins/colorscheme.lua.
Location
All theme customization is in the modus-themes configuration:
-- lua/plugins/colorscheme.lua
{
'miikanissi/modus-themes.nvim',
config = function()
require('modus-themes').setup({
on_highlights = function(highlights, colors)
-- Add custom highlights here
end,
})
end,
}
Highlight Pattern
Basic Highlight
on_highlights = function(highlights, colors)
highlights.GroupName = { fg = colors.blue, bg = colors.bg_dim }
end
With Attributes
highlights.GroupName = {
fg = colors.magenta,
bg = colors.bg_main,
bold = true,
italic = true,
underline = true,
strikethrough = true,
nocombine = true, -- Don't combine with other highlights
}
Link to Existing Group
highlights.NewGroup = { link = 'ExistingGroup' }
Available Colors
The colors parameter provides these colors:
Foreground/Background
fg_main- Main foregroundfg_dim- Dimmed foregroundbg_main- Main background (#f5f5f5 light, #141414 dark)bg_dim- Dimmed backgroundbg_active- Active element backgroundbg_hl_line- Highlighted line background
UI Colors
border- Border colorcursor- Cursor color
Semantic Colors
Base colors:
blue,cyan,green,magenta,red,yellow
Variants (warmer/cooler):
blue_warmer,blue_coolercyan_warmer,cyan_coolergreen_warmer,green_coolermagenta_warmer,magenta_coolerred_warmer,red_cooleryellow_warmer,yellow_cooler
Intensity variants:
blue_faint,blue_intensecyan_faint,cyan_intense- (and so on for other colors)
Light/Dark Conditional
Check background color to differentiate light and dark:
on_highlights = function(highlights, colors)
if colors.bg_main == '#f5f5f5' then
-- Light mode specific
highlights.LineNr = { fg = colors.fg_dim, bg = '#efefef' }
elseif colors.bg_main == '#141414' then
-- Dark mode specific
highlights.LineNr = { fg = colors.fg_dim, bg = '#1a1a1a' }
end
end
Plugin Highlight Examples
Indent Guides (indent-blankline)
highlights.IblIndent = { fg = colors.bg_active, nocombine = true }
highlights.IblScope = { fg = colors.cyan_faint, nocombine = true }
Fuzzy Finder (fzf-lua)
-- Preview window
highlights.FzfLuaPreviewNormal = { bg = colors.bg_dim }
highlights.FzfLuaPreviewBorder = { fg = colors.border, bg = colors.bg_dim }
-- Match highlighting
highlights.FzfLuaFzfMatch = { fg = colors.magenta, bold = true }
highlights.FzfLuaFzfPointer = { fg = colors.magenta_cooler }
highlights.FzfLuaFzfMarker = { fg = colors.green }
-- Path display
highlights.FzfLuaDirPart = { fg = colors.fg_dim }
highlights.FzfLuaFilePart = { fg = colors.fg_main }
File Explorer (nvim-tree)
-- Git status
highlights.NvimTreeGitStaged = { fg = colors.green }
highlights.NvimTreeGitRenamed = { fg = colors.magenta }
highlights.NvimTreeGitIgnored = { fg = colors.fg_dim }
-- Folders
highlights.NvimTreeFolderName = { fg = colors.blue }
highlights.NvimTreeOpenedFolderName = { fg = colors.blue, bold = true }
Completion Menu (blink.cmp)
-- Menu
highlights.BlinkCmpMenu = { bg = colors.bg_dim }
highlights.BlinkCmpMenuBorder = { fg = colors.border, bg = colors.bg_dim }
highlights.BlinkCmpMenuSelection = { bg = colors.bg_active }
-- LSP kinds
highlights.BlinkCmpKindFunction = { fg = colors.magenta }
highlights.BlinkCmpKindVariable = { fg = colors.cyan }
highlights.BlinkCmpKindKeyword = { fg = colors.blue }
Diagnostics (trouble.nvim)
highlights.TroubleNormal = { bg = colors.bg_dim }
highlights.TroubleDiagnosticsError = { fg = colors.red }
highlights.TroubleDiagnosticsWarn = { fg = colors.yellow }
highlights.TroubleDiagnosticsInfo = { fg = colors.blue }
highlights.TroubleDiagnosticsHint = { fg = colors.cyan }
Git Diff (diffview.nvim)
highlights.DiffAdd = { bg = colors.bg_added }
highlights.DiffDelete = { bg = colors.bg_removed }
highlights.DiffChange = { bg = colors.bg_changed }
highlights.DiffText = { bg = colors.bg_changed_intense }
Common Highlight Groups
LSP
LspReferenceText- References to symbol under cursorLspReferenceRead- Read access to symbolLspReferenceWrite- Write access to symbolLspSignatureActiveParameter- Active parameter in signature
Treesitter
@variable- Variables@function- Functions@keyword- Keywords@string- Strings@comment- Comments@parameter- Parameters
Diagnostics
DiagnosticError- Error diagnosticsDiagnosticWarn- Warning diagnosticsDiagnosticInfo- Info diagnosticsDiagnosticHint- Hint diagnostics
UI
FloatBorder- Floating window bordersNormalFloat- Floating window backgroundPmenu- Popup menuPmenuSel- Popup menu selectionStatusLine- Status lineTabLine- Tab line
Finding Highlight Groups
Under Cursor
:Inspect
Shows highlight group and treesitter info at cursor.
All Groups
:so $VIMRUNTIME/syntax/hitest.vim
Shows all highlight groups.
Plugin Groups
Check plugin documentation or source code for highlight group names.
Workflow
- Identify plugin highlight groups (
:Inspect, docs, or source) - Add highlights to
on_highlightsfunction incolorscheme.lua - Choose appropriate colors from
colorsparameter - Test in both light and dark modes if needed
- Reload config with
:so %or restart Neovim - Run
make lintandmake formatto validate
Notes
- Highlights are applied after theme loads
- Use semantic colors (blue, green, etc.) not hex values
- Test in both light and dark modes
- Use
nocombine = truefor subtle elements like indent guides - Link to existing groups when appropriate for consistency
- Check existing highlights in the file for examples