Skip to content

Instantly share code, notes, and snippets.

View lkhphuc's full-sized avatar

Phúc H. Lê Khắc lkhphuc

View GitHub Profile
@lkhphuc
lkhphuc / nvim_highlight_update.md
Last active December 25, 2023 06:20
A simple utility function to override and update any colorscheme in Neovim.

I like to have my neovim to bold the language keywords, italicize the comments, or both italicize and bold all the builtin functions, type or constants etc. And I want this to be consistent across colorschemes.

In vim/neovim, to update a highlight group it is as simple as highlight HighlightGroupToModified gui=bold,italic,underline. But this is problematic if the HighlightGroupToModified is defined as a link to other highlight group. For example highlight TSInclude might be linked to Include by your colorscheme, so executing hi TSInclude gui=bold will apply bold to TSInclude but wipe out any foreground and background color information that was originally defined by linking to Include highlight group.

Since every colorschemes can arbitrarily choose to define a highlight group explicitly or by linking, adding hi TSConstant gui=bold to your config are bound to break when you switch colorschemes. A manual approach is to recursively go down the linking chain defined by colorscheme, e.g TSConstant