@@ -70,28 +70,29 @@ function M.buf_diagnostics_save_positions(bufnr, diagnostics)
70
70
end
71
71
72
72
function M .buf_diagnostics_virtual_text (bufnr , diagnostics )
73
- local buffer_line_diagnostics = all_buffer_diagnostics [bufnr ]
74
73
local prefix = api .nvim_get_var (' diagnostic_virtual_text_prefix' )
75
74
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 ]
80
77
if not buffer_line_diagnostics then
81
78
return
82
79
end
83
- for line , line_diags in pairs (buffer_line_diagnostics ) do
80
+ for line , line_diagnostics in pairs (buffer_line_diagnostics ) do
84
81
local virt_texts = {}
85
82
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 ]})
88
86
end
89
- local last = line_diags [ # line_diags ]
87
+
90
88
-- TODO(ashkan) use first line instead of subbing 2 spaces?
91
89
if api .nvim_get_var (' diagnostic_trimmed_virtual_text' ) ~= nil then
92
90
local trimmed_text = last .message :gsub (" \r " , " " ):gsub (" \n " , " " )
93
91
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
95
96
trimmed_text = trimmed_text .. " ..."
96
97
end
97
98
table.insert (virt_texts , {prefix .. " " .. trimmed_text , severity_highlights [last .severity ]})
0 commit comments