Packaging a Plugin
Structure and share it.
Plugin Directory Layout
A Neovim plugin is just a directory on the runtimepath. The conventional layout has top-level folders that Neovim treats specially.
Key directories: lua/ for modules, plugin/ for auto-loaded setup, ftplugin/ for filetype scripts, doc/ for help, and after/ for late overrides.
-- myplugin/
-- lua/myplugin/init.lua
-- plugin/myplugin.lua
-- doc/myplugin.txtThe lua/ Directory
Files under lua/ are reachable with require. A module at lua/myplugin/init.lua loads as require('myplugin').
Nesting maps to dotted paths: lua/myplugin/config.lua becomes require('myplugin.config'). This is how plugins expose a clean public namespace.
-- in lua/myplugin/init.lua
local M = {}
function M.hello() print('hi') end
return MAll lessons in this course
- The Neovim Lua API
- Commands and Keymaps
- Buffers and Windows
- Packaging a Plugin