feat(actions): add close_float to close only floating oil windows
Problem: users who bind <Esc> 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
This commit is contained in:
parent
ce64ae18de
commit
f6bcdda988
1 changed files with 16 additions and 0 deletions
|
|
@ -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 cmd string
|
||||||
---@param silent? boolean
|
---@param silent? boolean
|
||||||
local function cd(cmd, silent)
|
local function cd(cmd, silent)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue