Back to all catalogs

nvim-plugin-template

Template repository for building and releasing Neovim plugins with tests and CI.

Last synced:

Template metadata

Repository
matt-riley/nvim-plugin-template
Language
Lua
Topics
github-actions, lua, neovim, neovim-plugin, template
Last updated

README

myplugin.nvim

A Neovim plugin that does something useful.

Features

  • Feature 1
  • Feature 2

Requirements

  • Neovim 0.8+

Versioning

  • Canonical project version is stored in VERSION.
  • release-please updates both VERSION and CHANGELOG.md.

Installation

-- lazy.nvim
{ "YOUR_USERNAME/myplugin.nvim", opts = {} }

-- packer.nvim
use { "YOUR_USERNAME/myplugin.nvim", config = function() require("myplugin").setup() end }

Usage

:Myplugin

Configuration

require("myplugin").setup({
  greeting = "Hello from myplugin!",
})

Options

Option Type Default Description
greeting string "Hello from myplugin!" The greeting message

Development

Getting Started from Template

  1. Click "Use this template" on GitHub to create your repo
  2. Clone your new repo
  3. Search and replace myplugin with your plugin name:
    # Preview what will change
    grep -r "myplugin" --include="*.lua" --include="*.md" --include="Makefile" -l
    
    # Rename files
    mv lua/myplugin lua/YOUR_PLUGIN_NAME
    mv plugin/myplugin.lua plugin/YOUR_PLUGIN_NAME.lua
    
    # Replace in file contents (macOS)
    find . -type f \( -name "*.lua" -o -name "*.md" -o -name "Makefile" \) -exec sed -i '' 's/myplugin/YOUR_PLUGIN_NAME/g' {} +
    
    # Replace in file contents (Linux)
    find . -type f \( -name "*.lua" -o -name "*.md" -o -name "Makefile" \) -exec sed -i 's/myplugin/YOUR_PLUGIN_NAME/g' {} +
    
  4. Update README.md — replace YOUR_USERNAME, write your own description and features
  5. Choose your license (MIT is included by default)

Testing

Tests use mini.test. Run them with:

make test

Or manually:

MINI_PATH=/path/to/mini.nvim \
  nvim --headless -u tests/minimal_init.lua \
  -c "lua MiniTest.run({})" -c "qa"

Linting

make lint

Formatting

make format        # auto-format
make format-check  # check only (CI uses this)

Documentation (:help)

Plugin help is generated from Lua annotations in lua/myplugin/init.lua using mini.doc:

make docs

make docs injects the current value from VERSION into the generated vim help file.

License

MIT