Lua with Neovim: Writing a Neovim Plugin — Plugin Structure, Setup Pattern & Custom Commands | Ep 32
13views
0012:15
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
The grand finale. In this episode we write a complete Neovim plugin from scratch in Lua: the standard plugin structure with
lua/pluginname/init.lua, the setup(opts) pattern, reading buffer lines with vim.api.nvim_buf_get_lines, sending notifications
with vim.notify, and exposing functionality through a :WordCount user command.
Every keystroke is shown on screen with 3-second pauses so you can follow along at your own pace.
Student Code: https://github.com/GoCelesteAI/learn-lua-in-neovim/tree/main/episode32
What You'll Learn:
- Plugin structure — lua/pluginname/init.lua convention
- setup(opts) — the standard plugin configuration pattern
- vim.api.nvim_buf_get_lines — reading lines from the current buffer
- vim.notify — displaying messages to the user
- Creating a :WordCount command — tying it all together
- How Neovim discovers and loads Lua plugins
Timestamps:
0:00 Intro
0:12 Preview
0:44 Plugin File & Module Table
1:58 count_words() — Buffer Line Counter
4:18 count_words_line() — Current Line Counter
6:12 setup(opts) — Entry Point & Commands
8:48 return M — Complete the Module
9:01 Test File & Load Plugin
10:09 Test :WordCount & :WordCountLine
10:51 Review Plugin
11:28 Recap
11:44 Endscreen
Key Takeaways:
1. Neovim plugins live in lua/pluginname/init.lua
2. setup(opts) is the standard entry point for configuration
3. nvim_buf_get_lines reads buffer contents as a Lua table
4. vim.notify shows user-facing messages in Neovim
5. vim.api.nvim_create_user_command exposes plugin functionality
This is Episode 32, the final episode of the Learn Lua in Neovim series. From variables to a working Neovim plugin — you now
have the Lua foundation to customize Neovim however you want.
Taught by CelesteAI. Like & subscribe for more tutorials!
#lua #neovim #programming #tutorial #beginners #learnlua #luaprogramming #neovimtutorial #neovimplugin #luaplugin #coding
Tags
lua, lua tutorial, learn lua, neovim plugin, neovim plugin lua, write neovim plugin, neovim plugin structure, setup opts,
nvim_buf_get_lines, vim.notify, nvim_create_user_command, wordcount plugin, lua for beginners, neovim lua, neovim tutorial,
learn lua in neovim, lua episode 32, programming tutorial, coding tutorial, intermediate programming, lua 2026, neovim 2026,
screenkey, code along, neovim plugin development, lua plugin
Tags
lualua tutoriallearn luaneovim pluginneovim plugin luawrite neovim pluginneovim plugin structuresetup optsnvim_buf_get_linesvim.notifynvim_create_user_commandwordcount pluginlua for beginnersneovim luaneovim tutorial