DEV Community

Cover image for NeoVim Installation and Configuration on Win10/11
Bek Brace
Bek Brace

Posted on • Updated on

NeoVim Installation and Configuration on Win10/11

Hi 👋
Today I want to share with you how I installed and configured NeoVim on Windows 11 [same goes for Win10].

First of all, you will need to install NeoVim.
The easisiest way to do it on Windows 10 is through winget :

winget install Neovim.Neovim
Enter fullscreen mode Exit fullscreen mode

For more info : https://github.com/neovim/neovim/wiki/Installing-Neovim

Once this is done, you can type nvim [and not neovim].
Now we need to configure the editor.

It's not that difficult to configure Neovim, just you will have to navigate to => Users folder => username's folder => you will have to show hidden files => AppData => Local folder, enter it and there you will find a lot of folders,
but only two concern NeoVim, find folders :
1) nvim
2) nvim-data
Go ahead and open vim folder and there create init.vim file.
Then copy paste the below settings in that file :

:set number
:set autoindent
:set tabstop=5
:set shiftwidth=4
:set smarttab
:set softtabstop=4
:set mouse=a

call plug#begin()

Plug 'http://github.com/tpope/vim-surround' " Surrounding ysw)
Plug 'https://github.com/preservim/nerdtree' " NerdTree
Plug 'https://github.com/tpope/vim-commentary' " For Commenting gcc & gc
Plug 'https://github.com/vim-airline/vim-airline' " Status bar
Plug 'https://github.com/lifepillar/pgsql.vim' " PSQL Pluging needs :SQLSetType pgsql.vim
Plug 'https://github.com/ap/vim-css-color' " CSS Color Preview
Plug 'https://github.com/rafi/awesome-vim-colorschemes' " Retro Scheme
Plug 'https://github.com/neoclide/coc.nvim'  " Auto Completion
Plug 'https://github.com/ryanoasis/vim-devicons' " Developer Icons
Plug 'https://github.com/tc50cal/vim-terminal' " Vim Terminal
Plug 'https://github.com/preservim/tagbar' " Tagbar for code navigation
Plug 'https://github.com/terryma/vim-multiple-cursors' " CTRL + N for multiple cursors
Plug 'https://github.com/rstacruz/vim-closer' " For brackets autocompletion


" Auto-completion  For Javascript, typescript, html, jsx ...etc
Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'} " this is for auto complete, prettier and tslinting

let g:coc_global_extensions = ['coc-tslint-plugin', 'coc-tsserver', 'coc-css', 'coc-html', 'coc-json', 'coc-prettier']  " list of CoC extensions needed

Plug 'jiangmiao/auto-pairs' "this will auto close ( [ {

" these two plugins will add highlighting and indenting to JSX and TSX files.
Plug 'yuezk/vim-js'
Plug 'HerringtonDarkholme/yats.vim'
Plug 'maxmellon/vim-jsx-pretty'

set encoding=UTF-8

call plug#end()

nnoremap <C-f> :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-l> :call CocActionAsync('jumpDefinition')<CR>

nmap <F8> :TagbarToggle<CR>

:set completeopt-=preview " For No Previews

:colorscheme jellybeans

let g:NERDTreeDirArrowExpandable="+"
let g:NERDTreeDirArrowCollapsible="~"

" --- Just Some Notes ---
" :PlugClean :PlugInstall :UpdateRemotePlugins
"
" :CocInstall coc-python
" :CocInstall coc-clangd
" :CocInstall coc-snippets
" :CocCommand snippets.edit... FOR EACH FILE TYPE

" air-line
let g:airline_powerline_fonts = 1

if !exists('g:airline_symbols')
    let g:airline_symbols = {}
endif

" airline symbols
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''

inoremap <expr> <Tab> pumvisible() ? coc#_select_confirm() : "<Tab>"
Enter fullscreen mode Exit fullscreen mode

Save the file,

:wq 
Enter fullscreen mode Exit fullscreen mode

then exit.

Now you have to install your Plugins for your NeoVim, and the plugins are code written by other developers that we can use for different reasons, like the VSCode extensions and plugins; and they should be between :

call plug#begin() 

" Any plugin you want from GitHub [autocompleting, color schemes, nerdtree, etc..]

call plug#end()
Enter fullscreen mode Exit fullscreen mode

Not only writing them will make it activated, so inside your nvim editor, type =>

: PlugInstall 
Enter fullscreen mode Exit fullscreen mode

It won't work, I know 😂 To make it work, you will have to go to your terminal, copy and paste the following command :

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
Enter fullscreen mode Exit fullscreen mode

Remember, this is only will work for Windows 10 in your powershell [ for more info, check out this github link : https://github.com/junegunn/vim-plug ]
You will find the CURL command to install on UNIX/LINUX.

Great! now, get back to nvim init.vim , and run: PlugInstall.
You will find a left window is opened and the installation of the plugins are running.

And you will be good to go for everything, except for autocompletion, you will find difficulties.
Now, for autocompletion, there is a plugin for each language [ I mainly work with python and node + html, css ,js ]
You have already copied the plugin for autocompletion coc-vim, but it's not activated yet.
So, you will want to go to the other directory nvim-data , inside it open Plugged folder, then enter coc.nvim folder, and here you will have to run Yarn.
For Linux users:
Go to :
/home//.local/share/nvim/plugged/coc.nvim

If you don't have yarn install, then install it with :

npm install --global yarn
Enter fullscreen mode Exit fullscreen mode

You will have to have Node Version >=14.14.0, otherwise it is incompatible.
Once installed, go ahead and do :

yarn install
Enter fullscreen mode Exit fullscreen mode

Again, once installed do :

yarn build
Enter fullscreen mode Exit fullscreen mode

And that is all .. hmm not really, one last thing is missing.
If you will try to open a Python file, you will find that NeoVim is trying to find an interpreter ( for autocompletion ) and cannot do it, try to type any python code and you will see what I am saying.
So get back to your terminal again and type :

pip install jedi
Enter fullscreen mode Exit fullscreen mode

Jedi is a static analysis tool for Python that is typically used in IDEs/editors plugins.
Jedi has a focus on autocompletion and goto functionality.
Other features include refactoring, code search and finding references.

Once that is installed, get back to your init.vim or any Python file to edit, and you should be absolutely fine by now :)

Hope this was helpful.
Subscribing to my YouTube channel will be very appreciated.
https://www.youtube.com/bekbrace
Best,
Bek

Latest comments (1)

Collapse
 
pawanpoudelgithub profile image
Pawan Poudel

Just created account to say thanks to you. I was not finding configuration folder. Thanks again