Writing Neovim Plugins — A Beginner Guide (Part 2)

5 min readMay 31, 2021

A beginner guide on writing Neovim plugins in Lua.

Writing Neovim Plugins


In Part 1 of the article, I developed a very simple Neovim plugin. In this article let’s explore Neovim Lua's libraries and use them to enhance the plugin.

Development Setup

Let’s get started by setting up a proper plugin development environment.


Type :nvim_ followed tab and you should be able to see the Neovim built-in Lua APIs. However, navigating the help documentation is a bit cumbersome so let’s set up LSP.

Telescope. nvim

If you install telescope.nvim, type :Telescope help_tags and you can easily search for the Neovim APIs that you need.

telescope.nvim Help

Lua Language Server — sumneko_lua

Set up Lua language server following the instructions here.


For this tutorial, I am going to use luadev.nvim.luadev.nvim enables development setup for init.lua and plugin development with full signature help, documentation, and completion for the Neovim Lua APIs.


I am using packer.nvimto install the plugin.

use {'folke/lua-dev.nvim'}

Run :luafile % and :PackerInstall to install the plugin, and use the configuration below to set up the plugin.

You can refer to this file for the full listing of the code. Note that I also set up LSP for Vimscript.

With the plugin setup, we should be able to get proper LSP support for using Neovim…


Software engineer, Data Science and ML practitioner.