Skip to content

Commit 2eb915d

Browse files
author
Telman Babayev
committed
Refactor different prompt configs to single ui table
1 parent fdfe70e commit 2eb915d

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

lua/nvim-tree.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,12 @@ local function setup_autocommands(opts)
495495
end
496496

497497
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
498+
ui = {
499+
confirm = {
500+
node_deletion = true,
501+
trash = true,
502+
},
503+
},
498504
file_deletion_confirmation = true,
499505
auto_reload_on_write = true,
500506
disable_netrw = false,

lua/nvim-tree/actions/fs/remove-file.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function M.fn(node)
9696
end
9797

9898

99-
if M.file_deletion_confirmation then
99+
if M.config.ui.confirm.node_deletion then
100100
local prompt_select = "Remove " .. node.name .. " ?"
101101
local prompt_input = prompt_select .. " y/n: "
102102
lib.prompt(prompt_input, prompt_select, { "y", "n" }, { "Yes", "No" }, function(item_short)
@@ -111,9 +111,10 @@ function M.fn(node)
111111
end
112112

113113
function M.setup(opts)
114+
M.config = {}
115+
M.config.ui = opts.ui or {}
114116
M.enable_reload = not opts.filesystem_watchers.enable
115117
M.close_window = opts.actions.remove_file.close_window
116-
M.file_deletion_confirmation = opts.file_deletion_confirmation
117118
end
118119

119120
return M

lua/nvim-tree/actions/fs/trash.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function M.fn(node)
8787
end
8888
end
8989

90-
if M.config.trash.require_confirm then
90+
if M.config.ui.confirm.trash then
9191
local prompt_select = "Trash " .. node.name .. " ?"
9292
local prompt_input = prompt_select .. " y/n: "
9393
lib.prompt(prompt_input, prompt_select, { "y", "n" }, { "Yes", "No" }, function(item_short)
@@ -103,7 +103,7 @@ end
103103

104104
function M.setup(opts)
105105
M.config = {}
106-
M.config.trash = opts.trash or {}
106+
M.config.ui = opts.ui or {}
107107
M.enable_reload = not opts.filesystem_watchers.enable
108108
end
109109

0 commit comments

Comments
 (0)