feat: add kind param to vim.ui.select function calls (#2602)
* feat: add kind param to vim.ui.select function calls * feat: add kind param to prompts for bookmark actions * docs: add section for prompts * docs: add section for prompts --------- Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
parent
02ae52357b
commit
dc839a72a6
@ -47,8 +47,9 @@ CONTENTS *nvim-tree*
|
|||||||
7.1 Mappings: Default |nvim-tree-mappings-default|
|
7.1 Mappings: Default |nvim-tree-mappings-default|
|
||||||
8. Highlight |nvim-tree-highlight|
|
8. Highlight |nvim-tree-highlight|
|
||||||
9. Events |nvim-tree-events|
|
9. Events |nvim-tree-events|
|
||||||
10. OS Specific Restrictions |nvim-tree-os-specific|
|
10. Prompts |nvim-tree-prompts|
|
||||||
11. Netrw |nvim-tree-netrw|
|
11. OS Specific Restrictions |nvim-tree-os-specific|
|
||||||
|
12. Netrw |nvim-tree-netrw|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
1. INTRODUCTION *nvim-tree-introduction*
|
1. INTRODUCTION *nvim-tree-introduction*
|
||||||
@ -2442,7 +2443,32 @@ Example subscription: >
|
|||||||
})
|
})
|
||||||
<
|
<
|
||||||
==============================================================================
|
==============================================================================
|
||||||
10. OS SPECIFIC RESTRICTIONS *nvim-tree-os-specific*
|
10. PROMPTS *nvim-tree-prompts*
|
||||||
|
|
||||||
|
Some NvimTree actions use the builtin |vim.ui.select| prompt API for
|
||||||
|
confirmations when the |nvim_tree.select_prompts| option is set.
|
||||||
|
|
||||||
|
The API accepts the optional `kind` key as part of the {opts} parameter, which
|
||||||
|
can can be used to identify the type of prompt, to allow user side
|
||||||
|
configurations for different types of prompts.
|
||||||
|
|
||||||
|
- `nvimtree_overwrite_rename`
|
||||||
|
overwrite or rename during |nvim-tree-api.fs.paste()|
|
||||||
|
|
||||||
|
- `nvimtree_remove`
|
||||||
|
delete during |nvim-tree-api.fs.remove()|
|
||||||
|
|
||||||
|
- `nvimtree_trash`
|
||||||
|
send to trash during |nvim-tree-api.fs.trash()|
|
||||||
|
|
||||||
|
- `nvimtree_bulk_delete`
|
||||||
|
delete all bookmarked during |nvim-tree-api.marks.bulk.delete()|
|
||||||
|
|
||||||
|
- `nvimtree_bulk_trash`
|
||||||
|
send all bookmarked to trash during |nvim-tree-api.marks.bulk.trash()|
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
11. OS SPECIFIC RESTRICTIONS *nvim-tree-os-specific*
|
||||||
|
|
||||||
macOS
|
macOS
|
||||||
- Rename to different case is not possible when using a case insensitive file
|
- Rename to different case is not possible when using a case insensitive file
|
||||||
@ -2455,7 +2481,7 @@ Windows WSL and PowerShell
|
|||||||
- Some filesystem watcher error related to permissions will not be reported
|
- Some filesystem watcher error related to permissions will not be reported
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
11. NETRW *nvim-tree-netrw*
|
12. NETRW *nvim-tree-netrw*
|
||||||
|
|
||||||
|netrw| is a standard neovim plugin that is enabled by default. It provides,
|
|netrw| is a standard neovim plugin that is enabled by default. It provides,
|
||||||
amongst other functionality, a file/directory browser.
|
amongst other functionality, a file/directory browser.
|
||||||
|
|||||||
@ -131,7 +131,7 @@ local function do_single_paste(source, dest, action_type, action_fn)
|
|||||||
else
|
else
|
||||||
local prompt_select = "Overwrite " .. dest .. " ?"
|
local prompt_select = "Overwrite " .. dest .. " ?"
|
||||||
local prompt_input = prompt_select .. " R(ename)/y/n: "
|
local prompt_input = prompt_select .. " R(ename)/y/n: "
|
||||||
lib.prompt(prompt_input, prompt_select, { "", "y", "n" }, { "Rename", "Yes", "No" }, function(item_short)
|
lib.prompt(prompt_input, prompt_select, { "", "y", "n" }, { "Rename", "Yes", "No" }, "nvimtree_overwrite_rename", function(item_short)
|
||||||
utils.clear_prompt()
|
utils.clear_prompt()
|
||||||
if item_short == "y" then
|
if item_short == "y" then
|
||||||
on_process()
|
on_process()
|
||||||
|
|||||||
@ -130,7 +130,7 @@ function M.fn(node)
|
|||||||
items_long = { "No", "Yes" }
|
items_long = { "No", "Yes" }
|
||||||
end
|
end
|
||||||
|
|
||||||
lib.prompt(prompt_input, prompt_select, items_short, items_long, function(item_short)
|
lib.prompt(prompt_input, prompt_select, items_short, items_long, "nvimtree_remove", function(item_short)
|
||||||
utils.clear_prompt()
|
utils.clear_prompt()
|
||||||
if item_short == "y" or item_short == (M.config.ui.confirm.default_yes and "") then
|
if item_short == "y" or item_short == (M.config.ui.confirm.default_yes and "") then
|
||||||
do_remove()
|
do_remove()
|
||||||
|
|||||||
@ -102,7 +102,7 @@ function M.fn(node)
|
|||||||
items_long = { "No", "Yes" }
|
items_long = { "No", "Yes" }
|
||||||
end
|
end
|
||||||
|
|
||||||
lib.prompt(prompt_input, prompt_select, items_short, items_long, function(item_short)
|
lib.prompt(prompt_input, prompt_select, items_short, items_long, "nvimtree_trash", function(item_short)
|
||||||
utils.clear_prompt()
|
utils.clear_prompt()
|
||||||
if item_short == "y" or item_short == (M.config.ui.confirm.default_yes and "") then
|
if item_short == "y" or item_short == (M.config.ui.confirm.default_yes and "") then
|
||||||
do_trash()
|
do_trash()
|
||||||
|
|||||||
@ -157,8 +157,9 @@ end
|
|||||||
---@param prompt_select string
|
---@param prompt_select string
|
||||||
---@param items_short string[]
|
---@param items_short string[]
|
||||||
---@param items_long string[]
|
---@param items_long string[]
|
||||||
|
---@param kind string|nil
|
||||||
---@param callback fun(item_short: string)
|
---@param callback fun(item_short: string)
|
||||||
function M.prompt(prompt_input, prompt_select, items_short, items_long, callback)
|
function M.prompt(prompt_input, prompt_select, items_short, items_long, kind, callback)
|
||||||
local function format_item(short)
|
local function format_item(short)
|
||||||
for i, s in ipairs(items_short) do
|
for i, s in ipairs(items_short) do
|
||||||
if short == s then
|
if short == s then
|
||||||
@ -169,7 +170,7 @@ function M.prompt(prompt_input, prompt_select, items_short, items_long, callback
|
|||||||
end
|
end
|
||||||
|
|
||||||
if M.select_prompts then
|
if M.select_prompts then
|
||||||
vim.ui.select(items_short, { prompt = prompt_select, format_item = format_item }, function(item_short)
|
vim.ui.select(items_short, { prompt = prompt_select, kind = kind, format_item = format_item }, function(item_short)
|
||||||
callback(item_short)
|
callback(item_short)
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
|
|||||||
@ -33,7 +33,7 @@ function M.bulk_delete()
|
|||||||
if M.config.ui.confirm.remove then
|
if M.config.ui.confirm.remove then
|
||||||
local prompt_select = "Remove bookmarked ?"
|
local prompt_select = "Remove bookmarked ?"
|
||||||
local prompt_input = prompt_select .. " y/N: "
|
local prompt_input = prompt_select .. " y/N: "
|
||||||
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, function(item_short)
|
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, "nvimtree_bulk_delete", function(item_short)
|
||||||
utils.clear_prompt()
|
utils.clear_prompt()
|
||||||
if item_short == "y" then
|
if item_short == "y" then
|
||||||
do_delete(nodes)
|
do_delete(nodes)
|
||||||
|
|||||||
@ -28,7 +28,7 @@ function M.bulk_trash()
|
|||||||
if M.config.ui.confirm.trash then
|
if M.config.ui.confirm.trash then
|
||||||
local prompt_select = "Trash bookmarked ?"
|
local prompt_select = "Trash bookmarked ?"
|
||||||
local prompt_input = prompt_select .. " y/N: "
|
local prompt_input = prompt_select .. " y/N: "
|
||||||
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, function(item_short)
|
lib.prompt(prompt_input, prompt_select, { "", "y" }, { "No", "Yes" }, "nvimtree_bulk_trash", function(item_short)
|
||||||
utils.clear_prompt()
|
utils.clear_prompt()
|
||||||
if item_short == "y" then
|
if item_short == "y" then
|
||||||
do_trash(nodes)
|
do_trash(nodes)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user