-
Notifications
You must be signed in to change notification settings - Fork 3
Using This Template
To use this template to write a Neovim plugin, in short, you clone this template, remove what you don't want, set the GitHub repository settings to enable what you do want, and then you're ready to extend the template for your needs.
Press
(Or use gh repo create nvim-best-practices-plugin-template -p ColinKennedy/nvim-best-practices-plugin-template
)
In general that means
- Make sure the
plugin/
directory implements the command(s) and mappings that you need - Remove plugin integrations if you don't want them:
If you don't want a lualine.nvim status bar, run this:
git rm -rf lua/lualine
git rm spec/plugin_template/configuration_tools_lualine_spec.lua
git rm spec/plugin_template/lualine_spec.lua
If you don't want telescope.nvim commands, run this:
git rm -rf lua/telescope
git rm spec/plugin_template/configuration_tools_telescope_spec.lua
git rm spec/plugin_template/telescope_spec.lua
Renovate is a useful GitHub opt-in feature for bumping your dependencies. It requires some extra setup (see Managing Dependencies ‐ Using Renovate). If you don't want it at all though, run this:
git rm renovate.json
This plugin comes with example commands that you probably won't want, make sure to remove them.
git rm -rf lua/plugin_template/_commands
The nvim-best-practices-plugin-template repository has its own CHANGELOG.md
that are useful for communicating changes but you won't actually want. in your new repository. Remove it with the command below:
git rm CHANGELOG.md
Some features require API keys for third-party services or repository write permission. For example:
- For auto-releases to LuaRocks, see Releases
- For documentation auto-generation, see Documentation
There are several files that are named after this plugin and file contents that you'll want to change. The scripts can automate the process:
# Rename all files
git mv lua/plugin_template lua/your_plugin
git mv lua/telescope/_extensions/plugin_template lua/telescope/_extensions/your_plugin
git mv spec/plugin_template spec/your_plugin
find $PWD -type f | grep -v .git/ | grep -v .dependencies/ | xargs -I{} sh -c "rename --filename 's/nvim-best-practices-plugin-template/your-plugin.nvim/g ; s/plugin-template/your-plugin/ ; s/PluginTemplate/YourPlugin/ ; s/plugin_template/your_plugin/ ; s/ColinKennedy/YourUsername/' {}"
# Rename all file contents
find . -type f | grep -v .git/ | grep -v .dependencies/ | xargs sed -i 's/nvim-best-practices-plugin-template/your-plugin.nvim/g ; s/plugin-template/your-plugin/ ; s/PluginTemplate/YourPlugin/ ; s/plugin_template/your_plugin/ ; s/ColinKennedy/YourUsername/'
We've left a number of TODO notes labeled TODO: (you)
that you'll want to address.
The command below will auto-find all of these TODO notes and show them in Neovim's quickfix so you can quickly cycle through them all.
grep --recursive --line-number --word-regexp 'TODO: (you)' | nvim -q - -c "copen"
At this point, you've completely made this template your own plugin. Congratulations! Now go forth and add new Vim commands, mappings, configuration, unittests, or whatever else you'd like to create.
To enable automatic uploads to GitHub, you must:
-
Go to your repository's Settings page
-
Go to
Security
->Secrets and variables
->Actions
- Press the
New repository secret
button. Call itPERSONAL_ACCESS_TOKEN
(in the screenshot below this has already been done)
To complete this last step, you need a Personal Access Token to paste into here
- Go to https://github.com/settings/profile
- Go all the way to the bottom of the left side bar where it says
Developer settings
- Go to the left sidebar where it says
Personal access tokens
->Tokens (classic
- Press
Generate new token [menu]
->Generate new token (classic)
- Add "repo" scopes
- Press
Generate token
at the bottom and then copy the created token string. Paste it into your repository's personal access token secrets.
And you're done
To enable automatic uploads to LuaRocks, you must:
- Create a LuaRocks API key
- Add the secret API key to your GitHub actions (see below)
- Add a new git tag and push the tag to the default (main) branch.
Example:
git checkout main
git tag -a v1.2.3 -m "Added an important bug fix"
git push --tags
release.yml will then make a release for you.
This template can auto-generate its own documentation and Vimtags. This is controlled by the documentation.yml file.
For this feature to work, the GitHub workflow must have write access to the repository. To enable it:
- Click the Settings tab
- (Under the "Code and automation" section) Press "Actions" > "General"
- (In the new page) (Under "Workflow permissions") Press "Read and write permissions"
You can also disable this feature by removing documentation.yml.