Member-only story

Neovim for Beginners — LSP Installer

Refactor and automate the LSP installation process.

--

Neovim for Beginners — LSP Installer

In this article, let’s refactor our LSP installation process.

This article is part of the Neovim for Beginners series.

The Neovim configuration files can be found in this repository.

The Background

We use nvim-lsp-installer for the installation of language servers. As described in this thread, there are changes and improvements in the plugin to make it even easier to work withnvim-lspconfig and other LSP plugins.

Tip: Check out this article in which we use mason.nvim, the next-generation of nvim-lsp-installer to manage LSP servers, DAP servers, linters, and formatters.

Configure the Installer

Let’s refactor our installer code to use the new APIs and automate the installation of the language servers.

In the lua/config/lsp/installer.lua file, change the code to use the following snippet.

  • We must set up nvim-lsp-installer before nvim-lsp-config (line 8 — line 18).
  • We pass in the list of servers to install automatically to the ensure_installed option. The servers are configured in the lua/config/lsp/init.lua file.
local servers = {
gopls = {},
html = {},
jsonls = {
settings = {
json = {
schemas = require("schemastore").json.schemas(),
},
},
},
pyright = {
analysis = {
typeCheckingMode = "off",
},
},
rust_analyzer = {
....
  • Alternatively, we can use the automatic_installation option, if we want all servers set up via nvim-lspconfig, to be automatically installed.

--

--

alpha2phi
alpha2phi

Written by alpha2phi

Software engineer, Data Science and ML practitioner.

No responses yet