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

Commit

Permalink
Change call to refresh_diagnostics() to be delayed
Browse files Browse the repository at this point in the history
Changing the location list from autocmd can cause problems. As a
workaround, delay the call to refresh_diagnostics().
  • Loading branch information
erw7 committed Sep 14, 2020
1 parent 0367068 commit 8fa373c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lua/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -115,7 +121,7 @@ M.on_attach = function(_, _)
M.modifyCallback()
vim.api.nvim_command [[augroup DiagnosticRefresh]]
vim.api.nvim_command("autocmd! * <buffer>")
vim.api.nvim_command [[autocmd BufEnter,BufWinEnter,TabEnter <buffer> lua require'diagnostic'.refresh_diagnostics()]]
vim.api.nvim_command [[autocmd BufEnter,BufWinEnter,TabEnter <buffer> lua require'diagnostic'.on_BufEnter()]]
vim.api.nvim_command [[augroup end]]

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

0 comments on commit 8fa373c

Please sign in to comment.