Skip to content

Commit ef71841

Browse files
committed
Marks uses classic, tidy opts
1 parent db90f59 commit ef71841

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

lua/nvim-tree/explorer/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function Explorer:new(args)
6161
self.renderer = Renderer({ explorer = self })
6262
self.filters = Filters({ explorer = self })
6363
self.live_filter = LiveFilter({ explorer = self })
64-
self.marks = Marks:new(config, self)
64+
self.marks = Marks({ explorer = self })
6565
self.clipboard = Clipboard:new(config, self)
6666

6767
self:create_autocmds()

lua/nvim-tree/marks/init.lua

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,32 @@ local rename_file = require("nvim-tree.actions.fs.rename-file")
88
local trash = require("nvim-tree.actions.fs.trash")
99
local utils = require("nvim-tree.utils")
1010

11+
local Class = require("nvim-tree.classic")
1112
local DirectoryNode = require("nvim-tree.node.directory")
1213

13-
---@class Marks
14-
---@field config table hydrated user opts.filters
14+
---@class (exact) Marks: Class
1515
---@field private explorer Explorer
1616
---@field private marks table<string, Node> by absolute path
17-
local Marks = {}
18-
19-
---@return Marks
20-
---@param opts table user options
21-
---@param explorer Explorer
22-
function Marks:new(opts, explorer)
23-
local o = {
24-
explorer = explorer,
25-
config = {
26-
ui = opts.ui,
27-
filesystem_watchers = opts.filesystem_watchers,
28-
},
29-
marks = {},
30-
}
17+
local Marks = Class:extend()
18+
19+
---@class Marks
20+
---@overload fun(args: MarksArgs): Marks
3121

32-
setmetatable(o, self)
33-
self.__index = self
34-
return o
22+
---@class (exact) MarksArgs
23+
---@field explorer Explorer
24+
25+
---@param args MarksArgs
26+
function Marks:new(args)
27+
self.explorer = args.explorer
28+
29+
self.marks = {}
3530
end
3631

3732
---Clear all marks and reload if watchers disabled
3833
---@private
3934
function Marks:clear_reload()
4035
self:clear()
41-
if not self.config.filesystem_watchers.enable then
36+
if not self.explorer.opts.filesystem_watchers.enable then
4237
self.explorer:reload_explorer()
4338
end
4439
end
@@ -100,7 +95,7 @@ function Marks:bulk_delete()
10095
self:clear_reload()
10196
end
10297

103-
if self.config.ui.confirm.remove then
98+
if self.explorer.opts.ui.confirm.remove then
10499
local prompt_select = "Remove bookmarked ?"
105100
local prompt_input = prompt_select .. " y/N: "
106101
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, "nvimtree_bulk_delete", function(item_short)
@@ -129,7 +124,7 @@ function Marks:bulk_trash()
129124
self:clear_reload()
130125
end
131126

132-
if self.config.ui.confirm.trash then
127+
if self.explorer.opts.ui.confirm.trash then
133128
local prompt_select = "Trash bookmarked ?"
134129
local prompt_input = prompt_select .. " y/N: "
135130
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, "nvimtree_bulk_trash", function(item_short)

0 commit comments

Comments
 (0)