fix(prompt): add select_prompts to suit UI decorator plugins such as dressing and telescope

This commit is contained in:
Alexander Courtis
2022-09-22 13:23:49 +10:00
parent 5cb87c037d
commit ac8d259bad
7 changed files with 54 additions and 15 deletions

View File

@@ -94,12 +94,14 @@ local function do_single_paste(source, dest, action_type, action_fn)
end
if dest_stats then
vim.ui.input({ prompt = dest .. " already exists. Overwrite? y/n/r(ename): " }, function(choice)
local prompt_select = "Overwrite " .. dest .. " ?"
local prompt_input = prompt_select .. " y/n/r(ename): "
lib.prompt(prompt_input, prompt_select, { "y", "n", "r" }, { "Yes", "No", "Rename" }, function(item_short)
utils.clear_prompt()
if choice == "y" then
if item_short == "y" then
on_process()
elseif choice == "r" then
vim.ui.input({ prompt = "New name: ", default = dest, completion = "dir" }, function(new_dest)
elseif item_short == "r" then
vim.ui.input({ prompt = "Rename to ", default = dest, completion = "dir" }, function(new_dest)
utils.clear_prompt()
if new_dest then
do_single_paste(source, new_dest, action_type, action_fn)

View File

@@ -19,9 +19,11 @@ end
local function create_file(file)
if utils.file_exists(file) then
vim.ui.input({ prompt = file .. " already exists. Overwrite? y/n: " }, function(choice)
local prompt_select = "Overwrite " .. file .. " ?"
local prompt_input = prompt_select .. " y/n: "
lib.prompt(prompt_input, prompt_select, { "y", "n" }, { "Yes", "No" }, function(item_short)
utils.clear_prompt()
if choice == "y" then
if item_short == "y" then
create_and_notify(file)
end
end)

View File

@@ -4,6 +4,7 @@ local luv = vim.loop
local utils = require "nvim-tree.utils"
local events = require "nvim-tree.events"
local view = require "nvim-tree.view"
local lib = require "nvim-tree.lib"
local M = {}
@@ -74,10 +75,11 @@ function M.fn(node)
if node.name == ".." then
return
end
vim.ui.input({ prompt = "Remove " .. node.name .. " ? y/n: " }, function(choice)
local prompt_select = "Remove " .. node.name .. " ?"
local prompt_input = prompt_select .. " y/n: "
lib.prompt(prompt_input, prompt_select, { "y", "n" }, { "Yes", "No" }, function(item_short)
utils.clear_prompt()
if choice == "y" then
if item_short == "y" then
if node.nodes ~= nil and not node.link_to then
local success = remove_dir(node.absolute_path)
if not success then

View File

@@ -1,5 +1,7 @@
local a = vim.api
local lib = require "nvim-tree.lib"
local M = {
config = {
is_windows = vim.fn.has "win32" == 1 or vim.fn.has "win32unix" == 1,
@@ -93,9 +95,11 @@ function M.fn(node)
end
if M.config.trash.require_confirm then
vim.ui.input({ prompt = "Trash " .. node.name .. " ? y/n: " }, function(choice)
local prompt_select = "Trash " .. node.name .. " ?"
local prompt_input = prompt_select .. " y/n: "
lib.prompt(prompt_input, prompt_select, { "y", "n" }, { "Yes", "No" }, function(item_short)
utils.clear_prompt()
if choice == "y" then
if item_short == "y" then
do_trash()
end
end)