Skip to content

Commit

Permalink
Use the LSPBufferAutocmds group for the internal LspServerReady autocmd
Browse files Browse the repository at this point in the history
  • Loading branch information
yegappan committed Sep 22, 2024
1 parent 5ff1faa commit c1ec74d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions autoload/lsp/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions autoload/lsp/lspserver.vim
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def ServerInitReply(lspserver: dict<any>, initResult: dict<any>): void
exe $'doautocmd <nomodeline> User LspServerReady{lspserver.name}'
endif
# Used internally, and shouldn't be used by users
if exists($'#User#LspServerReady_{lspserver.id}')
exe $'doautocmd <nomodeline> User LspServerReady_{lspserver.id}'
if exists($'#LSPBufferAutocmds#User#LspServerReady_{lspserver.id}')
exe $'doautocmd <nomodeline> LSPBufferAutocmds User LspServerReady_{lspserver.id}'
endif

# set the server debug trace level
Expand Down

0 comments on commit c1ec74d

Please sign in to comment.