@@ -73,34 +73,45 @@ function M.fn(node)
73
73
if node .name == " .." then
74
74
return
75
75
end
76
- local prompt_select = " Remove " .. node .name .. " ?"
77
- local prompt_input = prompt_select .. " y/n: "
78
- lib .prompt (prompt_input , prompt_select , { " y" , " n" }, { " Yes" , " No" }, function (item_short )
79
- utils .clear_prompt ()
80
- if item_short == " y" then
81
- if node .nodes ~= nil and not node .link_to then
82
- local success = remove_dir (node .absolute_path )
83
- if not success then
84
- return notify .error (" Could not remove " .. node .name )
85
- end
86
- events ._dispatch_folder_removed (node .absolute_path )
87
- else
88
- local success = vim .loop .fs_unlink (node .absolute_path )
89
- if not success then
90
- return notify .error (" Could not remove " .. node .name )
91
- end
92
- events ._dispatch_file_removed (node .absolute_path )
93
- clear_buffer (node .absolute_path )
76
+
77
+ local function do_remove ()
78
+ if node .nodes ~= nil and not node .link_to then
79
+ local success = remove_dir (node .absolute_path )
80
+ if not success then
81
+ return notify .error (" Could not remove " .. node .name )
94
82
end
95
- notify .info (node .absolute_path .. " was properly removed." )
96
- if M .enable_reload then
97
- require (" nvim-tree.actions.reloaders.reloaders" ).reload_explorer ()
83
+ events ._dispatch_folder_removed (node .absolute_path )
84
+ else
85
+ local success = vim .loop .fs_unlink (node .absolute_path )
86
+ if not success then
87
+ return notify .error (" Could not remove " .. node .name )
98
88
end
89
+ events ._dispatch_file_removed (node .absolute_path )
90
+ clear_buffer (node .absolute_path )
99
91
end
100
- end )
92
+ notify .info (node .absolute_path .. " was properly removed." )
93
+ if M .enable_reload then
94
+ require (" nvim-tree.actions.reloaders.reloaders" ).reload_explorer ()
95
+ end
96
+ end
97
+
98
+ if M .config .ui .confirm .remove then
99
+ local prompt_select = " Remove " .. node .name .. " ?"
100
+ local prompt_input = prompt_select .. " y/n: "
101
+ lib .prompt (prompt_input , prompt_select , { " y" , " n" }, { " Yes" , " No" }, function (item_short )
102
+ utils .clear_prompt ()
103
+ if item_short == " y" then
104
+ do_remove ()
105
+ end
106
+ end )
107
+ else
108
+ do_remove ()
109
+ end
101
110
end
102
111
103
112
function M .setup (opts )
113
+ M .config = {}
114
+ M .config .ui = opts .ui or {}
104
115
M .enable_reload = not opts .filesystem_watchers .enable
105
116
M .close_window = opts .actions .remove_file .close_window
106
117
end
0 commit comments