Ignore that egregious startup time…

Neovim, but it’s in Windows

Kevin Feng
Nerd For Tech

--

Just a few days ago, I told myself that I’d probably never write an article about Neovim again… Well, here I am.

Déjà vu?

However, unlike my previous post, I’ll be sure to keep this one under 10 minutes of read time. And this time, we’ll be talking about setting up Neovim for Windows.

Hey, I used to have one of these in my 3rd grade classroom!

Surprisingly easy

I used to believe that setting up Neovim for my native Windows environment would be quite arduous and inconsistent compared to Linux. But after cloning my Neovim set up that was configured in Ubuntu in just a few minutes, I was elated to find that the entire process was quite straightforward.

So yes, a lot of the time saved here is due to already having a set of configuration files ready, but that also goes to show that configuring Neovim from scratch on Windows is more or less the same process as doing it on Linux, which I’ve gone over in this article:

I’d strongly recommend looking up some resources (including the article linked above) if you’ve never worked with Vim-based editors before. After all, aside from doing some house cleaning, all we’re doing here is cloning an already-existing Neovim config. But if you enjoy fully-fledged code editors (as most people do), then more power to you.

Installing Chocolatey

Unlike Linux and similar to macOS, Windows doesn’t have a built-in package manager (don’t talk to me about winget). While Ubuntu users have apt by default, Arch users prefer pacman and macOS users often opt for brew, choco (or Chocolatey) is the package manager for Windows.

We’ll be using Chocolatey to install Neovim, so let’s start by getting that:

  1. Open an elevated instance of Command Prompt or PowerShell (right-click -> Run as Administrator)
  2. Run Get-ExecutionPolicy — if it returns Restricted, then run either Set-ExecutionPolicy AllSigned or Set-ExecutionPolicy Bypass -Scope Process
  3. Run the following:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

And now Chocolatey should be installed! Run choco and you should see output that looks like this:

Installing Neovim and adding it to PATH

Now that we have Chocolatey, we can use it to install Neovim with choco install neovim. Once Chocolatey finishes installing Neovim, it might not work right away (ie. Runningnvim throws the error showing that it’s not a recognized command). In that case, we’ll have to add Neovim to our PATH environment variable.

You can do this by hitting the Windows key, and finding the option “Edit the system environment variables.”

Once on this screen, select “Environment Variables…” which will open another window.

Select the PATH environment variable and then select the “Edit…” button underneath it.

Here, select “New” and add the path of where Neovim was installed. For me, it was C:\tools\neovim\nvim-win64\bin, but I’ve seen some slightly different paths, so make sure to confirm your own.

Needless to say, nvim still won’t work in terminals that are already open. Instead of opening another terminal, you can just run this command from Chocolatey which refreshes environment variables: RefreshEnv.cmd. And now the nvim command should result in Neovim opening!

Cloning

Now it’s time to clone a Neovim config, and the proper path to do so can be found by performing Win + R (Windows Run), typing in %appdata% and hitting ENTER. Navigate one directory back from Roaming and then go into Local.

In Local, Neovim will look for a folder called nvim, so all we have to do now is open a terminal at the current directory, clone your repository of choice, and then rename that cloned folder to nvim, if it wasn’t already named as such.

If you want my config, run this:

git clone https://github.com/kevinfengcs88/neovim-config

Which will create a folder called neovim-config. Just change that folder to nvim, and the next time you open Neovim, everything should load up properly.

Is that supposed to be a hydra?

But there’s just one small problem… Where are all of our awesome icons? Without a Nerd Font, we won’t be able to render all the amazing glyphs and symbols that make Neovim look so clean. The file tree explorer looks particularly odious…

🤮

Installing Windows Terminal

Source

Before we even install a Nerd Font, we’ll need a terminal that is compatible with Nerd Fonts, and unfortunately Command Prompt and PowerShell are not only ugly (sorry) but do not accept Nerd Fonts.

Windows Terminal is a multi-tabbed terminal emulator which can run PowerShell, Command Prompt, or even Azure Cloud Shell inside of it. More importantly, it supports Nerd Fonts. If you have access to the Microsoft Store, then you can simply install it from there using the GUI. Unfortunately, my desktop has some problems with the Microsoft Store, so I had to do a little bit of research.

Navigate to the GitHub releases of Windows Terminal and hunt for the “Latest” release.

Scroll down to the “Assets” section and download the file that ends in .msixbundle. Now with this file downloaded, there are a few different ways of actually installing Windows Terminal.

One way is to simply run the .msixbundle file, which should allow you to install Window Terminal through a GUI:

I already have it installed of course :3

The other way is to use a PowerShell command (while in your Downloads directory of course):

Add-AppxPackage [name]

Substitute [name] for the full name of the .msixbundle file that you downloaded.

After you’ve installed Windows Terminal, you should find it in the “Recently added” section when opening your Windows start menu. I’d recommend pinning it to your Start Menu to make it easier to find.

Installing a Nerd Font

Now that we have Windows Terminal, let’s install a Nerd Font. Once again, there are a few ways of doing this, one of which involves visiting nerdfonts.com, and the other involving its respective GitHub repository. I’ve gone over the latter in this section of one of my previous articles, so I’ll install from the Nerd Fonts website this time around.

Go to the “Downloads” page of the Nerd Fonts website, and you’ll be met with a bunch of fonts:

Look for your favorite font and then download it. Navigate to the ZIP file of the font that you just downloaded and then hunt for the “regular” variant of the font:

Open that file and then install the font to Windows.

To confirm that the font installed, you can go to “Font settings” in Windows and search for it.

Wrapping it up

Finally, with a terminal that supports Nerd Fonts and a Nerd Font installed, we can view Neovim in all of its unadulterated glory with just a few more steps.

Open Windows Terminal and right-click anywere along the window’s header:

Click on “Settings” and then switch to the “Defaults” tab on the sidebar:

Scroll down to “Appearance”:

And finally change the “Font face” option:

And we’re finally done!

Some of the icons don’t seem to be supported by Windows Terminal :(

Conclusion

Setting up Neovim for Windows is a pretty seamless experience, coming from someone who only experience Neovim in a Linux environment. Pretty much everything is the same — there’s just a slightly different path to store the config files in.

Neovim on Windows is also about three times as slow on startup compared to my Linux environment, and on a “cold” start (when resources aren’t allocated for Neovim since it hasn’t been opened in a few hours), it’s actually more than 10x as slow.

My cold starts on Linux are about 200 or 250 ms, while normal starts are either 100 ms or just under. On Windows, however, a normal start hovers around 280 ms and a cold start takes an extraordinarily languid 2000+ ms (yes, over 2 whole seconds). This is definitely something I’ll have to look into and optimize, since I’ll be using Neovim whenever I have work to do on Windows now.

Thanks for reading! Until next time, friends :)

--

--