oil.nvim
oil.nvim copied to clipboard
Add argument to open Oil in Preview-Mode
Did you check existing requests?
- [X] I have searched the existing issues
Describe the feature
It would be great if open had an argument for enabling preview mode as soon as Oil opens.
Suggestion:
oil.open({
dir = '...',
preview = true,
})
Provide background
I couldn't find a way to open Oil with preview-mode activated initially.
I tried the following but preview triggers too early this way:
require('oil').open()
require('oil.actions').preview()
What is the significance of this feature?
nice to have
Additional details
Edit: This is just an issue for opening Oil for the first time in a session. So maybe it would be better to offer an option for setup to enable preview by default.
It will be great If can support open in preview mode. Meanwhile, I'm using this to achieve it.
vim.keymap.set('n', '-', function()
require('oil').open()
require('oil.util').run_after_load(0, function()
oil.select({ preview = true })
end)
end)
This is what I'm using as a workaround to try opening the preview only after its available
vim.keymap.set('n', '-', function()
oil.open()
-- Wait until oil has opened, for a maximum of 1 second.
vim.wait(1000, function()
return oil.get_cursor_entry() ~= nil
end)
if oil.get_cursor_entry() then
oil.open_preview()
end
end)