From cb65c3b288d22212e248d2cb8bf3ca46baa7201c Mon Sep 17 00:00:00 2001 From: Jakson Alves de Aquino Date: Mon, 1 Apr 2024 11:05:53 -0300 Subject: [PATCH] Run hook functions within vim.schedule() See #103 --- lua/r/browser.lua | 4 +++- lua/r/config.lua | 4 +++- lua/r/run.lua | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lua/r/browser.lua b/lua/r/browser.lua index 989956c8..0182b4e6 100644 --- a/lua/r/browser.lua +++ b/lua/r/browser.lua @@ -304,7 +304,9 @@ M.start = function(_) start_OB() running_objbr = false - if config.hook.after_ob_open then config.hook.after_ob_open() end + if config.hook.after_ob_open then + vim.schedule(function() config.hook.after_ob_open() end) + end end --- Return the active pane of the Object Browser diff --git a/lua/r/config.lua b/lua/r/config.lua index 0a0e9907..5551922c 100644 --- a/lua/r/config.lua +++ b/lua/r/config.lua @@ -809,7 +809,9 @@ M.real_setup = function() gtime = (uv.hrtime() - gtime) / 1000000000 require("r.edit").add_to_debug_info("global setup", gtime, "Time") - if config.hook.after_config then config.hook.after_config() end + if config.hook.after_config then + vim.schedule(function() config.hook.after_config() end) + end end --- Return the table with the final configure variables: the default values diff --git a/lua/r/run.lua b/lua/r/run.lua index 1fbec0fd..005634bb 100644 --- a/lua/r/run.lua +++ b/lua/r/run.lua @@ -301,7 +301,9 @@ M.set_nvimcom_info = function(nvimcomversion, rpid, wid, r_info) end vim.g.R_Nvim_status = 7 - if config.hook.after_R_start then config.hook.after_R_start() end + if config.hook.after_R_start then + vim.schedule(function() config.hook.after_R_start() end) + end send.set_send_cmd_fun() end