Neovim for Beginners —Plugin Management

Manage Neovim packages using a plugin or package manager.

6 min readDec 29, 2021


Neovim for Beginners — Plugin Management

Let’s understand Neovim packages (:h packages), and see how to properly manage them using a plugin/package manager (packer.nvim).

We are going to

  • Understand how packages work in Neovim.
  • Configure profiling to monitor and profile the plugins.
  • Understand the different options to lazy load plugins for better startup performance.
  • Lazy load plugins using different options.
  • Configure other useful plugins and lazy load them.

This article is part of the Neovim for Beginners series.

The Neovim configuration files can be found in this repository.


Let’s begin with the XDG base directory.

Neovim uses the $XDG_CONFIG_HOME and $XDG_DATA_HOME environment variables if they exist.

  • For Linux/Unix, the$XDG_CONFIG_HOME configuration directory defaults to ~/.config and~/.config/nvim. In Windows, it defaults to ~/AppData/Local ~/AppData/Local/nvim.
  • For the data directory $XDG_DATA_HOME, in Linux/Unix it defaults to ~/.local/share and ~/.local/share/nvim. In Windows, it defaults to ~/AppData/Local and ~/AppData/Local/nvim-data.

Neovim plugins or packages are installed under the$XDG_DATA_HOME directory. For our configuration, we explicitly specify the location of the$XDG_DATA_HOME in our installation script.

rm -rf $NVIM_BEGINNERmkdir -p $NVIM_BEGINNER/share
mkdir -p $NVIM_BEGINNER/nvim
stow --restow --target=$NVIM_BEGINNER/nvim .alias nvb='XDG_DATA_HOME=$NVIM_BEGINNER/share XDG_CONFIG_HOME=$NVIM_BEGINNER nvim'export nvb
  • In the lua/plugins.lua file, we specify the installation path ofpacker.nvim to be under $XDG_DATA_HOME/site/pack/packer/start.
local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim"




Software engineer, Data Science and ML practitioner.