Skip to content

Floating nvim-tree does not respect config on startup #2749

Open
@stentibbing

Description

@stentibbing

Description

When opening a folder with "nvim ." and while having nvim-tree configured to float in a window, nvim-tree opens full screen, not respecting open_win_config. Furthermore, trying to close the initial fullscreen nvim-tree with NvimTreeToggle produces an error:

Error executing Lua callback: ...cal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/view.lua:225: Expected Lua number stack traceback: [C]: in function 'nvim_win_is_valid' ...cal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/view.lua:225: in function 'close' ...cal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/view.lua:235: in function 'close_this_tab_only' ...cal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/view.lua:248: in function 'close' ...lazy/nvim-tree.lua/lua/nvim-tree/actions/tree/toggle.lua:45: in function 'toggle' ...share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/commands.lua:36: in function <...share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/commands.lua:35>

Neovim version

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1692716794

Operating system and version

Windows 11

Windows variant

WSL2 Ubuntu

nvim-tree version

#ddd1d6e, v1.3.0

Clean room replication

Install nvim-tree with Lazy, using the following configuration:

return {
	"nvim-tree/nvim-tree.lua",
	version = "*",
	lazy = false,
	dependencies = {
		"nvim-tree/nvim-web-devicons",
	},
	config = function()
		require("nvim-tree").setup({
			disable_netrw = true,
			hijack_netrw = false,
			view = {
				relativenumber = true,
				float = {
					enable = true,
					open_win_config = function()
						local screen_w = vim.opt.columns:get()
						local screen_h = vim.opt.lines:get() - vim.opt.cmdheight:get()
						local window_w = screen_w * 0.5
						local window_h = screen_h * 0.8
						local window_w_int = math.floor(window_w)
						local window_h_int = math.floor(window_h)
						local center_x = (screen_w - window_w) / 2
						local center_y = ((vim.opt.lines:get() - window_h) / 2) - vim.opt.cmdheight:get()
						return {
							title = " NvimTree ",
							title_pos = "center",
							border = "rounded",
							relative = "editor",
							row = center_y,
							col = center_x,
							width = window_w_int,
							height = window_h_int,
						}
					end,
				},
			},
		})
	end,
}

Steps to reproduce

  1. nvim .
  2. :NvimTreeToggle

Expected behavior

NvimTree should open in a floating window and close on NvimTreeToggle

Actual behavior

NvimTree opens full screen and :NvimTreeToggle produces error

Screenshot 2024-04-17 103007

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions