stevearc / oil.nvim

Neovim file explorer: edit your filesystem like a buffer
MIT License
3.7k stars 104 forks source link

bug: Oil failing to load #288

Open hoyt0084 opened 7 months ago

hoyt0084 commented 7 months ago

Did you check the docs and existing issues?

Neovim version (nvim -v)

0.9.5

Operating system/version

Arch Linux x86_64 Kernel 6.6.10-arch1-1

Describe the bug

When opening neovim with (nvim .), Oil fails to load. I will then execute :Oil which brings me up a directory. Then after going back into the directory I want to be in, all files and directories do not exist.

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

  1. nvim .

Expected Behavior

Expected behavior is for Oil to open in the current directory displaying the sub-directories and files in that directory.

Directory structure

a/b a/c a/text.txt

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 = {
  {
        "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",
})

Did you check the bug with a clean config?

stevearc commented 7 months ago

I've tried this on both mac and linux and couldn't reproduce. To confirm, when you run nvim -u repro.lua . it opens with an empty buffer?

Tyler-Hoyt commented 7 months ago

That is what was happening yesterday, now this only occurs with a file not found and a .swp file message even though I am just opening with nvim . and closing the buffer. I'm guessing there was something iffy on my machine yesterday or something but I could not get it to work. Even with the repro.lua.

hoyt0084 commented 7 months ago

That is what was happening yesterday, now this only occurs with a file not found and a .swp file message even though I am just opening with nvim . and closing the buffer. I'm guessing there was something iffy on my machine yesterday or something but I could not get it to work. Even with the repro.lua.

Nevermind, this is still happening with no .swp file message.

stevearc commented 6 months ago

Sorry, without being able to repro on my machine there's not much I can do. I'd recommend diving in and adding some debug print statements to see if you can suss out where it's dropping off

Piotr1215 commented 4 months ago

I had the same issue and ended up creating a wrapper funciton and calling it with an alias:

_G.OpenOil = function()
  local oil = require "oil"
  oil.open()
end

vim.keymap.set("n", "<Leader>ol", _G.OpenOil, { noremap = true, silent = true })
alias vo='vim -c ":lua OpenOil()"'

This works however there is another issue, it's not possible to navigate the buffer, you can notice the rapid cursor blinking at the bottom of the screen:

mvillafuertem commented 3 weeks ago

I have the same issue @stevearc, can you help me debug?

return {
  'stevearc/oil.nvim',
  opts = {},
  -- Optional dependencies
  -- dependencies = { { "echasnovski/mini.icons", opts = {} } },
  dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons
}
$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 14.6 (23G80)
      Kernel Version: Darwin 23.6.0
$ nvim --version

NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1713773202
Run "nvim -V1 -v" for more info
mvillafuertem commented 3 weeks ago

@Piotr1215 @hoyt0084 the solution that works for me was simply to disable lazy loading

return {
  'stevearc/oil.nvim',
  lazy = false,
  opts = {},
  -- Optional dependencies
  -- dependencies = { { "echasnovski/mini.icons", opts = {} } },
  dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons
}