Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Oil doesn't execute when Lazy.nvim needs to install something #539

Open
3 tasks done
andrewschmidgit opened this issue Dec 17, 2024 · 2 comments
Open
3 tasks done
Labels
bug Something isn't working P2 Not a priority. PRs welcome

Comments

@andrewschmidgit
Copy link

Did you check the docs and existing issues?

  • I have read the docs
  • I have searched the existing issues

Neovim version (nvim -v)

v0.10.2

Operating system/version

MacOS 15.1.1

Describe the bug

When running nvim ., and Lazy.nvim needs to install / update a plugin, Oil fails to open.

nvim-tree suggests adding the following lines to init.lua, but that doesn't help here

vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

I have tried with no Oil configuration, and with

-- ...
opts = {
  default_file_explorer = true
}
-- ...

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

  1. nvim -u repro.lua .
  2. Wait for Lazy.nvim to bootstrap / download the oil plugin

Expected Behavior

I expected Oil to open the given directory.

This works when no plugins need to be installed, but if even one plugin needs to install or be updated, Oil fails to open after Lazy.nvim is done.

Directory structure

repro.lua

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
              default_file_explorer = true
            })
        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?

  • I have confirmed that the bug reproduces with nvim -u repro.lua using the repro.lua file above.
@andrewschmidgit andrewschmidgit added the bug Something isn't working label Dec 17, 2024
@stevearc
Copy link
Owner

I'm not too surprised by this. Lazy.nvim is hijacking the typical startup process and opening its own window. Oil relies on a specific sequence of events and autocmds to take over folder named buffers. There may be a way to make these work together more gracefully, but it's not a high priority for me.

@stevearc stevearc added the P2 Not a priority. PRs welcome label Dec 21, 2024
@tom-gora
Copy link

tom-gora commented Jan 7, 2025

Did you check the docs and existing issues?

Have you tried +Oil arg? This forced it to execute and solved the issue of Oil not opening on starting nvim in dir that started occurring some time ago for me as well.
I'm on Fedora but zsh snippet from my config for C-Space to open in pwd should work on macos as well:

# ctrl-space to quickly open pwd in nvim
function nvim_here() {
  nvim "$(pwd)" +Oil
}
zle -N nvim_here
bindkey '^ ' nvim_here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 Not a priority. PRs welcome
Projects
None yet
Development

No branches or pull requests

3 participants