[Question] Does built-in linking take precedence over the values set in the setup function? #195
-
I did an experiment by setting: highlights = {
["@keyword"] = { fg = "${purple}", style = "bold" },
}
-- Set "@keyword" while leaving the "Keyword" highlight group in its default value The I expected the The settings in the setup function will only apply if the group isn't internally (hard coded?) linked to other groups. E.g: highlights = {
["@conditional"] = {fg = "${purple}", style = "bold"}, -- this one works
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Yep you're right. I can confirm this too. It stems from this PR which I merged a few weeks back. The idea behind the PR was to add the ability to add Thanks for raising. |
Beta Was this translation helpful? Give feedback.
-
I apologize for any confusion caused.Here my suggestion for this issue: We can use the values of the original highlight group and apply them to the linked highlight group along with the user's configuration. This way, we would preserve the configuration set by the colorscheme while also incorporating the user's configuration. compile.lua local function get_hl(...)
local group = vim.api.nvim_get_hl(...)
if group.link then
return get_hl(0, { name = group.link, link = true })
end
return group
end config_spec.vim ['@keyword'] = { fg = "${purple}", style = "bold" }, config_spec.lua it("should be able to override linked highlight group", function()
local output = vim.api.nvim_get_hl(0, { name = "@keyword" })
assert.is_nil(output.link)
assert.are.same("#d55fde", hex(output.fg))
assert.is_true(output.bold)
end) cc: @olimorris |
Beta Was this translation helpful? Give feedback.
-
@maxmx03 Thanks for the response. I also discovered that for some highlight groups like
But if we forego the link and set the values directly, it works. As in:
This is a bit counter-intuitive, to be honest. So far, there doesn't seem to be a uniform behavior that applies for these highlights. |
Beta Was this translation helpful? Give feedback.
Yep you're right. I can confirm this too. It stems from this PR which I merged a few weeks back.
The idea behind the PR was to add the ability to add
italic = true, bold = true
styling options and to extend existing highlight groups. In hindsight, most users want to simply overwrite the default. Will transfer this to an issue and publish a fix.Thanks for raising.