diff --git a/lua/nvim-tree/actions/fs/remove-file.lua b/lua/nvim-tree/actions/fs/remove-file.lua index fd71ae6a..ba1325f7 100644 --- a/lua/nvim-tree/actions/fs/remove-file.lua +++ b/lua/nvim-tree/actions/fs/remove-file.lua @@ -18,7 +18,7 @@ local function close_windows(windows) -- Prevent from closing when the win count equals 1 or 2, -- where the win to remove could be the last opened. -- For details see #2503. - if explorer and explorer.view.float.enable and #vim.api.nvim_list_wins() < 3 then + if explorer and explorer.opts.view.float.enable and #vim.api.nvim_list_wins() < 3 then return end @@ -36,12 +36,12 @@ local function clear_buffer(absolute_path) for _, buf in pairs(bufs) do if buf.name == absolute_path then local tree_winnr = vim.api.nvim_get_current_win() - if buf.hidden == 0 and (#bufs > 1 or explorer and explorer.view.float.enable) then + if buf.hidden == 0 and (#bufs > 1 or explorer and explorer.opts.view.float.enable) then vim.api.nvim_set_current_win(buf.windows[1]) vim.cmd(":bn") end vim.api.nvim_buf_delete(buf.bufnr, { force = true }) - if explorer and not explorer.view.float.quit_on_focus_loss then + if explorer and not explorer.opts.view.float.quit_on_focus_loss then vim.api.nvim_set_current_win(tree_winnr) end if M.config.actions.remove_file.close_window then diff --git a/lua/nvim-tree/actions/node/open-file.lua b/lua/nvim-tree/actions/node/open-file.lua index b3bcce75..b4487094 100644 --- a/lua/nvim-tree/actions/node/open-file.lua +++ b/lua/nvim-tree/actions/node/open-file.lua @@ -346,7 +346,7 @@ local function open_in_new_window(filename, mode) end end - if (mode == "preview" or mode == "preview_no_picker") and explorer and explorer.view.float.enable then + if (mode == "preview" or mode == "preview_no_picker") and explorer and explorer.opts.view.float.enable then -- ignore "WinLeave" autocmd on preview -- because the registered "WinLeave" -- will kill the floating window immediately diff --git a/lua/nvim-tree/explorer/live-filter.lua b/lua/nvim-tree/explorer/live-filter.lua index 9bd24406..fbc64331 100644 --- a/lua/nvim-tree/explorer/live-filter.lua +++ b/lua/nvim-tree/explorer/live-filter.lua @@ -61,7 +61,7 @@ local overlay_bufnr = 0 local overlay_winnr = 0 local function remove_overlay(self) - if self.explorer.view.float.enable and self.explorer.view.float.quit_on_focus_loss then + if self.explorer.opts.view.float.enable and self.explorer.opts.view.float.quit_on_focus_loss then -- return to normal nvim-tree float behaviour when filter window is closed vim.api.nvim_create_autocmd("WinLeave", { pattern = "NvimTree_*", @@ -171,7 +171,7 @@ local function calculate_overlay_win_width(self) end local function create_overlay(self) - if self.explorer.view.float.enable then + if self.explorer.opts.view.float.enable then -- don't close nvim-tree float when focus is changed to filter window vim.api.nvim_clear_autocmds({ event = "WinLeave", diff --git a/lua/nvim-tree/explorer/view.lua b/lua/nvim-tree/explorer/view.lua index 6653fd24..658deb8b 100644 --- a/lua/nvim-tree/explorer/view.lua +++ b/lua/nvim-tree/explorer/view.lua @@ -11,11 +11,9 @@ local Class = require("nvim-tree.classic") ---@class (exact) View: Class ---@field live_filter table ---@field side string ----@field float table ---@field private explorer Explorer ---@field private adaptive_size boolean ---@field private centralize_selection boolean ----@field private hide_root_folder boolean ---@field private winopts table ---@field private height integer ---@field private preserve_window_proportions boolean @@ -40,9 +38,7 @@ function View:new(args) self.explorer = args.explorer self.adaptive_size = false self.centralize_selection = self.explorer.opts.view.centralize_selection - self.float = self.explorer.opts.view.float self.height = self.explorer.opts.view.height - self.hide_root_folder = self.explorer.opts.renderer.root_folder_label == false self.preserve_window_proportions = self.explorer.opts.view.preserve_window_proportions self.side = (self.explorer.opts.view.side == "right") and "right" or "left" self.live_filter = { prev_focused_node = nil, } @@ -217,16 +213,16 @@ end ---@private ---@return table function View:open_win_config() - if type(self.float.open_win_config) == "function" then - return self.float.open_win_config() + if type(self.explorer.opts.view.float.open_win_config) == "function" then + return self.explorer.opts.view.float.open_win_config() else - return self.float.open_win_config + return self.explorer.opts.view.float.open_win_config end end ---@private function View:open_window() - if self.float.enable then + if self.explorer.opts.view.float.enable then vim.api.nvim_open_win(0, true, self:open_win_config()) else vim.api.nvim_command("vsp") @@ -405,9 +401,9 @@ end ---@param size string|number|nil function View:resize(size) - if self.float.enable and not self.adaptive_size then + if self.explorer.opts.view.float.enable and not self.adaptive_size then -- if the floating windows's adaptive size is not desired, then the - -- float size should be defined in view.float.open_win_config + -- float size should be defined in self.explorer.opts.view.float.open_win_config return end @@ -761,7 +757,7 @@ end ---@param cwd string|nil ---@return boolean function View:is_root_folder_visible(cwd) - return cwd ~= "/" and not self.hide_root_folder + return cwd ~= "/" and self.explorer.opts.renderer.root_folder_label ~= false end -- used on ColorScheme event