Skip to content

Commit

Permalink
feat!: renew template (#22)
Browse files Browse the repository at this point in the history
## 📃 Summary

Hey, as I keep working on
https://github.com/shortcuts/no-neck-pain.nvim, I discover new stuff,
tools, good lua practices and some fixes here and there, so I usually
port them to this template.

Hopefully this will help someone getting started!

close #21
  • Loading branch information
shortcuts authored Sep 25, 2024
1 parent 99f94a1 commit ca72698
Show file tree
Hide file tree
Showing 16 changed files with 378 additions and 195 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @YOUR_GITHUB_USERNAME
* @shortcuts
1 change: 1 addition & 0 deletions .github/CODEOWNERS_TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @YOUR_GITHUB_USERNAME
24 changes: 0 additions & 24 deletions .github/ISSUE_TEMPLATE/Bug_report.md

This file was deleted.

58 changes: 58 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Bug Report
description: File a bug report.
title: '[bug]: '
labels: ['bug', 'triage']
body:
- type: markdown
attributes:
value: |
## Please help us help you!
Before filing your issue, ask yourself:
- Is there an issue already opened for this bug?
- Can I reproduce it?
In doubt, you can also open [a discussion](https://github.com/shortcuts/neovim-plugin-boilerplate/discussions/new/choose).
- type: textarea
attributes:
label: Description
description: A clear and concise description of what the bug is.
validations:
required: true
- type: dropdown
id: nvim-version
attributes:
label: Neovim version
description: Which Neovim version are you using?
options:
- 0.9.x
- 0.10.x
- Nightly
- <= 0.9.x
validations:
required: true
- type: textarea
attributes:
label: Steps to reproduce
description: Write down the steps to reproduce the bug, please include any information that seems relevant for us to reproduce it properly
placeholder: |
1. I enter nvim with files `...`
2. I press the following keys `...`
3. I have those plugins enabled that might conflict `...`
4. See error
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
description: Please copy and paste any relevant log output. You can set `debug = true` in your neovim-plugin-boilerplate config and then use `:message<CR>` in order to see the logs.
render: shell
- type: checkboxes
attributes:
label: Self-service
description: |
If you feel like you could contribute to this issue, please check the box below. This would tell us and other people looking for contributions that someone's working on it.
options:
- label: I'd be willing to fix this bug myself.

58 changes: 58 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_report_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Bug Report
description: File a bug report.
title: '[bug]: '
labels: ['bug', 'triage']
body:
- type: markdown
attributes:
value: |
## Please help us help you!
Before filing your issue, ask yourself:
- Is there an issue already opened for this bug?
- Can I reproduce it?
In doubt, you can also open [a discussion](https://github.com/YOUR_GITHUB_USERNAME/YOUR_REPOSITORY_NAME/discussions/new/choose).
- type: textarea
attributes:
label: Description
description: A clear and concise description of what the bug is.
validations:
required: true
- type: dropdown
id: nvim-version
attributes:
label: Neovim version
description: Which Neovim version are you using?
options:
- 0.9.x
- 0.10.x
- Nightly
- <= 0.9.x
validations:
required: true
- type: textarea
attributes:
label: Steps to reproduce
description: Write down the steps to reproduce the bug, please include any information that seems relevant for us to reproduce it properly
placeholder: |
1. I enter nvim with files `...`
2. I press the following keys `...`
3. I have those plugins enabled that might conflict `...`
4. See error
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
description: Please copy and paste any relevant log output. You can set `debug = true` in your YOUR_REPOSITORY_NAME config and then use `:message<CR>` in order to see the logs.
render: shell
- type: checkboxes
attributes:
label: Self-service
description: |
If you feel like you could contribute to this issue, please check the box below. This would tell us and other people looking for contributions that someone's working on it.
options:
- label: I'd be willing to fix this bug myself.

55 changes: 50 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: v0.9.4
version: v0.10.1

- name: generate documentation
run: make documentation-ci
Expand All @@ -47,14 +47,14 @@ jobs:
run: exit $(git status --porcelain doc | wc -l | tr -d " ")

tests:
needs:
needs:
- lint
- documentation
runs-on: ubuntu-latest
timeout-minutes: 2
timeout-minutes: 1
strategy:
matrix:
neovim_version: ['v0.7.2', 'v0.8.3', 'v0.9.5', 'v0.10.0', 'nightly']
neovim_version: ['v0.9.5', 'v0.10.1']

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -93,6 +93,51 @@ jobs:
- name: run tests
run: make test-ci

tests-nightly:
needs:
- lint
- documentation
runs-on: ubuntu-latest
timeout-minutes: 1
continue-on-error: true

steps:
- uses: actions/checkout@v4

- run: date +%F > todays-date

- name: restore cache for today's nightly.
uses: actions/cache@v4
with:
path: _neovim
key: ${{ runner.os }}-x64-${{ hashFiles('todays-date') }}

- name: restore luals cache
uses: actions/cache@v4
id: cache
with:
path: .ci/lua-ls
key: ${{ env.LUA_LS_VERSION }}

- name: setup luals
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: mkdir -p .ci/lua-ls && curl -sL "https://github.com/LuaLS/lua-language-server/releases/download/${{ env.LUA_LS_VERSION }}/lua-language-server-${{ env.LUA_LS_VERSION }}-linux-x64.tar.gz" | tar xzf - -C "${PWD}/.ci/lua-ls"

- name: setup neovim
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: nightly

- name: run luals
run: |
export PATH="${PWD}/.ci/lua-ls/bin:${PATH}"
nvim --version
make luals-ci
- name: run tests
run: make test-ci

release:
name: release
if: ${{ github.ref == 'refs/heads/main' }}
Expand All @@ -102,7 +147,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: google-github-actions/release-please-action@v3
- uses: google-github-actions/release-please-action@v4
id: release
with:
release-type: simple
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ documentation-ci: deps documentation

# performs a lint check and fixes issue if possible, following the config in `stylua.toml`.
lint:
stylua . -g '*.lua' -g '!deps/'
stylua . -g '*.lua' -g '!deps/' -g '!nightly/'
luacheck plugin/ lua/

luals-ci:
rm -rf .ci/lua-ls/log
Expand Down
40 changes: 24 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,31 @@

## ⚡️ Features

- interactive `setup` script
- README.md template
- Interactive `setup` script for an easy setup
- Perfect for open-source:
- CODEOWNERS file for PR auto-assign
- Issues and PR templates
- CD leveraging [release-please-action](https://github.com/google-github-actions/release-please-action)
- CI:
- Test running on multiple Neovim version
- Lint check
- Documentation generation check
- Minimal run time, ideal for free plans
- Docs with [mini.nvim `doc` plugin](https://github.com/echasnovski/mini.nvim/blob/main/lua/mini/doc.lua)
- Tests with [mini.nvim `test` plugin](https://github.com/echasnovski/mini.nvim/blob/main/lua/mini/test.lua)
- Versioned testing with [`bob`](https://github.com/MordechaiHadad/bob)
- Issue forms and PR templates
- README.md template
- Generated Neovim documentation with [mini.nvim `doc` plugin](https://github.com/echasnovski/mini.nvim/blob/main/lua/mini/doc.lua)
- Test runner with [mini.nvim `test` plugin](https://github.com/echasnovski/mini.nvim/blob/main/lua/mini/test.lua)
- Versioned testing with available with [`bob`](https://github.com/MordechaiHadad/bob)
- Automatic releases (CD) with [release-please-action](https://github.com/google-github-actions/release-please-action)
- Linting with [Stylua](https://github.com/JohnnyMorganz/StyLua)
- LuaLS checks on CI (inspired by [lukas-reineke/ci-template.nvim](https://github.com/lukas-reineke/ci-template.nvim))
- Static analysis with LuaLS (inspired by [lukas-reineke/ci-template.nvim](https://github.com/lukas-reineke/ci-template.nvim))
- GitHub Actions Pipeline:
- Lint with [Stylua](https://github.com/JohnnyMorganz/StyLua)
- Static analysis with LuaLS
- Versioned testing (0.9.x, 0.10.x and Nightly by default)
- Generated documentation analysis
- Minimal run time with caching capabilities, ideal for free-plans

## 📋 Installation

> **Note**:
> This section is only required if you wish to use the linter provided by the template.
> This section is only required if you wish to use the tooling proposed by this template, you can skip this step if you want.
- [Install Stylua linter](https://github.com/JohnnyMorganz/StyLua#installation)
- [Install `bob` neovim version manager](https://github.com/MordechaiHadad/bob)
- [Install Stylua for the linting solution](https://github.com/JohnnyMorganz/StyLua#installation)
- [Install `bob` neovim version manager for the versioned testing solution](https://github.com/MordechaiHadad/bob)

## ☄ Getting started

Expand Down Expand Up @@ -82,6 +83,7 @@ rm -rf doc
mv plugin/your-plugin-name.lua plugin/my-awesome-plugin.lua
mv lua/your-plugin-name lua/my-awesome-plugin
mv README_TEMPLATE.md README.md
mv .github/ISSUE_TEMPLATE/Bug_report_template.yml .github/ISSUE_TEMPLATE/Bug_report.yml

```

Expand Down Expand Up @@ -111,6 +113,12 @@ You can now start writing your plugin, make sure the following commands work:

Enjoy!

## ☄ Who uses this template?

- [no-neck-pain.nvim](https://github.com/shortcuts/no-neck-pain.nvim): ☕ Dead simple yet super extensible plugin to center the currently focused buffer to the middle of the screen.
- [wf.nvim](https://github.com/Cassin01/wf.nvim): A modern which-key for neovim
- [better-ts-errors.nvim](https://github.com/OlegGulevskyy/better-ts-errors.nvim)

## ⌨ Contributing

PRs and issues are always welcome. Make sure to provide as much context as possible when opening one.
9 changes: 5 additions & 4 deletions doc/neovim-plugin-boilerplate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Toggle the plugin by calling the `enable`/`disable` methods respectively.

------------------------------------------------------------------------------
*YourPluginName.enable()*
`YourPluginName.enable`()
`YourPluginName.enable`({scope})
Initializes the plugin, sets event listeners and internal state.

------------------------------------------------------------------------------
Expand All @@ -19,17 +19,18 @@ Disables the plugin, clear highlight groups and autocmds, closes side buffers an
------------------------------------------------------------------------------
*YourPluginName.options*
`YourPluginName.options`
Your plugin configuration with its default values.
YourPluginName configuration with its default values.

Type ~
`(table)`
Default values:
>
>lua
YourPluginName.options = {
-- Prints useful logs about what event are triggered, and reasons actions are executed.
debug = false,
}

<

------------------------------------------------------------------------------
*YourPluginName.setup()*
`YourPluginName.setup`({options})
Expand Down
17 changes: 6 additions & 11 deletions lua/your-plugin-name/config.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
local D = require("your-plugin-name.util.debug")
local log = require("your-plugin-name.util.log")

local YourPluginName = {}

--- Your plugin configuration with its default values.
--- YourPluginName configuration with its default values.
---
---@type table
--- Default values:
---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section)
YourPluginName.options = {
Expand All @@ -20,11 +21,8 @@ local defaults = vim.deepcopy(YourPluginName.options)
---
---@private
function YourPluginName.defaults(options)
local tde = function(t1, t2)
return vim.deepcopy(vim.tbl_deep_extend("keep", t1 or {}, t2 or {}))
end

YourPluginName.options = tde(options, defaults)
YourPluginName.options =
vim.deepcopy(vim.tbl_deep_extend("keep", options or {}, defaults or {}))

-- let your user know that they provided a wrong value, this is reported when your plugin is executed.
assert(
Expand All @@ -43,10 +41,7 @@ end
function YourPluginName.setup(options)
YourPluginName.options = YourPluginName.defaults(options or {})

-- Useful for later checks that requires nvim 0.9 features at runtime.
YourPluginName.options.hasNvim9 = vim.fn.has("nvim-0.9") == 1

D.warnDeprecation(YourPluginName.options)
log.warn_deprecation(YourPluginName.options)

return YourPluginName.options
end
Expand Down
Loading

0 comments on commit ca72698

Please sign in to comment.