mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
(cherry picked from commit 2908f71dc9
)
This commit is contained in:

committed by
GitHub

parent
4efca7cda5
commit
3a354bfcaa
@@ -497,6 +497,30 @@ local function text_document_did_save_handler(bufnr)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param bufnr integer resolved buffer
|
||||||
|
---@param client vim.lsp.Client
|
||||||
|
local function buf_detach_client(bufnr, client)
|
||||||
|
api.nvim_exec_autocmds('LspDetach', {
|
||||||
|
buffer = bufnr,
|
||||||
|
modeline = false,
|
||||||
|
data = { client_id = client.id },
|
||||||
|
})
|
||||||
|
|
||||||
|
changetracking.reset_buf(client, bufnr)
|
||||||
|
|
||||||
|
if vim.tbl_get(client.server_capabilities, 'textDocumentSync', 'openClose') then
|
||||||
|
local uri = vim.uri_from_bufnr(bufnr)
|
||||||
|
local params = { textDocument = { uri = uri } }
|
||||||
|
client.notify(ms.textDocument_didClose, params)
|
||||||
|
end
|
||||||
|
|
||||||
|
client.attached_buffers[bufnr] = nil
|
||||||
|
util.buf_versions[bufnr] = nil
|
||||||
|
|
||||||
|
local namespace = lsp.diagnostic.get_namespace(client.id)
|
||||||
|
vim.diagnostic.reset(namespace, bufnr)
|
||||||
|
end
|
||||||
|
|
||||||
--- @type table<integer,true>
|
--- @type table<integer,true>
|
||||||
local attached_buffers = {}
|
local attached_buffers = {}
|
||||||
|
|
||||||
@@ -570,26 +594,10 @@ local function buf_attach(bufnr)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
on_detach = function()
|
on_detach = function()
|
||||||
local params = { textDocument = { uri = uri } }
|
local clients = lsp.get_clients({ bufnr = bufnr, _uninitialized = true })
|
||||||
for _, client in ipairs(lsp.get_clients({ bufnr = bufnr })) do
|
for _, client in ipairs(clients) do
|
||||||
api.nvim_exec_autocmds('LspDetach', {
|
buf_detach_client(bufnr, client)
|
||||||
buffer = bufnr,
|
|
||||||
modeline = false,
|
|
||||||
data = { client_id = client.id },
|
|
||||||
})
|
|
||||||
|
|
||||||
changetracking.reset_buf(client, bufnr)
|
|
||||||
if vim.tbl_get(client.server_capabilities, 'textDocumentSync', 'openClose') then
|
|
||||||
client.notify(ms.textDocument_didClose, params)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local namespace = lsp.diagnostic.get_namespace(client.id)
|
|
||||||
vim.diagnostic.reset(namespace, bufnr)
|
|
||||||
end
|
|
||||||
for _, client in ipairs(all_clients) do
|
|
||||||
client.attached_buffers[bufnr] = nil
|
|
||||||
end
|
|
||||||
util.buf_versions[bufnr] = nil
|
|
||||||
attached_buffers[bufnr] = nil
|
attached_buffers[bufnr] = nil
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -664,27 +672,9 @@ function lsp.buf_detach_client(bufnr, client_id)
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
else
|
||||||
|
buf_detach_client(bufnr, client)
|
||||||
end
|
end
|
||||||
|
|
||||||
api.nvim_exec_autocmds('LspDetach', {
|
|
||||||
buffer = bufnr,
|
|
||||||
modeline = false,
|
|
||||||
data = { client_id = client_id },
|
|
||||||
})
|
|
||||||
|
|
||||||
changetracking.reset_buf(client, bufnr)
|
|
||||||
|
|
||||||
if vim.tbl_get(client.server_capabilities, 'textDocumentSync', 'openClose') then
|
|
||||||
local uri = vim.uri_from_bufnr(bufnr)
|
|
||||||
local params = { textDocument = { uri = uri } }
|
|
||||||
client.notify(ms.textDocument_didClose, params)
|
|
||||||
end
|
|
||||||
|
|
||||||
client.attached_buffers[bufnr] = nil
|
|
||||||
util.buf_versions[bufnr] = nil
|
|
||||||
|
|
||||||
local namespace = lsp.diagnostic.get_namespace(client_id)
|
|
||||||
vim.diagnostic.reset(namespace, bufnr)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Checks if a buffer is attached for a particular client.
|
--- Checks if a buffer is attached for a particular client.
|
||||||
|
Reference in New Issue
Block a user