Skip to content

Deleting open file doesn't create new buffer #2014

Closed
@Raagh

Description

@Raagh

Description

Hi , I have weird case that maybe you can help me fix.

I am using toggleterm and nvim-tree together.

nvim-2023-02-21-12-03-58

Neovim version

nvim 0.8.2

Operating system and version

Windows 11(WSL Ubuntu)

nvim-tree version

latest

Minimal config

-- each of these are documented in `:help nvim-tree.OPTION_NAME`
local status_ok, nvim_tree = pcall(require, "nvim-tree")
if not status_ok then
  return
end

local config_status_ok, _ = pcall(require, "nvim-tree.config")
if not config_status_ok then
  return
end

nvim_tree.setup {
  disable_netrw = true,
  hijack_netrw = true,
  update_cwd = true,
  update_focused_file = {
    enable = true,
    update_cwd = true,
    ignore_list = {}
  },
  trash = {
    cmd = "trash",
    require_confirm = true,
  },
  actions = {
    open_file = {
      resize_window = false,
    }
  },
  view = {
    adaptive_size = true,
    mappings = {
      list = {
        { key = "e",  action = "" },
        { key = "<S-r>",  action = "rename_basename" },
      }
    }
  }
}

vim.api.nvim_create_autocmd('BufEnter', {
  command = "if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif",
  nested = true,
})


local events, nvim_tree_events = pcall(require, "nvim-tree.events")
if not events then
  return
end

local bufferapi, bufferline_api = pcall(require, "bufferline.api")
if not bufferapi then
  return
end

local function get_tree_size()
  return require 'nvim-tree.view'.View.width
end

nvim_tree_events.subscribe('TreeOpen', function()
  bufferline_api.set_offset(get_tree_size())
end)

nvim_tree_events.subscribe('Resize', function()
  bufferline_api.set_offset(get_tree_size())
end)

nvim_tree_events.subscribe('TreeClose', function()
  bufferline_api.set_offset(0)
end)

Steps to reproduce

Open a file
Open toggleterm as horizontal
Open nvim-tree
Delete file which is open

Expected behavior

nvim-tree would create a new empty buffer if there is no other buffer open

Actual behavior

nvim-tree leaves no buffer open

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions