Setup Neovim with vim-plug on Windows 11
I love to use vim everywhere. Almost all the linux distros and macOS come with Vim pre-installed, but what about Windows? You can stick to the vim within the Windows Git Bash(you should know git because that's what makes you a developer :D) with a Linux-like configuration, but you may notice that :w
command lags for some reason.
So why not use Neovim(nvim) on Windows? Let's get to it!
Open powershell and run the command below to install Neovim on your system. Different ways of installation can be found in the source repository.
1winget install Neovim.Neovim
Now close the powershell and reopen it. You should be able to use nvim
command and see the nvim startup screen.
It's time to configure your awesome nvim.
vim-plug is one of the most popular Vim plugin managers out there and I love it.
Install vim-plug using the following commands in your powershell:
1iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
2 ni "$(@($env:XDG_DATA_HOME, $env:LOCALAPPDATA)[$null -eq $env:XDG_DATA_HOME])/nvim-data/site/autoload/plug.vim" -Force
Inside %USERPROFILE%\AppData\Local
directory(for example, "C:\Users\crazyoptimist\AppData\Local"), make a new directory named nvim
, and create a new file init.nvim
there.
1mkdir nvim
2cd nvim
3nvim init.vim
Put your vimrc contents in it. I have my dotfiles on github, you may have one as well. :D
Restart nvim(just quit and reopen nvim), and install the plugins listed in your init.vim
by running :PlugInstall
command.
Want to edit files by double click using nvim? You can find nvim-qt.exe
in your Program Files\Neovim\bin
directory, which you can select in the "Open With" menu. Then create a new file ginit.vim
with following content:
1" Enable Mouse
2set mouse=a
3
4" Set Editor Font
5if exists(':GuiFont')
6 " Use GuiFont! to ignore font errors
7 " Below line assumes you installed the font "Hack Nerd Font Mono"
8 GuiFont Hack\ Nerd\ Font\ Mono:h14
9endif
10
11" Disable GUI Tabline
12if exists(':GuiTabline')
13 GuiTabline 0
14endif
15
16" Disable GUI Popupmenu
17if exists(':GuiPopupmenu')
18 GuiPopupmenu 0
19endif
20
21" Enable GUI ScrollBar
22if exists(':GuiScrollBar')
23 GuiScrollBar 1
24endif
25
26" Right Click Context Menu (Copy-Cut-Paste)
27nnoremap <silent><RightMouse> :call GuiShowContextMenu()<CR>
28inoremap <silent><RightMouse> <Esc>:call GuiShowContextMenu()<CR>
29xnoremap <silent><RightMouse> :call GuiShowContextMenu()<CR>gv
30snoremap <silent><RightMouse> <C-G>:call GuiShowContextMenu()<CR>gv
You can now use nvim on Windows. Very awesome! :XD
Happy coding!