Skip to content

Commit

Permalink
feat: improve arrow for under diagnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
rachartier committed Jul 13, 2024
1 parent 8f1708e commit abe21bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions lua/tiny-inline-diagnostic/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ local function get_arrow_from_chunk(

if need_to_be_under then
arrow = opts.signs.up_arrow
arrow = string.rep(" ", cursorpos[2] - math.floor(#arrow / 2) + 1) .. arrow
chunck = {
{ " ", "None" },
{ arrow, "TinyInlineDiagnosticVirtualTextArrow" },
Expand Down Expand Up @@ -223,7 +222,6 @@ local function forge_virt_texts_from_diagnostic(opts, cursorpos, index_diag, dia
need_to_be_under
)


if type(chunck_arrow[1]) == "table" then
table.insert(all_virtual_texts, chunck_arrow)
else
Expand Down Expand Up @@ -353,13 +351,28 @@ local function apply_diagnostics_virtual_texts(opts, event)
)
end


local win_col = vim.fn.virtcol("$")

if need_to_be_under then
win_col = 0
end

if need_to_be_under then
vim.api.nvim_buf_set_extmark(event.buf, diagnostic_ns, curline + 1, cursorpos[2], {
id = curline + 100,
line_hl_group = "CursorLine",
virt_text_pos = "overlay",
virt_text_win_col = cursorpos[2] - 1,
virt_text = virt_lines[2],
priority = virt_prorioty,
strict = false,
})
table.remove(virt_lines, 2)
if not diag_overflow_last_line then
curline = curline + 1
end
end

if diag_overflow_last_line then
local other_virt_lines = {}
for i, line in ipairs(virt_lines) do
Expand All @@ -368,6 +381,7 @@ local function apply_diagnostics_virtual_texts(opts, event)
table.insert(other_virt_lines, line)
end
end

vim.api.nvim_buf_set_extmark(event.buf, diagnostic_ns, curline, 0, {
id = curline + 1,
line_hl_group = "CursorLine",
Expand Down
2 changes: 1 addition & 1 deletion lua/tiny-inline-diagnostic/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local default_config = {
right = "",
diag = "",
arrow = "",
up_arrow = "",
up_arrow = "",
vertical = "",
vertical_end = ""
},
Expand Down

0 comments on commit abe21bf

Please sign in to comment.