mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 03:15:39 +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
@@ -132,17 +132,11 @@ end
|
||||
---@return boolean success true if operation was successful
|
||||
---@return string msg full path if operation was successful, else error message
|
||||
function M.trust(opts)
|
||||
vim.validate({
|
||||
path = { opts.path, 's', true },
|
||||
bufnr = { opts.bufnr, 'n', true },
|
||||
action = {
|
||||
opts.action,
|
||||
function(m)
|
||||
return m == 'allow' or m == 'deny' or m == 'remove'
|
||||
end,
|
||||
[["allow" or "deny" or "remove"]],
|
||||
},
|
||||
})
|
||||
vim.validate('path', opts.path, 'string', true)
|
||||
vim.validate('bufnr', opts.bufnr, 'number', true)
|
||||
vim.validate('action', opts.action, function(m)
|
||||
return m == 'allow' or m == 'deny' or m == 'remove'
|
||||
end, [["allow" or "deny" or "remove"]])
|
||||
|
||||
---@cast opts vim.trust.opts
|
||||
local path = opts.path
|
||||
|
||||
Reference in New Issue
Block a user