feat: migrate to vim.api.nvim_set_hl() #58
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Replace string-formatted
:highlightcommand with the native Lua APIvim.api.nvim_set_hl(). This change improves performance by avoiding command-string construction and enables full support for all keys supported invim.api.keyset.highlight.Breaking changes
This change breaks compatibility with user configs using the old format:
The
vim.api.keyset.highlighthas notguifield and instead uses separate booleans (bold, italic, etc.). This also allows specifying multiple styles simultaneously, which was not easily possible with the previous gui string field.This should be easy to update in configs, but it's worth calling out explicitly.
Config structure
This change also surfaces a broader design question:
While on_highlights will give users full control over all hl-group properties, the config’s styling-related options (bold, italic, etc.) feel increasingly limited—and possibly redundant.
My suggestion would be to:
a) Keep only a few top-level global toggles (e.g. italic = false, transparent = true) that apply across all groups
b) Drop the plugins section, which is already somewhat outdated and less reliable than editing highlight groups directly via on_highlights
Or another option that I see is to expose
vim.api.keyset.highlightfor each config style, so it will be notplugins.cmp.match = "italic"butplugins.cmp.match = { italic = true }. But it feels like aliasing already existing API of hl-groups.Now that this is taking shape, it feels like a v2-level change. I'm uncertain about how best to approach backward compatibility:
I’m leaning toward a clean break—most users likely won’t be affected much, and it would simplify the code and config model.
That said, I’d really appreciate your input and overall vision for this. I’m happy to adapt and move forward with whichever direction we choose.