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

Commit 8fa373c

Browse files
committed
Change call to refresh_diagnostics() to be delayed
Changing the location list from autocmd can cause problems. As a workaround, delay the call to refresh_diagnostics().
1 parent 0367068 commit 8fa373c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lua/diagnostic.lua

+7-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ function M.refresh_diagnostics()
9898
M.publish_diagnostics(bufnr)
9999
end
100100

101+
function M.on_BufEnter()
102+
vim.schedule(function()
103+
M.refresh_diagnostics()
104+
end)
105+
end
106+
101107
function M.on_InsertLeave()
102108
M.refresh_diagnostics()
103109
end
@@ -115,7 +121,7 @@ M.on_attach = function(_, _)
115121
M.modifyCallback()
116122
vim.api.nvim_command [[augroup DiagnosticRefresh]]
117123
vim.api.nvim_command("autocmd! * <buffer>")
118-
vim.api.nvim_command [[autocmd BufEnter,BufWinEnter,TabEnter <buffer> lua require'diagnostic'.refresh_diagnostics()]]
124+
vim.api.nvim_command [[autocmd BufEnter,BufWinEnter,TabEnter <buffer> lua require'diagnostic'.on_BufEnter()]]
119125
vim.api.nvim_command [[augroup end]]
120126

121127
if vim.api.nvim_get_var('diagnostic_insert_delay') == 1 then

0 commit comments

Comments
 (0)