Skip to content

FEATURE: preserve window layout when the last non-neotree-sidebar window is closed #1504

Open
@beastr45

Description

@beastr45

Did you check docs and existing issues?

  • I have read all the docs.
  • I have searched the existing issues.
  • I have searched the existing discussions.

Neovim Version (nvim -v)

0.10.0 (latest)

Operating System / Version

Linux 6.6.34-1-lts x86_64 GNU/Linux

Describe the Bug

When dealing with multiple buffers neotree will no longer become split view after closing a buffer. This is really annoying because in large co-debases I cant read code and navigate at the same time when this happens. I often just reopen neovim to fix it.

Screenshots, Traceback

expected behaviour
image
behaviour after closing one buffer out of multiple open (toggling neotree takes up entire screen)
image

Steps to Reproduce

  1. open more than one buffer
  2. toggle neotree
  3. focus the buffer while neotree is open and type :bw
  4. neotree now takes up entire screen, toggling neotree is no longer in split view
  5. in order to refresh split screen neotree has to open a file in its buffer.

Expected Behavior

Neotree should always stay in split windows unless directed to do otherwise by the user in the config.

(the minimal config already provided reproduces my issue)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions