From 8fd23f4b716a36a0a4b56ae34f6e6a4ab8979045 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Sat, 4 Sep 2021 18:07:53 -0700 Subject: Introduce an ALELSPStarted autocommand (#3878) This User autocommand is trigged immediately after an LSP process is successfully initialized. This provides a way to perform any additional initialization work, such as setting up buffer-level mappings. --- autoload/ale/lsp_linter.vim | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'autoload') diff --git a/autoload/ale/lsp_linter.vim b/autoload/ale/lsp_linter.vim index b8885f31..ad181912 100644 --- a/autoload/ale/lsp_linter.vim +++ b/autoload/ale/lsp_linter.vim @@ -271,6 +271,30 @@ function! ale#lsp_linter#OnInit(linter, details, Callback) abort call ale#lsp#NotifyForChanges(l:conn_id, l:buffer) endif + " Tell the relevant buffer that the LSP has started via an autocmd. + if l:buffer > 0 + if l:buffer == bufnr('') + silent doautocmd User ALELSPStarted + else + execute 'augroup ALELSPStartedGroup' . l:buffer + autocmd! + + execute printf( + \ 'autocmd BufEnter ' + \ . ' doautocmd User ALELSPStarted', + \ l:buffer + \) + + " Replicate ++once behavior for backwards compatibility. + execute printf( + \ 'autocmd BufEnter ' + \ . ' autocmd! ALELSPStartedGroup%d', + \ l:buffer, l:buffer + \) + augroup END + endif + endif + call a:Callback(a:linter, a:details) endfunction -- cgit v1.2.3