How to Install Plugins in Neovim

How to Install Plugins in Neovim

Using 'vim-plug' to install plugins in Neovim

We are going to use a plugin manager 'vim-plug' for installing & managing plugins in neovim.

The following tutorial is for Neovim & not for Vim.

installer.gif

Create Config

Create a directory for Neovim config if not already

mkdir ~/.config/nvim

Create an init.vim file

touch ~/.config/nvim/init.vim

Vim-plug installation

curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Create a file for plugins

Create a new file plugins.vim for organisation.

mkdir ~/.config/nvim/vim-plug

touch ~/.config/nvim/vim-plug/plugins.vim

Adding plugins

Add the following to ~/.config/nvim/vim-plug/plugins.vim

" auto-install vim-plug
if empty(glob('~/.config/nvim/autoload/plug.vim'))
  silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  "autocmd VimEnter * PlugInstall
  "autocmd VimEnter * PlugInstall | source $MYVIMRC
endif

call plug#begin('~/.config/nvim/autoload/plugged')

    " Better Syntax Support
    Plug 'sheerun/vim-polyglot'
    " File Explorer
    Plug 'scrooloose/NERDTree'
    " Auto pairs for '(' '[' '{'
    Plug 'jiangmiao/auto-pairs'

call plug#end()

We are adding 3 plugins they are optional but copy the rest of the snippet.

To add a new plugin add between call plug#begin() & call plug#end() in the following Syntax

    " Comment for the plugin
    Plug 'author/plugin-name'

Source plugins.vim

To source plugins.vim to init.vim add the following to init.vim

source $HOME/.config/nvim/vim-plug/plugins.vim

Vim-plug commands

Open nvim

nvim

Plugin Status

Check the status of your plugins

:PlugStatus

Installing Plugins

Install all plugins

:PlugInstall

Updating Plugins

To update your plugins

:PlugUpdate

Removing Plugins

To remove plugins

  1. Remove the plugin from plugins.Vim
  2. Use the following commands
:PlugClean

References

Did you find this article valuable?

Support Chaitanya's blog by becoming a sponsor. Any amount is appreciated!