From af200c10cf9d117a14ebf9f2e9c666721a1090d6 Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Thu, 23 May 2024 09:17:53 -0400 Subject: fix(lsp): check if buffer was detached in on_init callback (#28914) Co-authored-by: Jongwook Choi --- runtime/lua/vim/lsp/client.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/lsp/client.lua b/runtime/lua/vim/lsp/client.lua index 8fb5879e9b..4beb7fefda 100644 --- a/runtime/lua/vim/lsp/client.lua +++ b/runtime/lua/vim/lsp/client.lua @@ -612,7 +612,10 @@ function Client:initialize() self:_run_callbacks(self._on_init_cbs, lsp.client_errors.ON_INIT_CALLBACK_ERROR, self, result) for buf in pairs(reattach_bufs) do - self:_on_attach(buf) + -- The buffer may have been detached in the on_init callback. + if self.attached_buffers[buf] then + self:_on_attach(buf) + end end log.info( -- cgit