diff --git a/lua/tiny-inline-diagnostic/diagnostic.lua b/lua/tiny-inline-diagnostic/diagnostic.lua index 1f4a04c..d12ddc6 100644 --- a/lua/tiny-inline-diagnostic/diagnostic.lua +++ b/lua/tiny-inline-diagnostic/diagnostic.lua @@ -102,7 +102,7 @@ local function apply_diagnostics_virtual_texts(opts, event) -- group all_diags by lnum local all_diags_grouped = {} for _, diag in ipairs(diagnostics) do - if diag.lnum >= fist_visually_seen_line and diag.lnum <= last_visually_seen_line then + if diag.lnum >= fist_visually_seen_line - 1 and diag.lnum <= last_visually_seen_line then if all_diags_grouped[diag.lnum] == nil then all_diags_grouped[diag.lnum] = {} end @@ -110,6 +110,8 @@ local function apply_diagnostics_virtual_texts(opts, event) end end + local cursor_line = vim.api.nvim_win_get_cursor(0)[1] - 1 + for lnum, line_diags in pairs(all_diags_grouped) do if line_diags == nil then return @@ -122,7 +124,6 @@ local function apply_diagnostics_virtual_texts(opts, event) local virt_priority = opts.options.virt_texts.priority local virt_lines, offset, need_to_be_under - local cursor_line = vim.api.nvim_win_get_cursor(0)[1] - 1 if opts.options.multiple_diag_under_cursor and lnum == cursor_line then virt_lines, offset, need_to_be_under = diff --git a/lua/tiny-inline-diagnostic/highlights.lua b/lua/tiny-inline-diagnostic/highlights.lua index a9fe495..69b2eab 100644 --- a/lua/tiny-inline-diagnostic/highlights.lua +++ b/lua/tiny-inline-diagnostic/highlights.lua @@ -10,18 +10,21 @@ local function get_hi(name) return { fg = utils.int_to_hex(hi.fg), bg = utils.int_to_hex(hi.bg), + italic = hi.italic, } end --- Function to setup highlights for diagnostics. -- @param blend table - The table of blend options, which includes the blend factor. -- @param default_hi table - The table of default highlights, which includes the colors for each diagnostic type, the arrow, and the background. +-- @param italics boolean - Whether to use italics for the diagnostics. function M.setup_highlights(blend, default_hi) local colors = { error = get_hi(default_hi.error), warn = get_hi(default_hi.warn), info = get_hi(default_hi.info), hint = get_hi(default_hi.hint), + ok = get_hi(default_hi.ok), arrow = get_hi(default_hi.arrow), } @@ -52,10 +55,11 @@ function M.setup_highlights(blend, default_hi) } local hi = { - TinyInlineDiagnosticVirtualTextError = { bg = blends.error, fg = colors.error.fg }, - TinyInlineDiagnosticVirtualTextWarn = { bg = blends.warn, fg = colors.warn.fg }, - TinyInlineDiagnosticVirtualTextInfo = { bg = blends.info, fg = colors.info.fg }, - TinyInlineDiagnosticVirtualTextHint = { bg = blends.hint, fg = colors.hint.fg }, + TinyInlineDiagnosticVirtualTextError = { bg = blends.error, fg = colors.error.fg, italic = colors.error.italic }, + TinyInlineDiagnosticVirtualTextWarn = { bg = blends.warn, fg = colors.warn.fg, italic = colors.warn.italic }, + TinyInlineDiagnosticVirtualTextInfo = { bg = blends.info, fg = colors.info.fg, italic = colors.info.italic }, + TinyInlineDiagnosticVirtualTextHint = { bg = blends.hint, fg = colors.hint.fg, italic = colors.hint.italic }, + TinyInlineDiagnosticVirtualTextOk = { bg = blends.hint, fg = colors.hint.fg, italic = colors.ok.italic }, TinyInlineDiagnosticVirtualTextArrow = { bg = colors.background, fg = colors.arrow.fg },