nvim-neo-tree / neo-tree.nvim

Neovim plugin to manage the file system and other tree like structures.
MIT License
3.78k stars 219 forks source link

BUG: Buffer delete command closes Neovim when neo-tree is open #1580

Open JohnWilliston opened 1 week ago

JohnWilliston commented 1 week ago

Did you check docs and existing issues?

Neovim Version (nvim -v)

NVIM v0.10.1 Build type: Release LuaJIT 2.1.1713484068 Run "nvim -V1 -v" for more info

Operating System / Version

Windows 11 Pro x64

Describe the Bug

I tend to toggle neo-tree open with a keyboard shortcut (F3 from my old CUA days is a hard habit to break). Here's the procedure I follow to evince what seems to me like a bug:

  1. Open nvim with a single file specified on the command line.
  2. Hit F3 to toggle neo-tree (it appears in a new left pane). Open a second file using neo-tree.
  3. Issue the :bd command.

With two files open like that, I would think deleting the buffer that's open in the right pane would leave neo-tree open on the left and the original file from the command line open on the right. What actually happens with close_if_last_window set to true is that Neovim exits completely. And I believe it's neo-tree doing that for two reasons: (1) changing close_if_last_window to false stops it from happening, as does (2) if I toggle the neo-tree pane closed before the :bd command. Serious question: am I wrong in that initial expectation? Seems like this might be a bug.

Screenshots, Traceback

No response

Steps to Reproduce

  1. Open nvim with a single file specified on the command line.
  2. Hit F3 to toggle neo-tree (it appears in a new left pane). Open a second file using neo-tree.
  3. Issue the :bd command.

Expected Behavior

I expected my :bd command to delete the buffer I'm seeing, leaving neo-tree open in the left pane but now showing the second file open in the right pane. nvim-config-folder-2024-10-11_2012.zip

Your Configuration

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "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", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  -- add any other plugins here
}

local neotree_config = {
  "nvim-neo-tree/neo-tree.nvim",
  dependencies = { "MunifTanjim/nui.nvim", "nvim-tree/nvim-web-devicons", "nvim-lua/plenary.nvim" },
  cmd = { "Neotree" },
  keys = {
    { "<Leader>e", "<Cmd>Neotree<CR>" }, -- change or remove this line if relevant.
  },
  opts = {
    -- Your config here
    -- ...
  },
}

table.insert(plugins, neotree_config)
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

-- Sorry, gang, I don't know how to produce a "minimal init.lua to reproduce this issue". I'm attaching an archive of my entire %LOCALAPPDATA%\nvim folder instead.
ozztrk commented 4 days ago

I am experiencing the same issue. I will continue to investigate and update this thread if I find a solution