Skip to content

Commit afc7583

Browse files
authored
Initial commit
0 parents  commit afc7583

16 files changed

+378
-0
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Bug Report
2+
description: File a bug/issue
3+
title: "bug: "
4+
labels: [bug]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
**Before** reporting an issue, make sure to read the documentation and search existing issues. Usage questions such as ***"How do I...?"*** belong in Discussions and will be closed.
10+
- type: checkboxes
11+
attributes:
12+
label: Did you check docs and existing issues?
13+
description: Make sure you checked all of the below before submitting an issue
14+
options:
15+
- label: I have read all the plugin docs
16+
required: true
17+
- label: I have searched the existing issues
18+
required: true
19+
- label: I have searched the existing issues of plugins related to this issue
20+
required: true
21+
- type: input
22+
attributes:
23+
label: "Neovim version (nvim -v)"
24+
placeholder: "0.8.0 commit db1b0ee3b30f"
25+
validations:
26+
required: true
27+
- type: input
28+
attributes:
29+
label: "Operating system/version"
30+
placeholder: "MacOS 11.5"
31+
validations:
32+
required: true
33+
- type: textarea
34+
attributes:
35+
label: Describe the bug
36+
description: A clear and concise description of what the bug is. Please include any related errors you see in Neovim.
37+
validations:
38+
required: true
39+
- type: textarea
40+
attributes:
41+
label: Steps To Reproduce
42+
description: Steps to reproduce the behavior.
43+
placeholder: |
44+
1.
45+
2.
46+
3.
47+
validations:
48+
required: true
49+
- type: textarea
50+
attributes:
51+
label: Expected Behavior
52+
description: A concise description of what you expected to happen.
53+
validations:
54+
required: true
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Feature Request
2+
description: Suggest a new feature
3+
title: "feature: "
4+
labels: [enhancement]
5+
body:
6+
- type: checkboxes
7+
attributes:
8+
label: Did you check the docs?
9+
description: Make sure you read all the docs before submitting a feature request
10+
options:
11+
- label: I have read all the docs
12+
required: true
13+
- type: textarea
14+
validations:
15+
required: true
16+
attributes:
17+
label: Is your feature request related to a problem? Please describe.
18+
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
19+
- type: textarea
20+
validations:
21+
required: true
22+
attributes:
23+
label: Describe the solution you'd like
24+
description: A clear and concise description of what you want to happen.
25+
- type: textarea
26+
validations:
27+
required: true
28+
attributes:
29+
label: Describe alternatives you've considered
30+
description: A clear and concise description of any alternative solutions or features you've considered.
31+
- type: textarea
32+
validations:
33+
required: false
34+
attributes:
35+
label: Additional context
36+
description: Add any other context or screenshots about the feature request here.

.github/workflows/docs.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
name: docs
6+
7+
jobs:
8+
docs:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- name: panvimdoc
13+
uses: kdheepak/panvimdoc@main
14+
with:
15+
vimdoc: my-template-docs
16+
version: "Neovim >= 0.8.0"
17+
demojify: true
18+
treesitter: true
19+
- name: Push changes
20+
uses: stefanzweifel/git-auto-commit-action@v4
21+
with:
22+
commit_message: "auto-generate vimdoc"
23+
commit_user_name: "github-actions[bot]"
24+
commit_user_email: "github-actions[bot]@users.noreply.github.com"
25+
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"

.github/workflows/lint-test.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
on: [push, pull_request]
3+
name: lint-test
4+
5+
jobs:
6+
stylua:
7+
name: stylua
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: JohnnyMorganz/stylua-action@v3
12+
with:
13+
version: latest
14+
token: ${{ secrets.GITHUB_TOKEN }}
15+
args: --color always --check lua
16+
17+
test:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
nvim-versions: ['stable', 'nightly']
22+
name: test
23+
steps:
24+
- name: checkout
25+
uses: actions/checkout@v3
26+
27+
- uses: rhysd/action-setup-vim@v1
28+
with:
29+
neovim: true
30+
version: ${{ matrix.nvim-versions }}
31+
32+
- name: run tests
33+
run: make test

.github/workflows/release.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: "release"
2+
on:
3+
push:
4+
tags:
5+
- 'v*'
6+
jobs:
7+
luarocks-upload:
8+
runs-on: ubuntu-22.04
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: LuaRocks Upload
12+
uses: nvim-neorocks/luarocks-tag-release@v4
13+
env:
14+
LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor/plenary.nvim

.stylua.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
column_width = 120
2+
line_endings = "Unix"
3+
indent_type = "Spaces"
4+
indent_width = 2
5+
quote_style = "AutoPreferDouble"
6+
no_call_parentheses = false

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Ellison
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
TESTS_INIT=tests/minimal_init.lua
2+
TESTS_DIR=tests/
3+
4+
.PHONY: test
5+
6+
test:
7+
@nvim \
8+
--headless \
9+
--noplugin \
10+
-u ${TESTS_INIT} \
11+
-c "PlenaryBustedDirectory ${TESTS_DIR} { minimal_init = '${TESTS_INIT}' }"

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# A Neovim Plugin Template
2+
3+
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/ellisonleao/nvim-plugin-template/lint-test.yml?branch=main&style=for-the-badge)
4+
![Lua](https://img.shields.io/badge/Made%20with%20Lua-blueviolet.svg?style=for-the-badge&logo=lua)
5+
6+
A template repository for Neovim plugins.
7+
8+
## Using it
9+
10+
Via `gh`:
11+
12+
```
13+
$ gh repo create my-plugin -p ellisonleao/nvim-plugin-template
14+
```
15+
16+
Via github web page:
17+
18+
Click on `Use this template`
19+
20+
![](https://docs.github.com/assets/cb-36544/images/help/repository/use-this-template-button.png)
21+
22+
## Features and structure
23+
24+
- 100% Lua
25+
- Github actions for:
26+
- running tests using [plenary.nvim](https://github.com/nvim-lua/plenary.nvim) and [busted](https://olivinelabs.com/busted/)
27+
- check for formatting errors (Stylua)
28+
- vimdocs autogeneration from README.md file
29+
- luarocks release (LUAROCKS_API_KEY secret configuration required)
30+
31+
### Plugin structure
32+
33+
```
34+
.
35+
├── lua
36+
│   ├── plugin_name
37+
│   │   └── module.lua
38+
│   └── plugin_name.lua
39+
├── Makefile
40+
├── plugin
41+
│   └── plugin_name.lua
42+
├── README.md
43+
├── tests
44+
│   ├── minimal_init.lua
45+
│   └── plugin_name
46+
│   └── plugin_name_spec.lua
47+
```

doc/my-template-docs.txt

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
*my-template-docs.txt* For Neovim >= 0.8.0 Last change: 2024 January 18
2+
3+
==============================================================================
4+
Table of Contents *my-template-docs-table-of-contents*
5+
6+
1. A Neovim Plugin Template |my-template-docs-a-neovim-plugin-template|
7+
- Using it |my-template-docs-a-neovim-plugin-template-using-it|
8+
- Features and structure|my-template-docs-a-neovim-plugin-template-features-and-structure|
9+
10+
==============================================================================
11+
1. A Neovim Plugin Template *my-template-docs-a-neovim-plugin-template*
12+
13+
14+
15+
A template repository for Neovim plugins.
16+
17+
18+
USING IT *my-template-docs-a-neovim-plugin-template-using-it*
19+
20+
Via `gh`
21+
22+
>
23+
$ gh repo create my-plugin -p ellisonleao/nvim-plugin-template
24+
<
25+
26+
Viagithub web page:
27+
28+
Click on `Use this template`
29+
30+
31+
32+
33+
FEATURES AND STRUCTURE*my-template-docs-a-neovim-plugin-template-features-and-structure*
34+
35+
- 100% Lua
36+
- Github actions for:
37+
- running tests using plenary.nvim <https://github.com/nvim-lua/plenary.nvim> and busted <https://olivinelabs.com/busted/>
38+
- check for formatting errors (Stylua)
39+
- vimdocs autogeneration from README.md file
40+
- luarocks release (LUAROCKS_API_KEY secret configuration required)
41+
42+
43+
PLUGIN STRUCTURE ~
44+
45+
>
46+
.
47+
├── lua
48+
│   ├── plugin_name
49+
│   │   └── module.lua
50+
│   └── plugin_name.lua
51+
├── Makefile
52+
├── plugin
53+
│   └── plugin_name.lua
54+
├── README.md
55+
├── tests
56+
│   ├── minimal_init.lua
57+
│   └── plugin_name
58+
│   └── plugin_name_spec.lua
59+
<
60+
61+
==============================================================================
62+
2. Links *my-template-docs-links*
63+
64+
1. *GitHub Workflow Status*: https://img.shields.io/github/actions/workflow/status/ellisonleao/nvim-plugin-template/lint-test.yml?branch=main&style=for-the-badge
65+
2. *Lua*: https://img.shields.io/badge/Made%20with%20Lua-blueviolet.svg?style=for-the-badge&logo=lua
66+
3. **: https://docs.github.com/assets/cb-36544/images/help/repository/use-this-template-button.png
67+
68+
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
69+
70+
vim:tw=78:ts=8:noet:ft=help:norl:

lua/plugin_name.lua

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-- main module file
2+
local module = require("plugin_name.module")
3+
4+
---@class Config
5+
---@field opt string Your config option
6+
local config = {
7+
opt = "Hello!",
8+
}
9+
10+
---@class MyModule
11+
local M = {}
12+
13+
---@type Config
14+
M.config = config
15+
16+
---@param args Config?
17+
-- you can define your setup function here. Usually configurations can be merged, accepting outside params and
18+
-- you can also put some validation here for those.
19+
M.setup = function(args)
20+
M.config = vim.tbl_deep_extend("force", M.config, args or {})
21+
end
22+
23+
M.hello = function()
24+
return module.my_first_function(M.config.opt)
25+
end
26+
27+
return M

lua/plugin_name/module.lua

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---@class CustomModule
2+
local M = {}
3+
4+
---@return string
5+
M.my_first_function = function(greeting)
6+
return greeting
7+
end
8+
9+
return M

plugin/plugin_name.lua

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vim.api.nvim_create_user_command("MyFirstFunction", require("plugin_name").hello, {})

tests/minimal_init.lua

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
local plenary_dir = os.getenv("PLENARY_DIR") or "/tmp/plenary.nvim"
2+
local is_not_a_directory = vim.fn.isdirectory(plenary_dir) == 0
3+
if is_not_a_directory then
4+
vim.fn.system({"git", "clone", "https://github.com/nvim-lua/plenary.nvim", plenary_dir})
5+
end
6+
7+
vim.opt.rtp:append(".")
8+
vim.opt.rtp:append(plenary_dir)
9+
10+
vim.cmd("runtime plugin/plenary.vim")
11+
require("plenary.busted")
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
local plugin = require("plugin_name")
2+
3+
describe("setup", function()
4+
it("works with default", function()
5+
assert(plugin.hello() == "Hello!", "my first function with param = Hello!")
6+
end)
7+
8+
it("works with custom var", function()
9+
plugin.setup({ opt = "custom" })
10+
assert(plugin.hello() == "custom", "my first function with param = custom")
11+
end)
12+
end)

0 commit comments

Comments
 (0)