From: Yegappan Lakshmanan <4298407+yegappan@users.noreply.github.com> Date: Fri, 21 Oct 2022 03:16:48 +0000 (-0700) Subject: Update the steps to register LSP servers when using vim-plug to install the lsp plugin. X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=51fba76425fae61de511c3e57203406f3204fbf5;p=vim-lsp.git Update the steps to register LSP servers when using vim-plug to install the lsp plugin. --- diff --git a/README.md b/README.md index edc5ac1..ad156df 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ The following language server protocol (LSP) features are supported: To use the plugin features with a particular file type(s), you need to first register a LSP server for that file type(s). -To register a LSP server, add the following lines to your .vimrc file (use only the LSP servers that you need from the below list): +To register a LSP server, add the following lines to your .vimrc file (use only the LSP servers that you need from the below list). If you used [vim-plug](https://github.com/junegunn/vim-plug) to install the LSP plugin, the steps are described later in this section. ``` let lspServers = [ \ #{ @@ -115,6 +115,21 @@ args|a list of command-line arguments passed to the LSP server. Each argument is The LSP servers are added using the LspAddServer() function. This function accepts a list of LSP servers with the above information. +If you used [vim-plug](https://github.com/junegunn/vim-plug) to install the LSP plugin, then you need to use the VimEnter autocmd to initialize the LSP server and to set the LSP server options. For example: +``` + let lspServers = [ + \ #{ + \ filetype: ['c', 'cpp'], + \ path: '/usr/local/bin/clangd', + \ args: ['--background-index'] + \ } + \ ] + autocmd VimEnter * call LspAddServer(lspServers) + + let lspOpts = {'autoHighlightDiags': v:true} + autocmd VimEnter * call LspOptionsSet(lspOpts) +``` + ## Supported Commands The following commands are provided to use the LSP features.