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/lsp/buf.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/lsp/buf.lua')
-rw-r--r-- | runtime/lua/vim/lsp/buf.lua | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index ccef314d86..f6837a627f 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -21,10 +21,8 @@ local M = {} --- ---@see |vim.lsp.buf_request()| local function request(method, params, handler) - validate({ - method = { method, 's' }, - handler = { handler, 'f', true }, - }) + validate('method', method, 'string') + validate('handler', handler, 'function', true) return vim.lsp.buf_request(0, method, params, handler) end @@ -439,7 +437,7 @@ end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references ---@param opts? vim.lsp.ListOpts function M.references(context, opts) - validate({ context = { context, 't', true } }) + validate('context', context, 'table', true) local params = util.make_position_params() params.context = context or { includeDeclaration = true, @@ -857,7 +855,7 @@ end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction ---@see vim.lsp.protocol.CodeActionTriggerKind function M.code_action(opts) - validate({ options = { opts, 't', true } }) + validate('options', opts, 'table', true) opts = opts or {} -- Detect old API call code_action(context) which should now be -- code_action({ context = context} ) @@ -935,10 +933,8 @@ end --- @param command_params lsp.ExecuteCommandParams --- @see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_executeCommand function M.execute_command(command_params) - validate({ - command = { command_params.command, 's' }, - arguments = { command_params.arguments, 't', true }, - }) + validate('command', command_params.command, 'string') + validate('arguments', command_params.arguments, 'table', true) command_params = { command = command_params.command, arguments = command_params.arguments, |