feat: add toggle_float function (#94)
This commit is contained in:
parent
4738d08a5f
commit
82c706822b
3 changed files with 27 additions and 0 deletions
|
|
@ -321,6 +321,15 @@ Open oil browser in a floating window
|
|||
| ----- | ------------- | ------------------------------------------------------------------------------------------- |
|
||||
| dir | `nil\|string` | When nil, open the parent of the current buffer, or the cwd if current buffer is not a file |
|
||||
|
||||
### toggle_float(dir)
|
||||
|
||||
`toggle_float(dir)` \
|
||||
Open oil browser in a floating window, or close it if open
|
||||
|
||||
| Param | Type | Desc |
|
||||
| ----- | ------------- | ------------------------------------------------------------------------------------------- |
|
||||
| dir | `nil\|string` | When nil, open the parent of the current buffer, or the cwd if current buffer is not a file |
|
||||
|
||||
### open(dir)
|
||||
|
||||
`open(dir)` \
|
||||
|
|
|
|||
|
|
@ -175,6 +175,13 @@ open_float({dir}) *oil.open_floa
|
|||
{dir} `nil|string` When nil, open the parent of the current buffer, or the
|
||||
cwd if current buffer is not a file
|
||||
|
||||
toggle_float({dir}) *oil.toggle_float*
|
||||
Open oil browser in a floating window, or close it if open
|
||||
|
||||
Parameters:
|
||||
{dir} `nil|string` When nil, open the parent of the current buffer, or the
|
||||
cwd if current buffer is not a file
|
||||
|
||||
open({dir}) *oil.open*
|
||||
Open oil browser for a directory
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue