Skip to content

Commit

Permalink
Run hook functions within vim.schedule()
Browse files Browse the repository at this point in the history
See #103
  • Loading branch information
jalvesaq committed Apr 1, 2024
1 parent 7b31cfa commit cb65c3b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lua/r/browser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lua/r/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lua/r/run.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit cb65c3b

Please sign in to comment.