diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-10-16 17:03:48 +0100 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2024-10-17 16:53:52 +0100 |
commit | 3f3e4837d5f7d2d9cb1c89bd3a5b2ee8a730772a (patch) | |
tree | 54dc9c0e06c7436d18b1863e5b26272dc1948d78 /runtime/lua/vim/ui.lua | |
parent | fa6ab0d90958516d0bc1ed62839d85405ad08fa8 (diff) | |
download | rneovim-3f3e4837d5f7d2d9cb1c89bd3a5b2ee8a730772a.tar.gz rneovim-3f3e4837d5f7d2d9cb1c89bd3a5b2ee8a730772a.tar.bz2 rneovim-3f3e4837d5f7d2d9cb1c89bd3a5b2ee8a730772a.zip |
perf(validate): use lighter version
- Also fix `vim.validate()` for PUC Lua when showing errors for values
that aren't string or number.
Diffstat (limited to 'runtime/lua/vim/ui.lua')
-rw-r--r-- | runtime/lua/vim/ui.lua | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/runtime/lua/vim/ui.lua b/runtime/lua/vim/ui.lua index 532decf5e9..c0f03ceadc 100644 --- a/runtime/lua/vim/ui.lua +++ b/runtime/lua/vim/ui.lua @@ -37,10 +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 }, - on_choice = { on_choice, 'function', false }, - }) + vim.validate('items', items, 'table', false) + vim.validate('on_choice', on_choice, 'function', false) opts = opts or {} local choices = { opts.prompt or 'Select one of:' } local format_item = opts.format_item or tostring @@ -86,10 +84,8 @@ end --- an empty string if nothing was entered), or --- `nil` if the user aborted the dialog. function M.input(opts, on_confirm) - vim.validate({ - opts = { opts, 'table', true }, - on_confirm = { on_confirm, 'function', false }, - }) + vim.validate('opts', opts, 'table', true) + vim.validate('on_confirm', on_confirm, 'function', false) opts = (opts and not vim.tbl_isempty(opts)) and opts or vim.empty_dict() @@ -135,9 +131,7 @@ end --- ---@see |vim.system()| function M.open(path, opt) - vim.validate({ - path = { path, 'string' }, - }) + vim.validate('path', path, 'string') local is_uri = path:match('%w+:') if not is_uri then path = vim.fs.normalize(path) |