0Pricing
Lua Academy · Lesson

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.txt

The 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 M

All lessons in this course

  1. The Neovim Lua API
  2. Commands and Keymaps
  3. Buffers and Windows
  4. Packaging a Plugin
← Back to Lua Academy