]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Fire event when LSP client is attached to a buffer
authorGregory Anders <greg@gpanders.com>
Wed, 30 Mar 2022 14:57:15 +0000 (08:57 -0600)
committerGregory Anders <greg@gpanders.com>
Thu, 31 Mar 2022 14:09:45 +0000 (08:09 -0600)
This provides a hook for users to configure buffers that use LSP. For
example,

    autocmd User LspAttached {
        nnoremap <buffer> <C-]> <Cmd>LspGotoDefinition<CR>
    }

autoload/lsp/lsp.vim
doc/lsp.txt

index e4f4c8ba4c8cfd46471b42eb97fbb576844058c0..9c8accb18efd737c39ed27d5c6291305e208303c 100644 (file)
@@ -406,6 +406,8 @@ export def AddFile(bnr: number): void
     endif
   augroup END
 
+  doautocmd <nomodeline> User LspAttached
+
   buf.BufLspServerSet(bnr, lspserver)
 enddef
 
index 0ad70a077aed7a2057c2c24ea7dd535294684471..6d7be53d403314336f44ca46ca48ae484c5dfb38 100644 (file)
@@ -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: