-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feature request: opening behaviour customization #444
Labels
enhancement
New feature or request
Comments
Or: oil starts with float window rather than full window width buffer |
You can achieve these behaviours using the neovim API: -- Open oil in split
vim.keymap.set("n", "<leader>os", "<cmd>vs | Oil<cr>", { desc = "Open oil in split" }) -- Open oil in float window
vim.keymap.set("n", "-", "<cmd>Oil --float<cr>", { desc = "Open parent directory" }) -- Open oil with preview
vim.keymap.set("n", "<leader>op", function()
local oil = require("oil")
local util = require("oil.util")
oil.open()
util.run_after_load(0, function()
oil.select({ preview = true })
end)
end, { desc = "Open oil with preview" }) -- Map q or <escape> to close buffer only for floating Oil buffers
vim.api.nvim_create_autocmd("User", {
group = vim.api.nvim_create_augroup("OilFloatCustom", {}),
pattern = "OilEnter",
callback = function()
local actions = require("oil.actions")
local util = require("oil.util")
if util.is_floating_win() then
vim.keymap.set("n", "<Esc>", actions.close.callback, {
buffer = true,
})
vim.keymap.set("n", "q", actions.close.callback, {
buffer = true,
})
end
end,
})
|
Thank you mayne! |
UPDATE: This is the updated keymap to open the oil filetree with preview enabled: vim.keymap.set("n", "<leader>ee", function()
local oil = require("oil")
local util = require("oil.util")
oil.open()
util.run_after_load(0, function()
oil.open_preview()
end)
end, { desc = "oil: open file explorer with preview" }), |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Did you check existing requests?
Describe the feature
It would be cool to allow the user to define options how Oil should open.
For example: oil starts with the preview turned on
Or: oil starts in a split on the right side of the screen and the previously opened buffer stays in the split on the left
Provide background
No response
What is the significance of this feature?
nice to have
Additional details
No response
The text was updated successfully, but these errors were encountered: