70
70
--- @return table
71
71
function M .filter_diags_under_cursor (opts , buf , diagnostics )
72
72
if
73
- not vim .api .nvim_buf_is_valid (buf )
74
- or vim .api .nvim_get_current_buf () ~= buf
75
- or not diagnostics
76
- or # diagnostics == 0
73
+ not vim .api .nvim_buf_is_valid (buf )
74
+ or vim .api .nvim_get_current_buf () ~= buf
75
+ or not diagnostics
76
+ or # diagnostics == 0
77
77
then
78
78
return {}
79
79
end
130
130
--- @param diagnostics table
131
131
local function update_diagnostics_cache (opts , bufnr , diagnostics )
132
132
if vim .tbl_isempty (diagnostics ) then
133
- -- The event doesn't contain the associated namespace of the diagnostics,
134
- -- meaning we can't know which namespace was cleared. We thus have to get
133
+ -- The event doesn't contain the associated namespace of the diagnostics,
134
+ -- meaning we can't know which namespace was cleared. We thus have to get
135
135
-- the diagnostics through normal means.
136
136
local diags = vim .diagnostic .get (bufnr )
137
137
table.sort (diags , function (a , b )
@@ -148,7 +148,7 @@ local function update_diagnostics_cache(opts, bufnr, diagnostics)
148
148
149
149
-- Find the namespaces of the incoming diagnostics.
150
150
-- Use the namespace and not the source because the event is triggered per namespace,
151
- -- while the source field can be unreliable (e.g. Deno LSP seems to switch between
151
+ -- while the source field can be unreliable (e.g. Deno LSP seems to switch between
152
152
-- deno and deno-ts).
153
153
local namespaces = {}
154
154
for _ , diag in ipairs (diagnostics ) do
@@ -184,13 +184,20 @@ local function apply_virtual_texts(opts, bufnr)
184
184
end
185
185
186
186
if
187
- not M .user_toggle_state
188
- or not (M .enabled and vim .diagnostic .is_enabled () and vim .api .nvim_buf_is_valid (bufnr ))
187
+ not M .user_toggle_state
188
+ or not (M .enabled and vim .diagnostic .is_enabled () and vim .api .nvim_buf_is_valid (bufnr ))
189
189
then
190
190
extmarks .clear (bufnr )
191
191
return
192
192
end
193
193
194
+ local mode = vim .api .nvim_get_mode ().mode
195
+ if M .enabled and vim .tbl_contains (DISABLED_MODES , mode ) then
196
+ disable ()
197
+ extmarks .clear (event .buf )
198
+ return
199
+ end
200
+
194
201
-- Get diagnostics and clear them if needed
195
202
local diagnostics = diagnostics_cache [bufnr ] or {}
196
203
if vim .tbl_isempty (diagnostics ) then
@@ -218,13 +225,11 @@ local function apply_virtual_texts(opts, bufnr)
218
225
219
226
if lnum == cursor_line then
220
227
virt_lines , offset , need_to_be_under =
221
- virtual_text_forge .from_diagnostics (opts , diags , diagnostic_pos , bufnr )
228
+ virtual_text_forge .from_diagnostics (opts , diags , diagnostic_pos , bufnr )
222
229
else
223
- local chunks = chunk_utils .get_chunks (opts , diags , 1 , diagnostic_pos [1 ], cursor_line ,
224
- bufnr )
230
+ local chunks = chunk_utils .get_chunks (opts , diags , 1 , diagnostic_pos [1 ], cursor_line , bufnr )
225
231
local max_width = chunk_utils .get_max_width_from_chunks (chunks .chunks )
226
- virt_lines , offset , need_to_be_under = virtual_text_forge .from_diagnostic (opts , chunks , 1 ,
227
- max_width , 1 )
232
+ virt_lines , offset , need_to_be_under = virtual_text_forge .from_diagnostic (opts , chunks , 1 , max_width , 1 )
228
233
end
229
234
230
235
table.insert (diags_dims , { lnum , # virt_lines })
0 commit comments