Marks uses classic, tidy opts
This commit is contained in:
parent
db90f59532
commit
ef7184118c
@ -61,7 +61,7 @@ function Explorer:new(args)
|
|||||||
self.renderer = Renderer({ explorer = self })
|
self.renderer = Renderer({ explorer = self })
|
||||||
self.filters = Filters({ explorer = self })
|
self.filters = Filters({ explorer = self })
|
||||||
self.live_filter = LiveFilter({ 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.clipboard = Clipboard:new(config, self)
|
||||||
|
|
||||||
self:create_autocmds()
|
self:create_autocmds()
|
||||||
|
|||||||
@ -8,37 +8,32 @@ local rename_file = require("nvim-tree.actions.fs.rename-file")
|
|||||||
local trash = require("nvim-tree.actions.fs.trash")
|
local trash = require("nvim-tree.actions.fs.trash")
|
||||||
local utils = require("nvim-tree.utils")
|
local utils = require("nvim-tree.utils")
|
||||||
|
|
||||||
|
local Class = require("nvim-tree.classic")
|
||||||
local DirectoryNode = require("nvim-tree.node.directory")
|
local DirectoryNode = require("nvim-tree.node.directory")
|
||||||
|
|
||||||
---@class Marks
|
---@class (exact) Marks: Class
|
||||||
---@field config table hydrated user opts.filters
|
|
||||||
---@field private explorer Explorer
|
---@field private explorer Explorer
|
||||||
---@field private marks table<string, Node> by absolute path
|
---@field private marks table<string, Node> by absolute path
|
||||||
local Marks = {}
|
local Marks = Class:extend()
|
||||||
|
|
||||||
---@return Marks
|
---@class Marks
|
||||||
---@param opts table user options
|
---@overload fun(args: MarksArgs): Marks
|
||||||
---@param explorer Explorer
|
|
||||||
function Marks:new(opts, explorer)
|
|
||||||
local o = {
|
|
||||||
explorer = explorer,
|
|
||||||
config = {
|
|
||||||
ui = opts.ui,
|
|
||||||
filesystem_watchers = opts.filesystem_watchers,
|
|
||||||
},
|
|
||||||
marks = {},
|
|
||||||
}
|
|
||||||
|
|
||||||
setmetatable(o, self)
|
---@class (exact) MarksArgs
|
||||||
self.__index = self
|
---@field explorer Explorer
|
||||||
return o
|
|
||||||
|
---@param args MarksArgs
|
||||||
|
function Marks:new(args)
|
||||||
|
self.explorer = args.explorer
|
||||||
|
|
||||||
|
self.marks = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
---Clear all marks and reload if watchers disabled
|
---Clear all marks and reload if watchers disabled
|
||||||
---@private
|
---@private
|
||||||
function Marks:clear_reload()
|
function Marks:clear_reload()
|
||||||
self:clear()
|
self:clear()
|
||||||
if not self.config.filesystem_watchers.enable then
|
if not self.explorer.opts.filesystem_watchers.enable then
|
||||||
self.explorer:reload_explorer()
|
self.explorer:reload_explorer()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -100,7 +95,7 @@ function Marks:bulk_delete()
|
|||||||
self:clear_reload()
|
self:clear_reload()
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.config.ui.confirm.remove then
|
if self.explorer.opts.ui.confirm.remove then
|
||||||
local prompt_select = "Remove bookmarked ?"
|
local prompt_select = "Remove bookmarked ?"
|
||||||
local prompt_input = prompt_select .. " y/N: "
|
local prompt_input = prompt_select .. " y/N: "
|
||||||
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, "nvimtree_bulk_delete", function(item_short)
|
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()
|
self:clear_reload()
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.config.ui.confirm.trash then
|
if self.explorer.opts.ui.confirm.trash then
|
||||||
local prompt_select = "Trash bookmarked ?"
|
local prompt_select = "Trash bookmarked ?"
|
||||||
local prompt_input = prompt_select .. " y/N: "
|
local prompt_input = prompt_select .. " y/N: "
|
||||||
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, "nvimtree_bulk_trash", function(item_short)
|
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, "nvimtree_bulk_trash", function(item_short)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user