Make Neovim your ultimate code editor

siraphobk

Siraphob Kan

Posted on December 21, 2021

Make Neovim your ultimate code editor

TLDR; My dot-file can be downloaded from this link.

Prologue

Vim was invented around 30 years ago (1991). It is a text editor that runs in a terminal. Programmers at the time use Vim to write their code.

In mordern days, even with new text editor like VSCode, intellij, sublime text, etc; Vim still stand tall among them. This is because Vim has some advantages over those text editors.

  • Vim is extremely lightweight.
    Vim itself is very small and it's likely shipped with most Linux distros. The only dependency it needs is a terminal.

  • People who use Vim could edit their code faster.
    Vim enables full keyboard control. You can navigate, edit, delete, replace, etc. using only your keyboard. You'll seldomly need to touch your mouse when writing code ever again.

  • Vim is highly customizable.
    You can configure Vim to work in your way. Keybindings are not intuitively enough? You can remap it! Want to add Git integration? You can do that too! Add code-completiong and linting for your programming language? I don't need to say that it's achievable too.

Why Neovim?

You may wonder why I was talking about Vim when the title said Neovim. Well, here I am. In this article I'm going to explain why we'll use Neovim instead of Vim.

What is Neovim?

Neovim is a forked version of Vim. It's basically Vim but driven by an open-source community. On the other hand, Vim is maintained by only one person which is its original author, Bram Moolenaar.

Why should you use Neovim instead of Vim?

As I said, Neovim is maintained by the community. And because of that, the tends software evolves faster and more compatible with the modern system. And by that term, I am talking about integration with other third-parties and bug fixes.

Moreover, Neovim's software architecture was redesigned to be more extensible and could process task in multi-thread fashion.

With all that; the traits of its predecessor, blazingly fast software, and powerful plugins; is the reason I recommend you to use Neovim over regular Vim.

Installing Neovim

If you're on Debain-based system, you could run the following command.

sudo apt-get install neovim
Enter fullscreen mode Exit fullscreen mode

For other distributions/system, please refer to this wiki page.

After the installation completed, you could start Neovim by just typing neovim in your terminal.

Configuring Neovim

Before any processes of Vim begins, Vim will read its configuration file first.
So does Neovim. Neovim's configuration file is located at $HOME/.config/nvim/init.vim. If your system doesn't have this directory, you could create one.

The init.vim file allows you to specify how Neovim should behave. The look
and feel, keybindings, and plugins are all configured through this file.

Installing plugins using Vim-Plug

A way to install plugins in Neovim is through a plugin manager. There exists many plugin managers for you to choose. Here is some examples; Vim-Plug, Pathogen, Vundle, etc. In this article, I'm going to use Vim-Plug since it's very easy to use and setup.

To install Vim-Plug for Neovim, please run the following command.

sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
       https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
Enter fullscreen mode Exit fullscreen mode

Neovim configuration file

After the installation completed, open init.vim and add the following snippet.

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

" This is where you define your plugins.

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

The snippet above make Vim-Plug scans for the defined plugins. Any defined plugins that don't exist in nvim/plugged directory will be download and install. To trigger the Vim-Plug installation, reload Neovim and type :PlugInstall.

Protips: If you're editing init.vim, save the file by running :w and then :source % to source the current file. After that you can call PlugInstall without needing to reload the Neovim process again.

Finding plugins

You can find any plugins for Vim on Vimawesome. When you select a plugin on Vimawesome, it'll show installation instruction for
any plugin manager.

For example, please see Fugitive.

Fugitive Vim-Awesome

Useful plugins I recommend.

I am going to list all the plugins I use and explain what they do in my Neovim configuration. The list is shown below.

  1. NERDTree - File browsing
    Plug 'scrooloose/nerdtree'

  2. NERDTree Git Plugin - Git integration for NERDTree
    Plug 'Xuyuanp/nerdtree-git-plugin'

  3. Vim Devicons - Extend Vim to use beatiful icons
    Plug 'ryanoasis/vim-devicons'

  4. Syntastic - Syntax Checking
    Plug 'scrooloose/syntastic'

  5. Gitgutter - Show git diff in a file
    Plug 'airblade/vim-gitgutter'

  6. NERDCommenter - Add comment keybindings support
    Plug 'scrooloose/nerdcommenter'

  7. Vim Surround - Brackets wrapping
    Plug 'tpope/vim-surround'

  8. CTRL-P - File search
    Plug 'ctrlpvim/ctrlp.vim'

  9. Vim-Go - Go programming language support for Vim
    Plug 'fatih/vim-go'

  10. COC(Conquer Of Completion) - Syntax completion support
    Plug 'neoclide/coc.nvim', {'branch': 'release'}

  11. Colorschemes - Customize Vim colorscheme
    Plug 'flazz/vim-colorschemes'

  12. Vim-Javascript - Javascript support
    Plug 'pangloss/vim-javascript'

  13. Vim-Graphql - Graphql Sytax highlighting
    Plug 'jparise/vim-graphql'

  14. Indentline - Show indentation guide in Vim
    Plug 'yggdroot/indentline'

  15. FZF - FuzzyFinder support for Vim
    Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
    Plug 'junegunn/fzf.vim'

  16. Fugitive - Git integration
    Plug 'tpope/vim-fugitive'

  17. Vim-Airline - Vim status bar customization
    Plug 'vim-airline/vim-airline'

  18. Undotree - Undo history
    Plug 'mbbill/undotree'

My dot-file

For anyone who's looking for my dot-file. You can download it from this link.

Closing thoughts

In my opinion Neovim is not the thing that every developers should adopt. It is also not something that would instantly replace your current text editor. Honestly, I think the best text editor is not the fastest one or the one with the most plugins. The best text editor is the one that suits your workflow the most.

Neovim is one of those text editor that fits my workflow. It is fast, lightweight, and highly customizable. It is a little bit harder to learn at first because of its steep learning curve. But I assure you that it is worth learning and it will pay off a great prize!

💖 💪 🙅 🚩
siraphobk
Siraphob Kan

Posted on December 21, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related