fix(nvim): better handle setting culhl for signs

This commit is contained in:
Price Hiller 2024-02-02 21:38:52 -06:00
parent ddb4679ee9
commit bfae2cb59f
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8
3 changed files with 8 additions and 10 deletions

View File

@ -65,6 +65,7 @@ return {
CursorLineNr = { fg = colors.roninYellow, bg = palette.theme.ui.bg_p1 },
CursorLineFold = { fg = colors.crystalBlue, bg = palette.theme.ui.bg_p1 },
CursorLineSign = { bg = palette.theme.ui.bg_p1 },
LightBulbSign = { fg = colors.crystalBlue, bg = palette.theme.ui.bg_p1 },
WinSeparator = { fg = colors.fujiGray },
StatusLine = { fg = colors.fujiWhite, bg = colors.sumiInk0 },
WinBar = { fg = colors.fujiWhite, bg = nil },

View File

@ -79,16 +79,13 @@ return {
opts = function()
local text_icon = ""
local nvim_lightbulb = require("nvim-lightbulb")
vim.fn.sign_define(
"LightBulbSign",
{ text = text_icon, numhl = "DiagnosticSignHint", texthl = "DiagnosticSignHint", priority = 9 }
)
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
callback = nvim_lightbulb.update_lightbulb,
})
return {
link_highlights = false,
sign = {
priority = 9,
enabled = true,
text = text_icon,
},
}

View File

@ -8,20 +8,20 @@ return {
-- HACK: Ensure all signs get the correct CursorLineSign set to their "culhl" value
-- This, in effect, extends the CursorLine background highlight into the signcolumn
vim.uv.new_timer():start(
50,
1000,
100,
100,
vim.schedule_wrap(function()
-- Make all signs support "CusorLine.*" highlights
local signs_defined = vim.fn.sign_getdefined()
local signs_defined = vim.fn.sign_getdefined() or {}
if #signs_defined == last_sign_def_len or #signs_defined == 0 then
return
end
last_sign_def_len = signs_defined
last_sign_def_len = #signs_defined
local bg = vim.api.nvim_get_hl(0, { name = "SignColumn", link = false }).bg
local cl_bg = vim.api.nvim_get_hl(0, { name = "CursorLineSign", link = false }).bg
for _, sign in ipairs(signs_defined) do
local name = sign.texthl
if name then
if name and not sign.culhl then
local hl = vim.api.nvim_get_hl(0, { name = name, link = false })
vim.api.nvim_set_hl(0, name, { fg = hl.fg, bg = bg })
name = name .. "Cul"