diff --git a/lua/lazyvim/plugins/lsp/keymaps.lua b/lua/lazyvim/plugins/lsp/keymaps.lua index b667ab0c..9a9aab38 100644 --- a/lua/lazyvim/plugins/lsp/keymaps.lua +++ b/lua/lazyvim/plugins/lsp/keymaps.lua @@ -3,8 +3,8 @@ local M = {} ---@type LazyKeysLspSpec[]|nil M._keys = nil ----@alias LazyKeysLspSpec LazyKeysSpec|{has?:string, cond?:fun():boolean} ----@alias LazyKeysLsp LazyKeys|{has?:string, cond?:fun():boolean} +---@alias LazyKeysLspSpec LazyKeysSpec|{has?:string|string[], cond?:fun():boolean} +---@alias LazyKeysLsp LazyKeys|{has?:string|string[], cond?:fun():boolean} ---@return LazyKeysLspSpec[] function M.get() @@ -26,8 +26,7 @@ function M.get() { "cc", vim.lsp.codelens.run, desc = "Run Codelens", mode = { "n", "v" }, has = "codeLens" }, { "cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" }, { "cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" }, - { "cR", LazyVim.lsp.rename_file, desc = "Rename File", mode ={"n"}, has = "workspace/didRenameFiles"}, - { "cR", LazyVim.lsp.rename_file, desc = "Rename File", mode ={"n"}, has = "workspace/willRenameFiles"}, + { "cR", LazyVim.lsp.rename_file, desc = "Rename File", mode ={"n"}, has = { "workspace/didRenameFiles", "workspace/willRenameFiles" } }, { "cA", function() @@ -69,8 +68,16 @@ function M.get() return M._keys end ----@param method string +---@param method string|string[] function M.has(buffer, method) + if type(method) == "table" then + for _, m in ipairs(method) do + if M.has(buffer, m) then + return true + end + end + return false + end method = method:find("/") and method or "textDocument/" .. method local clients = LazyVim.lsp.get_clients({ bufnr = buffer }) for _, client in ipairs(clients) do