mirror of
https://github.com/neovim/neovim.git
synced 2026-01-07 03:48:02 +10: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
@@ -59,9 +59,9 @@ end
|
||||
--- @param callback vim._watch.Callback Callback for new events
|
||||
--- @return fun() cancel Stops the watcher
|
||||
function M.watch(path, opts, callback)
|
||||
vim.validate('path', path, 'string', false)
|
||||
vim.validate('path', path, 'string')
|
||||
vim.validate('opts', opts, 'table', true)
|
||||
vim.validate('callback', callback, 'function', false)
|
||||
vim.validate('callback', callback, 'function')
|
||||
|
||||
opts = opts or {}
|
||||
|
||||
@@ -125,9 +125,9 @@ end
|
||||
--- @param callback vim._watch.Callback Callback for new events
|
||||
--- @return fun() cancel Stops the watcher
|
||||
function M.watchdirs(path, opts, callback)
|
||||
vim.validate('path', path, 'string', false)
|
||||
vim.validate('path', path, 'string')
|
||||
vim.validate('opts', opts, 'table', true)
|
||||
vim.validate('callback', callback, 'function', false)
|
||||
vim.validate('callback', callback, 'function')
|
||||
|
||||
opts = opts or {}
|
||||
local debounce = opts.debounce or 500
|
||||
|
||||
Reference in New Issue
Block a user