NeoVim Plugins Guaranteed Hassle Free Installation on Windows 11

NeoVim Plugins Guaranteed Hassle Free Installation on Windows 11


Over the last week I’ve struggled to get NeoVim setup with plugins on Windows 11. I wanted to write a quick step by step guide that would hopefully help anyone who is starting out using NeoVim on Windows. This article will guide through some of the issues I’ve experienced.

Install NeoVim

To get started the first thing we need to do is actually install NeoVim, version 0.6.0 at time of writing. This can be completed with the command below in your Windows Terminal:

choco install neovim

This requires and application called Chocolatey to also be installed, instructions for that can be found here.

Once you have installed NeoVim you will be able to launch the application, you can do this in a couple of ways.

Open Start > Type “NVim” and entre.

In your Windows Terminal type “NVim“, it will open your NeoVim session whilst in the terminal.

As a side note, to close the session type “:q” and entre, if you’ve made an insert then either “:q!” to close without saving or “:wq

Plugin Manager

So now you’ve installed NeoVim and you’re able to launch it. But it’s looks a little blank and you’ve seen people with loads of features and functionality. This is where plugins come in handy, NeoVim is quite extensible. Lets run through the method which has worked for myself to setup plugins, as I did also come across a few issues and mis-documented “solutions”.

First getting a plugin manager the one I have found and used which seems to come as the top result when you search google is the vim-plug manager. Installing this is straight forward you use the following command from a PowerShell terminal session:

iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
    ni "$(@($env:XDG_DATA_HOME, $env:LOCALAPPDATA)[$null -eq $env:XDG_DATA_HOME])/nvim-data/site/autoload/plug.vim" -Force

This will install a file called plug.vim in your App Local folder %LOCALAPPDATA%\nvim-data\site\autoload.

Setup init.vim

Next we need to setup the init file which will be used to direct which plugins we want to use. This file was where I had the greatest amount of issues, seeing log file locations requiring to be placed in the wrong location. The other issue is that the folder which is required for this setup didn’t actually exist on initial setup for myself so I had to manually create the folder.

The init file is should be located in the following folder: %LOCALAPPDATA%\nvim\init.vim. If you don’t see a nvim folder in your AppData\Local folder then you will need to create one and then your init.vim file within there. The file initially will be blank and you might need to set it up manually, but it will be where you’re going to edit the config of your NeoVim settings.

To setup the Plugins for the manager to deal with the required plugins, first, open the init.vim file in your favourite editor, this is easier to do it from NeoVim based on the steps that follow.

nvim C:\Users\[username]\AppData\Local\nvim\init.vim

Here is an example of my init.vim file

:set number
:set autoindent
:set tabstop=4
:set smarttab
:set mouse=a

call plug#begin('~\AppData\Local\nvim-data\site\autoload')

Plug 'https://github.com/dracula/vim'

call plug#end()

:colorscheme Dracula

Some important parts to note, the parts that you want to ‘Plug‘ need to be inside the call Plug#begin() and call Plug#end().

The path I have within the Plug#begin ‘~\AppData\Local\nvim-data\site\autoload’ is where the Plugins are going to be downloaded to, you can set this path to whereever you would like.

Install Plugin

In our example I am getting the Plugin for Dracula theme for Vim. If we’re after a Plugin we can just type Plug and the URL of the version we want to download as I am after the master branch I can just put the main Dracula vim URL. There are other things you can put here and it will still fetch the plugin without issues. Check the installation documentation of any plugin you’re after and it will always explain it there.

As we’re editing in NeoVim we can then save the file esc > “:w“. Next reload the source “:source %” With the file still open we’re going to prompt for the install. Type the following command, it is as with each command case sensitive “:PlugInstall“. It will split the terminal pane, and on the left pane it will show you the plugins which are being installed.

After the plugins have been installed you can reload NeoVim and it should load the with changes, in the example above to installed the Plugin for Dracula theme and then set the theme “:colorscheme Dracula” so when NeoVim is started it will start with that theme.

Remove Plugin

So you’ve installed a plugin which you no longer require how do you go about removing the plugin, as you might expect you remove the Plug line from your init.vim file of the plugin you want to remove.

Be advised if you remove a plugin and you configure it elsewhere in you init.vim file you will need to remove that configuration as well.

Next we need to run the following config :PlugClean this will remove any lingering files which are no longer required.

Tips

As I am working in the Windows Terminal typing nvim every time I want to use the application is a bit too much so below are a couple of steps I took to make using the application a little faster and more manageable in the long run. I have made the following changes to my PowerShell $profile (edit by “nvim $profile“).

Launch NeoVim quickly

Set-Alias n NeoVim

Quick edit init

I have a feeling I will be in and out the init file a lot, to make the process a lot easier to manage I added the following script to make access a lot easier.

function Edit-NeoVimInit { 
		Nvim C:\Users\sbarton25\AppData\Local\nvim\init.vim 
}

Set-Alias en Edit-NeoVimInit

The good thing about the $profile is you can do a lot of customisation for Windows Terminal which in turn can make management of NeoVim a lot easier as well.

I have a lot more to learn about using NeoVim as an editor and aim to continue my use over VSCode to see if I prefer it. The learning curve is a lot steeper but it also seems to be quicker as an application from start-up to editing code.

Hopefully this article helps you getting NeoVim up and running on your Windows environment and you don’t fall into traps I have had in the past.

If you have a list of Plugins you use and swear by please leave a comment below with the community to share some of the tools which makes working in NeoVim your go to over other editors.

Leave a Reply

Your email address will not be published.