diff --git a/lua/diagnostic.lua b/lua/diagnostic.lua index 2ff67af..397f36b 100644 --- a/lua/diagnostic.lua +++ b/lua/diagnostic.lua @@ -98,6 +98,12 @@ function M.refresh_diagnostics() M.publish_diagnostics(bufnr) end +function M.on_BufEnter() + vim.schedule(function() + M.refresh_diagnostics() + end) +end + function M.on_InsertLeave() M.refresh_diagnostics() end @@ -115,7 +121,7 @@ M.on_attach = function(_, _) M.modifyCallback() vim.api.nvim_command [[augroup DiagnosticRefresh]] vim.api.nvim_command("autocmd! * ") - vim.api.nvim_command [[autocmd BufEnter,BufWinEnter,TabEnter lua require'diagnostic'.refresh_diagnostics()]] + vim.api.nvim_command [[autocmd BufEnter,BufWinEnter,TabEnter lua require'diagnostic'.on_BufEnter()]] vim.api.nvim_command [[augroup end]] if vim.api.nvim_get_var('diagnostic_insert_delay') == 1 then