From f8b312d782094aebb1c34df6f76b04b69b5631ac Mon Sep 17 00:00:00 2001 From: Andreas Johansson Date: Wed, 17 Jun 2020 11:32:43 +0200 Subject: [PATCH 1/2] Fix LspDiagnosticsChanged not firing vim.schedule_wrap() returns a function that needs to be executed in order to schedule the actual execution of the function taken by schedule_wrap() --- lua/diagnostic.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/diagnostic.lua b/lua/diagnostic.lua index 91cd250..7555bcb 100644 --- a/lua/diagnostic.lua +++ b/lua/diagnostic.lua @@ -90,7 +90,7 @@ function M.publish_diagnostics(bufnr) vim.schedule_wrap(function() vim.api.nvim_command("doautocmd User LspDiagnosticsChanged") - end) + end)() end function M.refresh_diagnostics() From eca5f6e5c8f08f6c6aa406242cea2dc5e6637310 Mon Sep 17 00:00:00 2001 From: Andreas Johansson Date: Tue, 30 Jun 2020 09:12:52 +0200 Subject: [PATCH 2/2] Extract the changed event into a module function --- lua/diagnostic.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/diagnostic.lua b/lua/diagnostic.lua index 7555bcb..baa6148 100644 --- a/lua/diagnostic.lua +++ b/lua/diagnostic.lua @@ -87,11 +87,12 @@ function M.publish_diagnostics(bufnr) util.buf_diagnostics_virtual_text(bufnr, result.diagnostics) end M.diagnostics_loclist(result) + M.trigger_diagnostics_changed() +end - vim.schedule_wrap(function() +M.trigger_diagnostics_changed = vim.schedule_wrap(function() vim.api.nvim_command("doautocmd User LspDiagnosticsChanged") - end)() -end +end) function M.refresh_diagnostics() local bufnr = vim.api.nvim_win_get_buf(0)