Neovim for Beginners — Package Manager Plugin

Use mason.nvim to install and manage LSP servers, DAP servers, linters, and formatters.

alpha2phi

--

Neovim for Beginners — Package Manager Plugin

We use the nvim-lsp-installer plugin to install and manage the LSP servers. In this article, we will refactor our existing configuration to use mason.nvim. It is the next-generation version of nvim-lsp-installer that makes it easy to install LSP servers, DAP servers, linters, and formatters.

This article is part of the Neovim for Beginners series.

The Neovim configuration files are available in this repository.

Getting Started

In our existing configuration, we will install these 3 plugins.

  • mason.nvim that allows us to easily manage external editor tooling such as LSP servers, DAP servers, linters, and formatters through a single interface.
  • mason-lspconfig.nvim which is an extension of mason.nvim that bridges mason.nvim with the nvim-lspconfig plugin, making it easier to use both plugins together.
  • mason-tool-installer.nvim is a simple plugin that helps to install or upgrade all of the third-party tools.

In the lua/plugins.lua file, we add the lines to install these plugins.

We remove the nvim-lsp-installer plugin and add the lines to install the 3 plugins.

Configuration

We will refactor the code in the lua/config/lsp/installer.lua file.

mason.nvim

We add the following lines to configure this plugin.

For other configurable parameters, check out the documentation.

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.