aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/ui.lua
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2023-09-14 08:23:01 -0500
committerGitHub <noreply@github.com>2023-09-14 08:23:01 -0500
commit2e92065686f62851318150a315591c30b8306a4b (patch)
tree3d4d216f7b031cd2e966380f9b32d1aae472d32f /runtime/lua/vim/ui.lua
parent9fc321c9768d1a18893e14f46b0ebacef1be1db4 (diff)
downloadrneovim-2e92065686f62851318150a315591c30b8306a4b.tar.gz
rneovim-2e92065686f62851318150a315591c30b8306a4b.tar.bz2
rneovim-2e92065686f62851318150a315591c30b8306a4b.zip
docs: replace <pre> with ``` (#25136)
Diffstat (limited to 'runtime/lua/vim/ui.lua')
-rw-r--r--runtime/lua/vim/ui.lua54
1 files changed, 28 insertions, 26 deletions
diff --git a/runtime/lua/vim/ui.lua b/runtime/lua/vim/ui.lua
index cd90886489..b6ddf337ce 100644
--- a/runtime/lua/vim/ui.lua
+++ b/runtime/lua/vim/ui.lua
@@ -3,6 +3,23 @@ local M = {}
--- Prompts the user to pick from a list of items, allowing arbitrary (potentially asynchronous)
--- work until `on_choice`.
---
+--- Example:
+---
+--- ```lua
+--- vim.ui.select({ 'tabs', 'spaces' }, {
+--- prompt = 'Select tabs or spaces:',
+--- format_item = function(item)
+--- return "I'd like to choose " .. item
+--- end,
+--- }, function(choice)
+--- if choice == 'spaces' then
+--- vim.o.expandtab = true
+--- else
+--- vim.o.expandtab = false
+--- end
+--- end)
+--- ```
+---
---@param items table Arbitrary items
---@param opts table Additional options
--- - prompt (string|nil)
@@ -19,23 +36,6 @@ local M = {}
--- Called once the user made a choice.
--- `idx` is the 1-based index of `item` within `items`.
--- `nil` if the user aborted the dialog.
----
----
---- Example:
---- <pre>lua
---- vim.ui.select({ 'tabs', 'spaces' }, {
---- prompt = 'Select tabs or spaces:',
---- format_item = function(item)
---- return "I'd like to choose " .. item
---- end,
---- }, function(choice)
---- if choice == 'spaces' then
---- vim.o.expandtab = true
---- else
---- vim.o.expandtab = false
---- end
---- end)
---- </pre>
function M.select(items, opts, on_choice)
vim.validate({
items = { items, 'table', false },
@@ -58,6 +58,14 @@ end
--- Prompts the user for input, allowing arbitrary (potentially asynchronous) work until
--- `on_confirm`.
---
+--- Example:
+---
+--- ```lua
+--- vim.ui.input({ prompt = 'Enter value for shiftwidth: ' }, function(input)
+--- vim.o.shiftwidth = tonumber(input)
+--- end)
+--- ```
+---
---@param opts table Additional options. See |input()|
--- - prompt (string|nil)
--- Text of the prompt
@@ -77,13 +85,6 @@ end
--- `input` is what the user typed (it might be
--- an empty string if nothing was entered), or
--- `nil` if the user aborted the dialog.
----
---- Example:
---- <pre>lua
---- vim.ui.input({ prompt = 'Enter value for shiftwidth: ' }, function(input)
---- vim.o.shiftwidth = tonumber(input)
---- end)
---- </pre>
function M.input(opts, on_confirm)
vim.validate({
on_confirm = { on_confirm, 'function', false },
@@ -110,11 +111,12 @@ end
--- Expands "~/" and environment variables in filesystem paths.
---
--- Examples:
---- <pre>lua
+---
+--- ```lua
--- vim.ui.open("https://neovim.io/")
--- vim.ui.open("~/path/to/file")
--- vim.ui.open("$VIMRUNTIME")
---- </pre>
+--- ```
---
---@param path string Path or URL to open
---