Neovim — init.lua

alpha2phi
8 min readFeb 7, 2021
Neovim + Lua = init.lua

Overview

Integration of Lua as a first-class language in the latest release of Neovim provides a good alternative to developers to use a more proper programming language to configure Neovim and develop plugins. Vimscript can get a bit messy to manage when the code base grows. Lua is also relatively easy to learn compared to Emacs Lisp which is used to configure Emacs.

I have been trying to configure Neovim using Lua. There are many developers who had done this, and it seems each one has very different ways of coding the configurations. This is a bit challenging for a beginner to understand.

In this article, I am going to set up a very simple solution that hopefully is easier for beginners to understand, and they can further engineer or customize the solution based on their preferences.

Check out our Neovim for Beginners series for more articles!

What to Achieve

  • Automate the installation and setup of a package manager - packer.nvim
  • Use packer.nvim to install a color scheme, fuzzy finder, and Lua language server
  • Set up sensible defaults and key mappings using Lua
  • Configure Lua language server so that I can use Neovim to learn Lua

And below is the init.lua I am going to configure. Once you have an idea of how this can be set up, you should be able to customize or refactor it to suit your needs.

Neovim Setup with Lua LSP

Learn the Basics of Lua

Lua is a relatively easy language to learn and understand. I strongly suggest you spend 30 minutes to 1 hour to go through the followings

You need some basics, e.g.

  • not equal is ~=

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.