mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-27 03:09:07 +02:00
fix(lsp): use proper buffer for dynamic capabilities. Fixes #3246
This commit is contained in:
parent
c6e8c5b450
commit
10ed3082a4
1 changed files with 18 additions and 5 deletions
|
@ -43,12 +43,13 @@ function M.setup()
|
||||||
---@diagnostic disable-next-line: no-unknown
|
---@diagnostic disable-next-line: no-unknown
|
||||||
local ret = register_capability(err, res, ctx)
|
local ret = register_capability(err, res, ctx)
|
||||||
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
||||||
local buffer = vim.api.nvim_get_current_buf()
|
|
||||||
if client then
|
if client then
|
||||||
vim.api.nvim_exec_autocmds("User", {
|
for buffer in ipairs(client.attached_buffers) do
|
||||||
pattern = "LspDynamicCapability",
|
vim.api.nvim_exec_autocmds("User", {
|
||||||
data = { client_id = client.id, buffer = buffer },
|
pattern = "LspDynamicCapability",
|
||||||
})
|
data = { client_id = client.id, buffer = buffer },
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
@ -58,6 +59,18 @@ end
|
||||||
|
|
||||||
---@param client vim.lsp.Client
|
---@param client vim.lsp.Client
|
||||||
function M._check_methods(client, buffer)
|
function M._check_methods(client, buffer)
|
||||||
|
-- don't trigger on invalid buffers
|
||||||
|
if not vim.api.nvim_buf_is_valid(buffer) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- don't trigger on non-listed buffers
|
||||||
|
if not vim.bo[buffer].buflisted then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- don't trigger on nofile buffers
|
||||||
|
if vim.bo[buffer].buftype == "nofile" then
|
||||||
|
return
|
||||||
|
end
|
||||||
for method, clients in pairs(M._supports_method) do
|
for method, clients in pairs(M._supports_method) do
|
||||||
clients[client] = clients[client] or {}
|
clients[client] = clients[client] or {}
|
||||||
if not clients[client][buffer] then
|
if not clients[client][buffer] then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue