feat: add toggle_float function (#94)

This commit is contained in:
Steven Arcangeli 2023-04-29 08:16:18 -07:00
parent 4738d08a5f
commit 82c706822b
3 changed files with 27 additions and 0 deletions

View file

@ -337,6 +337,17 @@ M.open_float = function(dir)
end
end
---Open oil browser in a floating window, or close it if open
---@param dir nil|string When nil, open the parent of the current buffer, or the cwd if current buffer is not a file
M.toggle_float = function(dir)
local util = require("oil.util")
if util.is_oil_bufnr(0) and util.is_floating_win(0) then
vim.api.nvim_win_close(0, true)
else
M.open_float(dir)
end
end
---Open oil browser for a directory
---@param dir nil|string When nil, open the parent of the current buffer, or the cwd if current buffer is not a file
M.open = function(dir)