From cd8f6c5fb7858d8981fdfb2067bddb3eb86c13d0 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Sun, 5 Sep 2021 10:27:52 -0700 Subject: feat(lsp)!: change handler signature #15504 --- runtime/lua/vim/lsp/buf.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'runtime/lua/vim/lsp/buf.lua') diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index b13d662ccb..8dfd5c9c5b 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -422,6 +422,21 @@ function M.clear_references() util.buf_clear_references() end +--- Requests code actions from all clients and calls the handler exactly once +--- with all aggregated results +---@private +local function code_action_request(params) + local bufnr = vim.api.nvim_get_current_buf() + local method = 'textDocument/codeAction' + vim.lsp.buf_request_all(bufnr, method, params, function(results) + local actions = {} + for _, r in pairs(results) do + vim.list_extend(actions, r.result or {}) + end + vim.lsp.handlers[method](nil, actions, {bufnr=bufnr, method=method}) + end) +end + --- Selects a code action from the input list that is available at the current --- cursor position. -- -- cgit