Neovim for Beginners — LSP (Part 1)

Configure the built-in LSP (Language Server Protocol) client.

alpha2phi
6 min readJan 28, 2022
Neovim for Beginners — LSP

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-lspconfigplugin 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 the omnifunc(:h omnifunc) handler. The omnifuncoption specifies a function to be used for insert mode omni completion with CTRL-X CTRL-O.
  • Configure the vim.lsp.formatexpr function as the handler for formatexpr(:h formatexpr). The formatexpr option specifies an expression that is evaluated to format a range of lines for the gqoperator or automatic formatting (:h formatoptions).
  • Configure LSP completion using coq.nvim and nvim-cmp. Previously, we talked about these two completion plugins in this article.

--

--

alpha2phi
alpha2phi

Written by alpha2phi

Software engineer, Data Science and ML practitioner.

Responses (7)