From d019d38a3ef4926308735a00bd919a5666c464b6 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Tue, 3 Jan 2023 23:08:52 -0800 Subject: [PATCH] feat: Use to refresh directory (#7) --- lua/oil/actions.lua | 13 +++++++++++++ lua/oil/config.lua | 1 + 2 files changed, 14 insertions(+) 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",