From ef7184118cea40450b1daa5ec7e860fedb24b196 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Fri, 8 Nov 2024 13:50:45 +1100 Subject: [PATCH] Marks uses classic, tidy opts --- lua/nvim-tree/explorer/init.lua | 2 +- lua/nvim-tree/marks/init.lua | 37 ++++++++++++++------------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/lua/nvim-tree/explorer/init.lua b/lua/nvim-tree/explorer/init.lua index 90ace32c..c07e3f58 100644 --- a/lua/nvim-tree/explorer/init.lua +++ b/lua/nvim-tree/explorer/init.lua @@ -61,7 +61,7 @@ function Explorer:new(args) self.renderer = Renderer({ explorer = self }) self.filters = Filters({ explorer = self }) self.live_filter = LiveFilter({ explorer = self }) - self.marks = Marks:new(config, self) + self.marks = Marks({ explorer = self }) self.clipboard = Clipboard:new(config, self) self:create_autocmds() diff --git a/lua/nvim-tree/marks/init.lua b/lua/nvim-tree/marks/init.lua index ddeb5cc9..8c569e5f 100644 --- a/lua/nvim-tree/marks/init.lua +++ b/lua/nvim-tree/marks/init.lua @@ -8,37 +8,32 @@ local rename_file = require("nvim-tree.actions.fs.rename-file") local trash = require("nvim-tree.actions.fs.trash") local utils = require("nvim-tree.utils") +local Class = require("nvim-tree.classic") local DirectoryNode = require("nvim-tree.node.directory") ----@class Marks ----@field config table hydrated user opts.filters +---@class (exact) Marks: Class ---@field private explorer Explorer ---@field private marks table by absolute path -local Marks = {} +local Marks = Class:extend() ----@return Marks ----@param opts table user options ----@param explorer Explorer -function Marks:new(opts, explorer) - local o = { - explorer = explorer, - config = { - ui = opts.ui, - filesystem_watchers = opts.filesystem_watchers, - }, - marks = {}, - } +---@class Marks +---@overload fun(args: MarksArgs): Marks - setmetatable(o, self) - self.__index = self - return o +---@class (exact) MarksArgs +---@field explorer Explorer + +---@param args MarksArgs +function Marks:new(args) + self.explorer = args.explorer + + self.marks = {} end ---Clear all marks and reload if watchers disabled ---@private function Marks:clear_reload() self:clear() - if not self.config.filesystem_watchers.enable then + if not self.explorer.opts.filesystem_watchers.enable then self.explorer:reload_explorer() end end @@ -100,7 +95,7 @@ function Marks:bulk_delete() self:clear_reload() end - if self.config.ui.confirm.remove then + if self.explorer.opts.ui.confirm.remove then local prompt_select = "Remove bookmarked ?" local prompt_input = prompt_select .. " y/N: " lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, "nvimtree_bulk_delete", function(item_short) @@ -129,7 +124,7 @@ function Marks:bulk_trash() self:clear_reload() end - if self.config.ui.confirm.trash then + if self.explorer.opts.ui.confirm.trash then local prompt_select = "Trash bookmarked ?" local prompt_input = prompt_select .. " y/N: " lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, "nvimtree_bulk_trash", function(item_short)