Skip to content

...nvim-tree/view.lua:345 Vim:E444: Cannot close last window #745

Closed
@MrAustin2u

Description

@MrAustin2u
  1. Navigate to my project directory. Nvim-tree displays instead of Netrw(intended behavior)
  2. Open telescope git_files
  3. Select file
  4. Attempt to open nvim-tree map('n', 'nf', ':NvimTreeFindFile<CR>', { noremap = false, silent = true })
  5. Receive this error in the command line ...nvim-tree/view.lua:345 Vim:E44: Cannot close last window

However, if I navigate to a file from the root. I am able to toggle nvim-tree fine.

Lua config:

 local function setup_nvim_tree()
   vim.g.nvim_tree_icons = {
     default = "",
     git = {
       unstaged = "",
       staged = "",
       unmerged = "",
       renamed = "",
       untracked = "",
       deleted = "",
     },
   }
   vim.g.nvim_tree_special_files = {}
	vim.g.nvim_tree_indent_markers = 1
	vim.g.nvim_tree_gitignore = 0
	vim.g.nvim_tree_highlight_opened_files = 2
	vim.g.nvim_tree_ignore = { ".git", "node_modules", ".cache", ".vscode", ".DS_Store", ".un" }
	
local present, nvimtree = pcall(require, "nvim-tree")
	if not present then
		return
	end

	nvimtree.setup({
    ignore_ft_on_setup = { "dashboard", "terminal", "quickfix" },
		view = {
			allow_resize = true,
			width = 45,
      side = "right",
      hide_root_folder = false
		},
    auto_close = true,
    disable_netrw = true,
		hijack_cursor = true,
    update_cwd = true,
	})
end

Lua mappings:

map('n', '<C-n>', ':NvimTreeToggle<CR>', { noremap = true })
map('n', 'nf', ':NvimTreeFindFile<CR>', { noremap = false, silent =  true })
map('n', 'nc', ':NvimTreeClose<CR>', { noremap = false, silent =  true })
map('n', 'nr', ':NvimTreeRefresh<CR>', { noremap = false, silent = true })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions