feat: add user autocmds before and after performing actions (#310)

This commit is contained in:
Steven Arcangeli 2024-03-17 19:50:31 -07:00
parent 32e18df30f
commit e462a34465

View file

@ -367,6 +367,10 @@ end
---@param actions oil.Action[]
---@param cb fun(err: nil|string)
M.process_actions = function(actions, cb)
vim.api.nvim_exec_autocmds(
"User",
{ pattern = "OilActionsPre", modeline = false, data = { actions = actions } }
)
local did_complete = lsp_helpers.will_perform_file_operations(actions)
-- Convert some cross-adapter moves to a copy + delete
@ -387,11 +391,15 @@ M.process_actions = function(actions, cb)
local finished = false
local progress = Progress.new()
local function finish(...)
local function finish(err)
if not finished then
finished = true
progress:close()
cb(...)
vim.api.nvim_exec_autocmds(
"User",
{ pattern = "OilActionsPost", modeline = false, data = { err = err, actions = actions } }
)
cb(err)
end
end