Skip to content

Commit 3096671

Browse files
authored
fix: check for cursorline visibility (#165)
vim.opt.cursorline isn't enough to check if the cursorline is visible, since vim.opt.cursorlineopt can be set to "number", in which case the cursorline isn't truly visible, making the background behind the displayed diagnostics look strange
1 parent d9d12d4 commit 3096671

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

lua/tiny-inline-diagnostic/highlights.lua

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ local function get_mixing_color(color)
7272
return get_highlight(color).bg
7373
end
7474

75+
---Check if the cursorline is visible
76+
---@return boolean
77+
local function is_cursorline_visible()
78+
if vim.opt.cursorline:get() then
79+
local cursorline_opt = vim.opt.cursorlineopt:get()
80+
return not (#cursorline_opt == 1 and cursorline_opt[1] == "number")
81+
end
82+
83+
return false
84+
end
85+
7586
---@param blend BlendOptions
7687
---@param default_hi DefaultHighlights
7788
function M.setup_highlights(blend, default_hi, transparent_bg)
@@ -84,10 +95,10 @@ function M.setup_highlights(blend, default_hi, transparent_bg)
8495
end
8596

8697
local cursorline_hl = get_highlight("CursorLine")
87-
local is_cursorline_enabled = vim.opt.cursorline:get()
98+
local cursorline_is_visible = is_cursorline_visible()
8899
local has_cursorline_bg = cursorline_hl.bg ~= "None"
89100

90-
local cursor_line_color = (is_cursorline_enabled and has_cursorline_bg) and cursorline_hl
101+
local cursor_line_color = (cursorline_is_visible and has_cursorline_bg) and cursorline_hl
91102
or { bg = "None" }
92103

93104
local colors = {

0 commit comments

Comments
 (0)