diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-10-18 11:33:12 +0100 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2024-10-21 11:32:06 +0100 |
commit | 3572319b4cb1a4163624a5fe328886f1928dbc4a (patch) | |
tree | 5e190a6d9ca8a2e0f998ef578f895efee9450fb4 /runtime/lua/vim/lsp/client.lua | |
parent | 6fd13eeddaf5db89c1b81cc7d3d3f1a7da5401a7 (diff) | |
download | rneovim-3572319b4cb1a4163624a5fe328886f1928dbc4a.tar.gz rneovim-3572319b4cb1a4163624a5fe328886f1928dbc4a.tar.bz2 rneovim-3572319b4cb1a4163624a5fe328886f1928dbc4a.zip |
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.
Diffstat (limited to 'runtime/lua/vim/lsp/client.lua')
-rw-r--r-- | runtime/lua/vim/lsp/client.lua | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/runtime/lua/vim/lsp/client.lua b/runtime/lua/vim/lsp/client.lua index d5fc5b8908..d9d6b851d0 100644 --- a/runtime/lua/vim/lsp/client.lua +++ b/runtime/lua/vim/lsp/client.lua @@ -349,24 +349,22 @@ end --- @param config vim.lsp.ClientConfig local function validate_config(config) validate('config', config, 'table') - validate({ - handlers = { config.handlers, 't', true }, - capabilities = { config.capabilities, 't', true }, - cmd_cwd = { config.cmd_cwd, optional_validator(is_dir), 'directory' }, - cmd_env = { config.cmd_env, 't', true }, - detached = { config.detached, 'b', true }, - name = { config.name, 's', true }, - on_error = { config.on_error, 'f', true }, - on_exit = { config.on_exit, { 'f', 't' }, true }, - on_init = { config.on_init, { 'f', 't' }, true }, - on_attach = { config.on_attach, { 'f', 't' }, true }, - settings = { config.settings, 't', true }, - commands = { config.commands, 't', true }, - before_init = { config.before_init, { 'f', 't' }, true }, - offset_encoding = { config.offset_encoding, 's', true }, - flags = { config.flags, 't', true }, - get_language_id = { config.get_language_id, 'f', true }, - }) + validate('handlers', config.handlers, 'table', true) + validate('capabilities', config.capabilities, 'table', true) + validate('cmd_cwd', config.cmd_cwd, optional_validator(is_dir), 'directory') + validate('cmd_env', config.cmd_env, 'table', true) + validate('detached', config.detached, 'boolean', true) + validate('name', config.name, 'string', true) + validate('on_error', config.on_error, 'function', true) + validate('on_exit', config.on_exit, { 'function', 'table' }, true) + validate('on_init', config.on_init, { 'function', 'table' }, true) + validate('on_attach', config.on_attach, { 'function', 'table' }, true) + validate('settings', config.settings, 'table', true) + validate('commands', config.commands, 'table', true) + validate('before_init', config.before_init, { 'function', 'table' }, true) + validate('offset_encoding', config.offset_encoding, 'string', true) + validate('flags', config.flags, 'table', true) + validate('get_language_id', config.get_language_id, 'function', true) assert( ( |