In this post, I will go through how to customize neovim. If you are new to Vim, I suggest you go through this post to get familiarize with Vim first.
Installation
Operating System | Install command |
---|---|
MacOS | brew install neovim |
Debian based OS | apt install neovim |
Redhat based OS | yum install neovim |
Windows OS | choco install neovim |
Default Commands
Neovim is forked out of Vim; all key bindings of Vim should work. Refer Vim default key bindings
Configuration
Neovim supports configuration using Lua. (You can still use init.vim
).
Here I will be discussing how to configure using Lua.
The configuration file is located at $HOME/.config/nvim. Create init.lua
in $HOME/.config/nvim
Set options using Vimscript
You can directly write vim script like below
Set options using Lua
Below is how you can set options in Lua.
Set global options using Lua
Below is how you can set global settings
Custom bindings in lua
You can set key bindings like below
You can use helper functions like below.
Create ~/.config/nvim/lua/globals.lua
and add below content
Create ~/.config/nvim/lua/utils.lua
and add below content
Now in your ~/.config/nvim/init.lua
you can do like below to do custom bindings.
Plugin Manager
You can either use Vim Plug or Packer. I will show you on how to use packer plugin manager. Install packer plugin manager.
Create ~/.config/nvim/lua/plugins
folder and create init.lua
file.
Have below content
At line number 12, you will be adding the plugins you want to install.
For example, you want to install a gruvbox theme, then you will add use 'morhetz/gruvbox'
Then you can do :PackerCompile
, :PackerInstall
to install the plugin.
Interesting Plugins
Most plugins available in Vim should work with Neovim, but there are some plugins in Neovim, which is done in Lua, does not support Vim. I discussed most vim plugins in Steps to customize Vim. Below are some interesting plugins.
Language Server Protocol
Neovim out of the box supports LSP (Language Server Protocol) refer nvim-lspconfig
Below are some plugins that help in code completion & LSP.
- williamboman/nvim-lsp-installer - Companion plugin for nvim-lspconfig that allows you to seamlessly install LSP servers locally.
- onsails/lspkind-nvim - This tiny plugin adds vscode-like pictograms to neovim built-in lsp
- hrsh7th/nvim-cmp - Gives all the auto completion needed in neovim.
- glepnir/lspsaga - Gives options on fixing issues found in code (similar to vscode)

Navigating files
- nvim-tree - Gives tree view of folders in left sidebar.
- telescope - Gives fuzzy search with previews (similar to fzf plugins)

Status Line
In vim, there is vim-airline but requires more configuration in vimrc. lualine is a blazing fast and easy to configure Neovim statusline written in Lua.
Startup Dashboard
startify gives a welcome dashboard with the most recently used files. You can also customize to add bookmarks.

Note: This plugin supports Vim too.
Git
gitsigns gives options to move around git hunks ]c
& [c
to move
between hunks, this plugin also provides hunk preview like below.

Syntax Highlights
nvim-treesitter provides a simple interface for tree-sitter in Neovim and provides highlighting based on it.
This plugin can be configured like below.
Which key
vim-which-key is similar to emacs which-key, when you press a key, it will show next available keys; this is useful as there are many key bindings.
You can use below config, to trigger which key to expand on next available keys.

Note: This plugin supports Vim too.
Firenvim
You can use neovim inside Chrome and firefox using Firenvim. You can configure like below in your in init.lua file.
Note: If firenvim is not loading in text area, you can use Cmd+e in MacOS, in Windows/Linux you can use Ctrl+e

Conclusion
Above are some ways to customize neovim. If you want a complete configuration file of the above examples, refer here. Happy Vimming. – RC
Comments