@@ -7,42 +7,38 @@ local notify = require("nvim-tree.notify")
77
88local find_file = require (" nvim-tree.actions.finders.find-file" ).fn
99
10+ local Class = require (" nvim-tree.classic" )
1011local DirectoryNode = require (" nvim-tree.node.directory" )
1112
1213--- @alias ClipboardAction " copy" | " cut"
1314--- @alias ClipboardData table<ClipboardAction , Node[]>
1415
1516--- @alias ClipboardActionFn fun ( source : string , dest : string ): boolean , string ?
1617
17- --- @class Clipboard to handle all actions.fs clipboard API
18- --- @field config table hydrated user opts.filters
18+ --- @class (exact ) Clipboard : Class
1919--- @field private explorer Explorer
2020--- @field private data ClipboardData
2121--- @field private clipboard_name string
2222--- @field private reg string
23- local Clipboard = {}
24-
25- --- @param opts table user options
26- --- @param explorer Explorer
27- --- @return Clipboard
28- function Clipboard :new (opts , explorer )
29- --- @type Clipboard
30- local o = {
31- explorer = explorer ,
32- data = {
33- copy = {},
34- cut = {},
35- },
36- clipboard_name = opts .actions .use_system_clipboard and " system" or " neovim" ,
37- reg = opts .actions .use_system_clipboard and " +" or " 1" ,
38- config = {
39- filesystem_watchers = opts .filesystem_watchers ,
40- },
23+ local Clipboard = Class :extend ()
24+
25+ --- @class Clipboard
26+ --- @overload fun ( args : ClipboardArgs ): Clipboard
27+
28+ --- @class (exact ) ClipboardArgs
29+ --- @field explorer Explorer
30+
31+ --- @param args ClipboardArgs
32+ function Clipboard :new (args )
33+ self .explorer = args .explorer
34+
35+ self .data = {
36+ copy = {},
37+ cut = {},
4138 }
4239
43- setmetatable (o , self )
44- self .__index = self
45- return o
40+ self .clipboard_name = self .explorer .opts .actions .use_system_clipboard and " system" or " neovim"
41+ self .reg = self .explorer .opts .actions .use_system_clipboard and " +" or " 1"
4642end
4743
4844--- @param source string
@@ -252,7 +248,7 @@ function Clipboard:do_paste(node, action, action_fn)
252248 end
253249
254250 self .data [action ] = {}
255- if not self .config .filesystem_watchers .enable then
251+ if not self .explorer . opts .filesystem_watchers .enable then
256252 self .explorer :reload_explorer ()
257253 end
258254end
0 commit comments