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

Commit

Permalink
Merge pull request #57 from erw7/fix-autocmd-change-loclist
Browse files Browse the repository at this point in the history
Change call to refresh_diagnostics() to be delayed
  • Loading branch information
haorenW1025 authored Oct 1, 2020
2 parents 49abd2e + 8fa373c commit bef1c61
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 @@ -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
Expand All @@ -120,7 +126,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 bef1c61

Please sign in to comment.