Skip to content

Commit e563f38

Browse files
committed
feat: add transparent cursorline option. Fixes #113
1 parent 15becb1 commit e563f38

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ require("tiny-inline-diagnostic").setup({
5656
preset = "modern",
5757

5858
transparent_bg = false, -- Set the background of the diagnostic to transparent
59+
transparent_cursorline = false, -- Set the background of the cursorline to transparent (only one the first diagnostic)
5960

6061
hi = {
6162
error = "DiagnosticError", -- Highlight group for error messages

lua/tiny-inline-diagnostic/highlights.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ end
153153

154154
---@param blend BlendOptions
155155
---@param default_hi DefaultHighlights
156-
function M.setup_highlights(blend, default_hi, transparent)
156+
function M.setup_highlights(blend, default_hi, transparent_bg, transparent_cursorline)
157157
-- Get base colors
158158
local colors = {
159159
error = get_highlight(default_hi.error),
@@ -162,15 +162,15 @@ function M.setup_highlights(blend, default_hi, transparent)
162162
hint = get_highlight(default_hi.hint),
163163
ok = get_highlight(default_hi.ok),
164164
arrow = get_highlight(default_hi.arrow),
165-
cursor_line = get_highlight("CursorLine"),
165+
cursor_line = transparent_cursorline and { bg = "None" } or get_highlight("CursorLine"),
166166
}
167167

168-
if not transparent then
169-
transparent = false
168+
if not transparent_bg then
169+
transparent_bg = false
170170
end
171171

172172
if blend.factor == 0 then
173-
transparent = true
173+
transparent_bg = true
174174
end
175175

176176
-- Get special colors
@@ -187,7 +187,7 @@ function M.setup_highlights(blend, default_hi, transparent)
187187
}
188188

189189
-- Create highlight groups
190-
local hi = create_highlight_groups(colors, blends, transparent)
190+
local hi = create_highlight_groups(colors, blends, transparent_bg)
191191

192192
create_mixed_highlights(hi)
193193

lua/tiny-inline-diagnostic/init.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ local presets = require("tiny-inline-diagnostic.presets")
1313
local default_config = {
1414
preset = "modern",
1515
transparent_bg = false,
16+
transparent_cursorline = true,
1617
hi = {
1718
error = "DiagnosticError",
1819
warn = "DiagnosticWarn",
@@ -65,7 +66,7 @@ local function setup_colorscheme_handler(config)
6566
vim.api.nvim_create_autocmd("ColorScheme", {
6667
pattern = "*",
6768
callback = function()
68-
hi.setup_highlights(config.blend, config.hi, config.transparent_bg)
69+
hi.setup_highlights(config.blend, config.hi, config.transparent_bg, config.transparent_cursorline)
6970
end,
7071
})
7172
end
@@ -103,7 +104,7 @@ function M.setup(opts)
103104

104105
M.config = config
105106

106-
hi.setup_highlights(config.blend, config.hi, config.transparent_bg)
107+
hi.setup_highlights(config.blend, config.hi, config.transparent_bg, config.transparent_cursorline)
107108

108109
setup_colorscheme_handler(config)
109110
diag.set_diagnostic_autocmds(config)
@@ -123,7 +124,7 @@ function M.change(blend, highlights)
123124
hi = highlights or M.config.hi,
124125
})
125126

126-
hi.setup_highlights(config.blend, config.hi, config.transparent_bg)
127+
hi.setup_highlights(config.blend, config.hi, config.transparent_bg, config.transparent_cursorline)
127128
end
128129

129130
--- Enable the diagnostic display.

0 commit comments

Comments
 (0)