@@ -7,42 +7,38 @@ local notify = require("nvim-tree.notify")
7
7
8
8
local find_file = require (" nvim-tree.actions.finders.find-file" ).fn
9
9
10
+ local Class = require (" nvim-tree.classic" )
10
11
local DirectoryNode = require (" nvim-tree.node.directory" )
11
12
12
13
--- @alias ClipboardAction " copy" | " cut"
13
14
--- @alias ClipboardData table<ClipboardAction , Node[]>
14
15
15
16
--- @alias ClipboardActionFn fun ( source : string , dest : string ): boolean , string ?
16
17
17
- --- @class Clipboard to handle all actions.fs clipboard API
18
- --- @field config table hydrated user opts.filters
18
+ --- @class (exact ) Clipboard : Class
19
19
--- @field private explorer Explorer
20
20
--- @field private data ClipboardData
21
21
--- @field private clipboard_name string
22
22
--- @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 = {},
41
38
}
42
39
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"
46
42
end
47
43
48
44
--- @param source string
@@ -252,7 +248,7 @@ function Clipboard:do_paste(node, action, action_fn)
252
248
end
253
249
254
250
self .data [action ] = {}
255
- if not self .config .filesystem_watchers .enable then
251
+ if not self .explorer . opts .filesystem_watchers .enable then
256
252
self .explorer :reload_explorer ()
257
253
end
258
254
end
0 commit comments