Skip to content

Commit

Permalink
feat: added command
Browse files Browse the repository at this point in the history
  • Loading branch information
max397574 committed Jan 4, 2023
1 parent ae8f474 commit af59e7b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ If you want to mimic the `vim-vinegar` method of navigating to the parent direct
vim.keymap.set("n", "-", require("oil").open, { desc = "Open parent directory" })
```

You can also use the `Oil` command to open oil.nvim.
You can provide a folder argument to open this folder and add `--float` at the end of the command to open oil in a float.

## Options

```lua
Expand Down
11 changes: 11 additions & 0 deletions lua/oil/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,17 @@ M.setup = function(opts)
local config = require("oil.config")
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])
end
end, { 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 })
Expand Down

0 comments on commit af59e7b

Please sign in to comment.