From c1ec74dd78ec7c168eda6e271abdd3589adb1c6a Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Sun, 22 Sep 2024 09:32:57 -0700 Subject: [PATCH] Use the LSPBufferAutocmds group for the internal LspServerReady autocmd --- autoload/lsp/lsp.vim | 10 +++++++--- autoload/lsp/lspserver.vim | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index 5138c177..adbd60c0 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -482,9 +482,13 @@ export def AddFile(bnr: number): void if lspserver.ready BufferInit(lspserver.id, bnr) else - augroup LSPBufferAutocmds - exe $'autocmd User LspServerReady_{lspserver.id} ++once BufferInit({lspserver.id}, {bnr})' - augroup END + # Lsp server is not ready yet. Initialize the lsp state for this buffer + # when the server is ready. + autocmd_add([{group: 'LSPBufferAutocmds', + event: 'User', + pattern: $'LspServerReady_{lspserver.id}', + once: true, + cmd: $'BufferInit({lspserver.id}, {bnr})'}]) endif endfor enddef diff --git a/autoload/lsp/lspserver.vim b/autoload/lsp/lspserver.vim index 3d91520f..7304b003 100644 --- a/autoload/lsp/lspserver.vim +++ b/autoload/lsp/lspserver.vim @@ -132,8 +132,8 @@ def ServerInitReply(lspserver: dict, initResult: dict): void exe $'doautocmd User LspServerReady{lspserver.name}' endif # Used internally, and shouldn't be used by users - if exists($'#User#LspServerReady_{lspserver.id}') - exe $'doautocmd User LspServerReady_{lspserver.id}' + if exists($'#LSPBufferAutocmds#User#LspServerReady_{lspserver.id}') + exe $'doautocmd LSPBufferAutocmds User LspServerReady_{lspserver.id}' endif # set the server debug trace level