diff --git a/lua/oil/actions.lua b/lua/oil/actions.lua index 6950dea..353ecda 100644 --- a/lua/oil/actions.lua +++ b/lua/oil/actions.lua @@ -84,4 +84,17 @@ M.toggle_hidden = { end, } +M.refresh = { + desc = "Refresh directory", + callback = function() + if vim.bo.modified then + local ok, choice = pcall(vim.fn.confirm, "Discard changes?", "No\nYes") + if not ok or choice ~= 2 then + return + end + end + vim.cmd.edit({ bang = true }) + end, +} + return M diff --git a/lua/oil/config.lua b/lua/oil/config.lua index 2be52f2..19fff9b 100644 --- a/lua/oil/config.lua +++ b/lua/oil/config.lua @@ -34,6 +34,7 @@ local default_config = { [""] = "actions.select_split", [""] = "actions.preview", [""] = "actions.close", + [""] = "actions.refresh", ["-"] = "actions.parent", ["_"] = "actions.open_cwd", ["`"] = "actions.cd",