Neovim for Beginners — LSP (Part 1)
Configure the built-in LSP (Language Server Protocol) client.
Neovim supports the Language Server Protocol (LSP), which means it acts as a client to LSP servers and includes a Lua framework vim.lsp
(:h vim.lsp
) for building enhanced LSP tools. The language servers are provided by third parties.
In this article, we are going to
- Configure the
nvim-lspconfig
plugin that provides common configuration for various language servers. - Configure a language server installer to make it easy to install any language server.
- Configure key mappings for the LSP features.
- Configure the
vim.lsp.omnifunc
function (:h vim.lsp.omnifunc
) as theomnifunc
(:h omnifunc
) handler. Theomnifunc
option specifies a function to be used for insert modeomni
completion withCTRL-X CTRL-O
. - Configure the
vim.lsp.formatexpr
function as the handler forformatexpr
(:h formatexpr
). Theformatexpr
option specifies an expression that is evaluated to format a range of lines for thegq
operator or automatic formatting (:h formatoptions
). - Configure LSP completion using
coq.nvim
andnvim-cmp
. Previously, we talked about these two completion plugins in this article.