Skip to content

Commit ecfd340

Browse files
committed
more changes
1 parent d0805bf commit ecfd340

File tree

9 files changed

+47
-20
lines changed

9 files changed

+47
-20
lines changed

.github/workflows/default.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- uses: JohnnyMorganz/stylua-action@1.0.0
1111
with:
1212
token: ${{ secrets.GITHUB_TOKEN }}
13-
args: --color always --check .
13+
args: --color always --check lua
1414

1515
test:
1616
runs-on: ubuntu-latest

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A template repository for Neovim plugins.
1010
Via `gh`:
1111

1212
```
13-
$ gh repo create my-plugin -p ellisonleao/neovim-plugin-template
13+
$ gh repo create my-plugin -p ellisonleao/nvim-plugin-template
1414
```
1515

1616
Via github web page:
@@ -22,8 +22,8 @@ Click on `Use this template`
2222
## Features and structure
2323

2424
- 100% lua
25-
- Github actions to run tests and formatting (Stylua)
26-
- tests with busted and plenary.nvim
25+
- Github actions to run tests and check for formatting errors (Stylua)
26+
- tests [busted](https://olivinelabs.com/busted/) + [plenary.nvim](https://github.com/nvim-lua/plenary.nvim)
2727

2828
### Plugin structure
2929

lua/module/init.lua

Lines changed: 0 additions & 8 deletions
This file was deleted.

lua/plugin_name.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- main module file
2+
local module = require("plugin_name.module")
3+
4+
local M = {}
5+
local config = {
6+
-- default config
7+
opt = "Hello!",
8+
}
9+
10+
-- setup is the public method to setup your plugin
11+
M.setup = function(args)
12+
-- you can define your setup function here. Usually configurations can be merged, accepting outside params and
13+
-- you can also put some validation here for those.
14+
config = vim.tbl_deep_extend("keep", args, config)
15+
end
16+
17+
-- "hello" is a public method for the plugin
18+
M.hello = function()
19+
module.my_first_function(config.opt)
20+
end
21+
22+
return M

lua/plugin_name/module.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- module represents a lua module for the plugin
2+
local M = {}
3+
4+
M.my_first_function = function(var)
5+
return "my first function with param = " .. var
6+
end
7+
8+
return M

plugin/module.lua

Lines changed: 0 additions & 1 deletion
This file was deleted.

plugin/plugin_name.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vim.cmd([[command! MyFirstFunction lua require('plugin_name.module').my_first_function() ]])

tests/module/module_spec.lua

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
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("my first function with param = Hello!", plugin.hello())
6+
end)
7+
8+
it("works with custom var", function()
9+
plugin.setup({ opt = "custom" })
10+
assert("my first function with param = custom", plugin.hello())
11+
end)
12+
end)

0 commit comments

Comments
 (0)