From 5902a132a987d077e0a5f69af545c3fa8ec52d43 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Wed, 30 Mar 2022 08:57:15 -0600 Subject: [PATCH] Fire event when LSP client is attached to a buffer This provides a hook for users to configure buffers that use LSP. For example, autocmd User LspAttached { nnoremap LspGotoDefinition } --- autoload/lsp/lsp.vim | 2 ++ doc/lsp.txt | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index e4f4c8b..9c8accb 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -406,6 +406,8 @@ export def AddFile(bnr: number): void endif augroup END + doautocmd User LspAttached + buf.BufLspServerSet(bnr, lspserver) enddef diff --git a/doc/lsp.txt b/doc/lsp.txt index 0ad70a0..6d7be53 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -543,5 +543,11 @@ default. The following example disables omni-completion for python: > \ ] < ============================================================================== +7. Autocommands *lsp-autocmds* + + *LspAttached* +LspAttached A |User| autocommand fired when the LSP client + attaches to a buffer. Can be used to configure + buffer-local mappings or options. vim:tw=78:ts=8:noet:ft=help:norl: -- 2.48.1