Closed yingzhu146 closed 2 months ago
{
"stevearc/oil.nvim",
cmd = "Oil",
keys = {
{
"<s-tab>",
function()
local util = require("oil.util")
local oil = require("oil")
local winid = util.get_preview_win()
if winid then
vim.api.nvim_win_close(winid, true)
end
oil.open()
end,
},
},
config = function()
local util = require("oil.util")
local oil = require("oil")
vim.api.nvim_create_autocmd("User", {
pattern = "OilEnter",
callback = vim.schedule_wrap(function(args)
if vim.api.nvim_get_current_buf() == args.data.buf and oil.get_cursor_entry() then
local winid = util.get_preview_win()
if winid then
vim.api.nvim_win_close(winid, true)
return
end
oil.open_preview()
end
end),
})
oil.setup({
keymaps = {
["<tab>"] = "actions.select",
},
})
end,
}
like this works.
It is helpful to know about oil.util
and util.get_preview_win()
(which I didn't find documented anywhere).
~~However this config still doesn't fix the preview window already exists
error for me:
Just opening oil with a preview window works just fine. Problems start when I navigate to parent directories.~~
... updating to the latest 'stable' fixed it.
Did you check the docs and existing issues?
Neovim version (nvim -v)
v0.10.0-dev-2943+gb0f922817 Build type: Release LuaJIT 2.1.1710088188 Run "nvim -V1 -v" for more info
Operating system/version
MacOS 12.4
Describe the bug
I have been having issues with the config proposed by https://github.com/stevearc/oil.nvim/issues/87
When pressing actions.parent twice, I get the following error
What is the severity of this bug?
blocking (cannot use plugin)
Steps To Reproduce
<s-tab>
(actions.parent)<s-tab>
(actions.parent)Expected Behavior
No error
Directory structure
(see torch repo example - file is arbitrary just needed to have sufficient nested structure to repro in public repo)
Repro
Did you check the bug with a clean config?
nvim -u repro.lua
using the repro.lua file above.