From f6bcdda988376520dd4d09063f289a329801b53e Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Fri, 20 Feb 2026 20:24:06 -0500 Subject: [PATCH] feat(actions): add close_float to close only floating oil windows Problem: users who bind to close oil in floating windows also accidentally close oil in split or fullscreen windows. There is no action that closes only a floating oil window and is a no-op otherwise. Solution: add a close_float action that checks vim.w.is_oil_win (the same window-local variable oil.close already uses to identify its own floating windows) before delegating to oil.close. Resolves: stevearc/oil.nvim#645 --- lua/oil/actions.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lua/oil/actions.lua b/lua/oil/actions.lua index 1c61999..edd44ba 100644 --- a/lua/oil/actions.lua +++ b/lua/oil/actions.lua @@ -179,6 +179,22 @@ M.close = { }, } +M.close_float = { + desc = "Close oil if the window is floating, otherwise do nothing", + callback = function(opts) + if vim.w.is_oil_win then + opts = opts or {} + oil.close(opts) + end + end, + parameters = { + exit_if_last_buf = { + type = "boolean", + desc = "Exit vim if oil is closed as the last buffer", + }, + }, +} + ---@param cmd string ---@param silent? boolean local function cd(cmd, silent)