mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-23 09:18:51 +02:00
fix(lsp): added support for has
as array for lsp keymaps
This commit is contained in:
parent
38b8736b81
commit
01e6718e03
1 changed files with 12 additions and 5 deletions
|
@ -3,8 +3,8 @@ local M = {}
|
||||||
---@type LazyKeysLspSpec[]|nil
|
---@type LazyKeysLspSpec[]|nil
|
||||||
M._keys = nil
|
M._keys = nil
|
||||||
|
|
||||||
---@alias LazyKeysLspSpec LazyKeysSpec|{has?:string, cond?:fun():boolean}
|
---@alias LazyKeysLspSpec LazyKeysSpec|{has?:string|string[], cond?:fun():boolean}
|
||||||
---@alias LazyKeysLsp LazyKeys|{has?:string, cond?:fun():boolean}
|
---@alias LazyKeysLsp LazyKeys|{has?:string|string[], cond?:fun():boolean}
|
||||||
|
|
||||||
---@return LazyKeysLspSpec[]
|
---@return LazyKeysLspSpec[]
|
||||||
function M.get()
|
function M.get()
|
||||||
|
@ -26,8 +26,7 @@ function M.get()
|
||||||
{ "<leader>cc", vim.lsp.codelens.run, desc = "Run Codelens", mode = { "n", "v" }, has = "codeLens" },
|
{ "<leader>cc", vim.lsp.codelens.run, desc = "Run Codelens", mode = { "n", "v" }, has = "codeLens" },
|
||||||
{ "<leader>cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" },
|
{ "<leader>cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" },
|
||||||
{ "<leader>cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" },
|
{ "<leader>cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" },
|
||||||
{ "<leader>cR", LazyVim.lsp.rename_file, desc = "Rename File", mode ={"n"}, has = "workspace/didRenameFiles"},
|
{ "<leader>cR", LazyVim.lsp.rename_file, desc = "Rename File", mode ={"n"}, has = { "workspace/didRenameFiles", "workspace/willRenameFiles" } },
|
||||||
{ "<leader>cR", LazyVim.lsp.rename_file, desc = "Rename File", mode ={"n"}, has = "workspace/willRenameFiles"},
|
|
||||||
{
|
{
|
||||||
"<leader>cA",
|
"<leader>cA",
|
||||||
function()
|
function()
|
||||||
|
@ -69,8 +68,16 @@ function M.get()
|
||||||
return M._keys
|
return M._keys
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param method string
|
---@param method string|string[]
|
||||||
function M.has(buffer, method)
|
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
|
method = method:find("/") and method or "textDocument/" .. method
|
||||||
local clients = LazyVim.lsp.get_clients({ bufnr = buffer })
|
local clients = LazyVim.lsp.get_clients({ bufnr = buffer })
|
||||||
for _, client in ipairs(clients) do
|
for _, client in ipairs(clients) do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue