diff options
author | Hirokazu Hata <h.hata.ai.t@gmail.com> | 2020-05-26 21:55:45 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-26 08:55:45 -0400 |
commit | 15b762761ad966f91d452fdd28c718f2fd3e45be (patch) | |
tree | cfd7c1ddd1b868862f571caf491cd9546853ca23 /runtime/lua/vim | |
parent | 618e9a769220ffe331cc554c51485f9230a544ec (diff) | |
download | rneovim-15b762761ad966f91d452fdd28c718f2fd3e45be.tar.gz rneovim-15b762761ad966f91d452fdd28c718f2fd3e45be.tar.bz2 rneovim-15b762761ad966f91d452fdd28c718f2fd3e45be.zip |
lsp: make the command error message more detailed (#11633)
* lsp.lua: make the error message more detailed
* test: add lsp._cmd_part test
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r-- | runtime/lua/vim/lsp.lua | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 61da2130c8..7135d2c5b6 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -122,19 +122,19 @@ local function validate_encoding(encoding) end function lsp._cmd_parts(input) - local cmd, cmd_args - if vim.tbl_islist(input) then - cmd = input[1] - cmd_args = {} - -- Don't mutate our input. - for i, v in ipairs(input) do - assert(type(v) == 'string', "input arguments must be strings") - if i > 1 then - table.insert(cmd_args, v) - end + vim.validate{cmd={ + input, + function() return vim.tbl_islist(input) end, + "list"}} + + local cmd = input[1] + local cmd_args = {} + -- Don't mutate our input. + for i, v in ipairs(input) do + vim.validate{["cmd argument"]={v, "s"}} + if i > 1 then + table.insert(cmd_args, v) end - else - error("cmd type must be list.") end return cmd, cmd_args end @@ -524,7 +524,7 @@ function lsp.start_client(config) function client.request(method, params, callback, bufnr) if not callback then callback = resolve_callback(method) - or error("not found: request callback for client "..client.name) + or error(string.format("not found: %q request callback for client %q.", method, client.name)) end local _ = log.debug() and log.debug(log_prefix, "client.request", client_id, method, params, callback, bufnr) -- TODO keep these checks or just let it go anyway? |