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

Commit 2d29a51

Browse files
committed
fix: Make sure to schedule commands appropriately
1 parent 03b456e commit 2d29a51

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lua/diagnostic.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function M.modifyCallback()
5454
return
5555
end
5656
end
57+
5758
M.publish_diagnostics(bufnr)
5859
end
5960
end
@@ -71,7 +72,7 @@ function M.publish_diagnostics(bufnr)
7172
if #vim.lsp.buf_get_clients() == 0 then return end
7273
local result = M.bufferDiagnostic[bufnr]
7374
if result == nil then return end
74-
vim.api.nvim_command('lexpr []')
75+
vim.fn.setloclist(0, {}, 'r')
7576
vim.lsp.util.buf_clear_diagnostics(bufnr)
7677
vim.lsp.util.buf_diagnostics_save_positions(bufnr, result.diagnostics)
7778
util.buf_diagnostics_save_positions(bufnr, result.diagnostics)
@@ -83,7 +84,10 @@ function M.publish_diagnostics(bufnr)
8384
util.buf_diagnostics_virtual_text(bufnr, result.diagnostics)
8485
end
8586
M.diagnostics_loclist(result)
86-
vim.api.nvim_command("doautocmd User LspDiagnosticsChanged")
87+
88+
vim.schedule_wrap(function()
89+
vim.api.nvim_command("doautocmd User LspDiagnosticsChanged")
90+
end)
8791
end
8892

8993
function M.refresh_diagnostics()

0 commit comments

Comments
 (0)