diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-09-05 10:27:52 -0700 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2021-09-26 10:25:17 -0700 |
commit | cd8f6c5fb7858d8981fdfb2067bddb3eb86c13d0 (patch) | |
tree | 980dbf25f4342e9cf4b616f6c242df3355963ec8 /runtime/lua/vim/lsp.lua | |
parent | f8e0011534a3f94cfd341fd9bfce1bcf9b1b7b73 (diff) | |
download | rneovim-cd8f6c5fb7858d8981fdfb2067bddb3eb86c13d0.tar.gz rneovim-cd8f6c5fb7858d8981fdfb2067bddb3eb86c13d0.tar.bz2 rneovim-cd8f6c5fb7858d8981fdfb2067bddb3eb86c13d0.zip |
feat(lsp)!: change handler signature #15504
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r-- | runtime/lua/vim/lsp.lua | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 6575e453da..6365091668 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -681,7 +681,7 @@ function lsp.start_client(config) local handler = resolve_handler(method) if handler then -- Method name is provided here for convenience. - handler(nil, method, params, client_id) + handler(nil, params, {method=method, client_id=client_id}) end end @@ -695,7 +695,7 @@ function lsp.start_client(config) local handler = resolve_handler(method) if handler then local _ = log.debug() and log.debug("server_request: found handler for", method) - return handler(nil, method, params, client_id) + return handler(nil, params, {method=method, client_id=client_id}) end local _ = log.debug() and log.debug("server_request: no handler found for", method) return nil, lsp.rpc_response_error(protocol.ErrorCodes.MethodNotFound) @@ -894,7 +894,7 @@ function lsp.start_client(config) local _ = log.debug() and log.debug(log_prefix, "client.request", client_id, method, params, handler, bufnr) return rpc.request(method, params, function(err, result) - handler(err, method, result, client_id, bufnr) + handler(err, result, {method=method, client_id=client_id, bufnr=bufnr}) end) end @@ -915,7 +915,7 @@ function lsp.start_client(config) --@see |vim.lsp.buf_request_sync()| function client.request_sync(method, params, timeout_ms, bufnr) local request_result = nil - local function _sync_handler(err, _, result) + local function _sync_handler(err, result) request_result = { err = err, result = result } end @@ -1274,7 +1274,7 @@ function lsp.buf_request(bufnr, method, params, handler) local unsupported_err = lsp._unsupported_method(method) handler = handler or lsp.handlers[method] if handler then - handler(unsupported_err, method, bufnr) + handler(unsupported_err, nil, {method=method, bufnr=bufnr}) end return end @@ -1314,8 +1314,8 @@ function lsp.buf_request_all(bufnr, method, params, callback) end end) - local function _sync_handler(err, _, result, client_id) - request_results[client_id] = { error = err, result = result } + local function _sync_handler(err, result, ctx) + request_results[ctx.client_id] = { error = err, result = result } result_count = result_count + 1 set_expected_result_count() @@ -1421,7 +1421,7 @@ function lsp.omnifunc(findstart, base) local params = util.make_position_params() local items = {} - lsp.buf_request(bufnr, 'textDocument/completion', params, function(err, _, result) + lsp.buf_request(bufnr, 'textDocument/completion', params, function(err, result) if err or not result or vim.fn.mode() ~= "i" then return end local matches = util.text_document_completion_list_to_complete_items(result, prefix) -- TODO(ashkan): is this the best way to do this? @@ -1496,8 +1496,8 @@ end --@param handler (function) See |lsp-handler| --@param override_config (table) Table containing the keys to override behavior of the {handler} function lsp.with(handler, override_config) - return function(err, method, params, client_id, bufnr, config) - return handler(err, method, params, client_id, bufnr, vim.tbl_deep_extend("force", config or {}, override_config)) + return function(err, result, ctx, config) + return handler(err, result, ctx, vim.tbl_deep_extend("force", config or {}, override_config)) end end |