Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Commit 5e1ce55

Browse files
authored
Merge pull request #50 from el-iot/fix_diagnostics_not_refreshing
Fix diagnostics not refreshing
2 parents d7734f1 + eb8a4d4 commit 5e1ce55

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lua/diagnostic/util.lua

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,29 @@ function M.buf_diagnostics_save_positions(bufnr, diagnostics)
7070
end
7171

7272
function M.buf_diagnostics_virtual_text(bufnr, diagnostics)
73-
local buffer_line_diagnostics = all_buffer_diagnostics[bufnr]
7473
local prefix = api.nvim_get_var('diagnostic_virtual_text_prefix')
7574
local spaces = string.rep(" ", api.nvim_get_var('space_before_virtual_text'))
76-
if not buffer_line_diagnostics then
77-
M.buf_diagnostics_save_positions(bufnr, diagnostics)
78-
end
79-
buffer_line_diagnostics = all_buffer_diagnostics[bufnr]
75+
M.buf_diagnostics_save_positions(bufnr, diagnostics)
76+
local buffer_line_diagnostics = all_buffer_diagnostics[bufnr]
8077
if not buffer_line_diagnostics then
8178
return
8279
end
83-
for line, line_diags in pairs(buffer_line_diagnostics) do
80+
for line, line_diagnostics in pairs(buffer_line_diagnostics) do
8481
local virt_texts = {}
8582
table.insert(virt_texts, {spaces})
86-
for i = 1, #line_diags - 1 do
87-
table.insert(virt_texts, {prefix, severity_highlights[line_diags[i].severity]})
83+
local last = line_diagnostics[#line_diagnostics]
84+
for i = 1, #line_diagnostics - 1 do
85+
table.insert(virt_texts, {prefix, severity_highlights[line_diagnostics[i].severity]})
8886
end
89-
local last = line_diags[#line_diags]
87+
9088
-- TODO(ashkan) use first line instead of subbing 2 spaces?
9189
if api.nvim_get_var('diagnostic_trimmed_virtual_text') ~= nil then
9290
local trimmed_text = last.message:gsub("\r", ""):gsub("\n", " ")
9391
trimmed_text = string.sub(trimmed_text, 1, api.nvim_get_var('diagnostic_trimmed_virtual_text'))
94-
if #trimmed_text == api.nvim_get_var('diagnostic_trimmed_virtual_text') and vim.g.diagnostic_trimmed_virtual_text ~= 0 then
92+
if (
93+
#trimmed_text == api.nvim_get_var('diagnostic_trimmed_virtual_text')
94+
and vim.g.diagnostic_trimmed_virtual_text ~= 0
95+
) then
9596
trimmed_text = trimmed_text.."..."
9697
end
9798
table.insert(virt_texts, {prefix.." "..trimmed_text, severity_highlights[last.severity]})

0 commit comments

Comments
 (0)