diff --git a/lua/diagnostic.lua b/lua/diagnostic.lua index 3b64dca..b5d87aa 100644 --- a/lua/diagnostic.lua +++ b/lua/diagnostic.lua @@ -103,6 +103,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 @@ -120,7 +126,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