refactor: rework Oil command to support --float argument anywhere
This commit is contained in:
parent
a0b69fa117
commit
101689b0fe
2 changed files with 10 additions and 11 deletions
|
|
@ -498,16 +498,16 @@ M.setup = function(opts)
|
|||
config.setup(opts)
|
||||
set_colors()
|
||||
vim.api.nvim_create_user_command("Oil", function(args)
|
||||
if #args.fargs == 0 then
|
||||
require("oil").open()
|
||||
elseif args.fargs[1] == "--float" then
|
||||
require("oil").open_float()
|
||||
elseif args.fargs[2] == "--float" then
|
||||
require("oil").open_float(args.fargs[1])
|
||||
else
|
||||
require("oil").open(args.fargs[1])
|
||||
local float = false
|
||||
for i, v in ipairs(args.fargs) do
|
||||
if v == "--float" then
|
||||
float = true
|
||||
table.remove(args.fargs, i)
|
||||
end
|
||||
end
|
||||
end, { nargs = "*", complete = "dir" })
|
||||
local method = float and "open_float" or "open"
|
||||
M[method](unpack(args.fargs))
|
||||
end, { desc = "Open oil file browser on a directory", nargs = "*", complete = "dir" })
|
||||
local aug = vim.api.nvim_create_augroup("Oil", {})
|
||||
if vim.fn.exists("#FileExplorer") then
|
||||
vim.api.nvim_create_augroup("FileExplorer", { clear = true })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue