A beginner guide on writing Neovim plugins in Lua.
Overview
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.
Help
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.
Lua Language Server — sumneko_lua
Set up Lua language server following the instructions here.
luadev.nvim
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.nvim
to 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…