fix(lsp): trigger LspDetach on buffer delete (#28795)

Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
This commit is contained in:
Andre Toerien
2024-05-23 12:03:47 +02:00
committed by GitHub
parent bdf15dbe69
commit 5ac8db10f0
2 changed files with 17 additions and 0 deletions

View File

@ -576,10 +576,19 @@ local function buf_attach(bufnr)
on_detach = function()
local params = { textDocument = { uri = uri } }
for _, client in ipairs(lsp.get_clients({ bufnr = bufnr })) do
api.nvim_exec_autocmds('LspDetach', {
buffer = bufnr,
modeline = false,
data = { client_id = client.id },
})
changetracking.reset_buf(client, bufnr)
if client.supports_method(ms.textDocument_didClose) then
client.notify(ms.textDocument_didClose, params)
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