mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
feat(vim.validate): improve fast form and deprecate spec form
Problem: `vim.validate()` takes two forms when it only needs one. Solution: - Teach the fast form all the features of the spec form. - Deprecate the spec form. - General optimizations for both forms. - Add a `message` argument which can be used alongside or in place of the `optional` argument.
This commit is contained in:
committed by
Lewis Russell
parent
6fd13eedda
commit
3572319b4c
@@ -37,8 +37,8 @@ local M = {}
|
||||
--- `idx` is the 1-based index of `item` within `items`.
|
||||
--- `nil` if the user aborted the dialog.
|
||||
function M.select(items, opts, on_choice)
|
||||
vim.validate('items', items, 'table', false)
|
||||
vim.validate('on_choice', on_choice, 'function', false)
|
||||
vim.validate('items', items, 'table')
|
||||
vim.validate('on_choice', on_choice, 'function')
|
||||
opts = opts or {}
|
||||
local choices = { opts.prompt or 'Select one of:' }
|
||||
local format_item = opts.format_item or tostring
|
||||
@@ -85,7 +85,7 @@ end
|
||||
--- `nil` if the user aborted the dialog.
|
||||
function M.input(opts, on_confirm)
|
||||
vim.validate('opts', opts, 'table', true)
|
||||
vim.validate('on_confirm', on_confirm, 'function', false)
|
||||
vim.validate('on_confirm', on_confirm, 'function')
|
||||
|
||||
opts = (opts and not vim.tbl_isempty(opts)) and opts or vim.empty_dict()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user