bug: Oil "Could not find entry under cursor" on nightly
Did you check the docs and existing issues?
- [x] I have read the docs
- [x] I have searched the existing issues
Neovim version (nvim -v)
NVIM v0.13.0-dev-960+g59dbca9b0c
Operating system/version
archlinux 7.0.12-arch1-1
Describe the bug
Cannot open any file/dir from the Oil directory buffer.
What is the severity of this bug?
breaking (some functionality is broken)
Steps To Reproduce
- nvim -u repro.lua
- Open dir buffer,
:Oil - Try opening a file/dir
Expected Behavior
No "Could not find entry under cursor" error
Directory structure
No response
Repro
-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
"folke/tokyonight.nvim",
{
"stevearc/oil.nvim",
config = function()
require("oil").setup({
-- add any needed settings here
})
end,
},
-- add any other plugins here
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
-- add anything else here
Did you check the bug with a clean config?
- [x] I have confirmed that the bug reproduces with
nvim -u repro.luausing the repro.lua file above.
I did some initial scouting and it seems to be because the filetype isn't set properly. If you inspect a seemingly broken buffer update in nightly, you will discover, that the filetype is directory, not oil, which is why functions like get_cursor_on_line fail. If you set the filetype manully, it should work, meanwhile I'll be ferreting further to see what causes the filetype to not be set properly.
Okay it seems oil does set the ft properly, but something later somehow overrides it to directory :p
Yup, this is a neovim matter: https://github.com/neovim/neovim/issues/40689
Looks like they want to fix this behaviour in this PR: https://github.com/neovim/neovim/pull/40680
Also note that the suggested approach here for now is to disable dir.lua via vim.g.nvim_dir_plugin = 1, similar to what you'd do with netrw (see the docs).
I'm pretty sure by setting this early yourself (even though oil.nvim ought to set the guard flag according to the use_default_explorer config option) that'd circumvent the entire issue. At least it did for me.