Member-only story
A beginner guide on writing Neovim plugins in Lua.
Overview
There are many great Neovim plugins but not many guides on writing Neovim plugins in Lua. In this article, let’s start to explore developing Neovim plugins in Lua.
This is a beginner guide and we are going to learn by developing a simple plugin, and continue to explore more advanced topics in future articles.
- Part 1: This article.
- Part 2: Available here.
Table of Contents
- Startup Options
- Runtimepath
- Setting Runtimepath
- Use Custom Configuration File
- Setting up LSP (Optional)
- Plugin DIrectories Structure
- Hello World Plugin
- Define Plugin Command
- Documentation
- Publishing Plugin
- Installation and Testing
- Further Readings
- Summary
- References
Startup Options
Let’s first explore different methods to start Neovim without loading vimrc
files or plugins.
There are different ways that you can start Neovim without initialization.
nvim -u NONE
: Start Neovim without loadingvimrc
files and pluginsnvim -u NORC
: Start Neovim without loadingvimrc
files, but still load the plugins.nvim --noplugin
: Start Neovim, loadvimrc
files but not the plugins.nvim --clean
: Equivalent to “-u NONE -i NONE
”. Skips initializations from files and environment variables. No ‘shada
’ file is read or written. Excludes user directories from ‘runtimepath
’.
To show you the default runtimepath
, I am going to use the--clean
option to start Neovim with a clean environment. Type ":h --clean
” to check out the documentation.
$ nvim --clean
Runtimepath
Type :h rtp
to check out the documentation for runtimepath
.