├── .gitignore ├── .luacheckrc ├── .editorconfig ├── spec └── example_spec.lua ├── .busted ├── .github └── workflows │ ├── tests.yml │ ├── release.yml │ └── linter.yml ├── nvim-lua-plugin-scm-1.rockspec └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /luarocks 2 | /lua_modules 3 | /.luarocks 4 | -------------------------------------------------------------------------------- /.luacheckrc: -------------------------------------------------------------------------------- 1 | ignore = { 2 | "631", -- max_line_length 3 | } 4 | read_globals = { 5 | "vim", 6 | "describe", 7 | "it", 8 | "assert" 9 | } 10 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.lua] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | -------------------------------------------------------------------------------- /spec/example_spec.lua: -------------------------------------------------------------------------------- 1 | describe('Test example', function() 2 | it('Test can access vim namespace', function() 3 | assert.are.same(vim.trim(' a '), 'a') 4 | end) 5 | end) 6 | -------------------------------------------------------------------------------- /.busted: -------------------------------------------------------------------------------- 1 | return { 2 | _all = { 3 | coverage = false, 4 | lpath = "lua/?.lua;lua/?/init.lua", 5 | lua = "nlua", 6 | }, 7 | default = { 8 | verbose = true 9 | }, 10 | tests = { 11 | verbose = true 12 | }, 13 | } 14 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Run tests 3 | on: 4 | pull_request: ~ 5 | push: 6 | branches: 7 | - main 8 | 9 | jobs: 10 | build: 11 | name: Run tests 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | neovim_version: ['nightly'] 16 | 17 | steps: 18 | - uses: actions/checkout@v3 19 | - name: Run tests 20 | uses: nvim-neorocks/nvim-busted-action@v1 21 | with: 22 | nvim_version: ${{ matrix.neovim_version }} 23 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: "Release" 3 | on: 4 | push: 5 | tags: 6 | - 'v*.*.*' 7 | 8 | jobs: 9 | luarocks-release: 10 | runs-on: ubuntu-latest 11 | name: Luarocks Release 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v3 15 | if: env.LUAROCKS_API_KEY != null 16 | - name: Luarocks Upload 17 | uses: nvim-neorocks/luarocks-tag-release@v7 18 | if: env.LUAROCKS_API_KEY != null 19 | env: 20 | LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }} 21 | -------------------------------------------------------------------------------- /.github/workflows/linter.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Lint Code Base 3 | on: 4 | pull_request: ~ 5 | push: 6 | branches: 7 | - master 8 | 9 | jobs: 10 | build: 11 | name: Lint Code Base 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Checkout Code 16 | uses: actions/checkout@v3 17 | 18 | - name: Lint Code Base 19 | uses: github/super-linter/slim@v4 20 | env: 21 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 22 | LINTER_RULES_PATH: / 23 | VALIDATE_JSCPD: false 24 | VALIDATE_PYTHON_BLACK: false 25 | -------------------------------------------------------------------------------- /nvim-lua-plugin-scm-1.rockspec: -------------------------------------------------------------------------------- 1 | rockspec_format = '3.0' 2 | -- TODO: Rename this file and set the package 3 | package = "nvim-lua-plugin" 4 | version = "scm-1" 5 | source = { 6 | -- TODO: Update this URL 7 | url = "git+https://github.com/nvim-lua/nvim-lua-plugin-template" 8 | } 9 | dependencies = { 10 | -- Add runtime dependencies here 11 | -- e.g. "plenary.nvim", 12 | } 13 | test_dependencies = { 14 | "nlua" 15 | } 16 | build = { 17 | type = "builtin", 18 | copy_directories = { 19 | -- Add runtimepath directories, like 20 | -- 'plugin', 'ftplugin', 'doc' 21 | -- here. DO NOT add 'lua' or 'lib'. 22 | }, 23 | } 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nvim-lua-plugin-template 2 | 3 | This repository is a template for Neovim plugins written in Lua. 4 | 5 | The intention is that you use this template to create a new repository where you then adapt this readme and add your plugin code. 6 | The template includes the following: 7 | 8 | - GitHub workflows and configurations to run linters and tests 9 | - Packaging of tagged releases and upload to [LuaRocks][luarocks] 10 | if a [`LUAROCKS_API_KEY`][luarocks-api-key] is added 11 | to the [GitHub Actions secrets][gh-actions-secrets] 12 | - Minimal test setup: 13 | - A `scm` [rockspec][rockspec-format], `nvim-lua-plugin-scm-1.rockspec` 14 | - A `.busted` file 15 | - EditorConfig 16 | - A .luacheckrc 17 | 18 | 19 | To get started writing a Lua plugin, I recommend reading `:help lua-guide` and 20 | `:help write-plugin`. 21 | 22 | ## Scope 23 | 24 | Anything that the majority of plugin authors will want to have is in scope of 25 | this starter template. Anything that is controversial is out-of-scope. 26 | 27 | ## Usage 28 | 29 | - Click [Use this template][use-this-template]. Do not fork. 30 | - Rename `nvim-lua-plugin-scm-1.rockspec` and change the `package` name 31 | to the name of your plugin. 32 | 33 | ## Template License 34 | 35 | The template itself is licensed under the [MIT license](https://en.wikipedia.org/wiki/MIT_License). 36 | The template doesn't include a LICENSE file. You should add one after creating your repository. 37 | 38 | --- 39 | 40 | 41 | The remainder of the README is text that can be preserved in your plugin: 42 | 43 | --- 44 | 45 | 46 | ## Development 47 | 48 | ### Run tests 49 | 50 | 51 | Running tests requires either 52 | 53 | - [luarocks][luarocks] 54 | - or [busted][busted] and [nlua][nlua] 55 | 56 | to be installed[^1]. 57 | 58 | [^1]: The test suite assumes that `nlua` has been installed 59 | using luarocks into `~/.luarocks/bin/`. 60 | 61 | You can then run: 62 | 63 | ```bash 64 | luarocks test --local 65 | # or 66 | busted 67 | ``` 68 | 69 | Or if you want to run a single test file: 70 | 71 | ```bash 72 | luarocks test spec/path_to_file.lua --local 73 | # or 74 | busted spec/path_to_file.lua 75 | ``` 76 | 77 | If you see an error like `module 'busted.runner' not found`: 78 | 79 | ```bash 80 | eval $(luarocks path --no-bin) 81 | ``` 82 | 83 | For this to work you need to have Lua 5.1 set as your default version for 84 | luarocks. If that's not the case you can pass `--lua-version 5.1` to all the 85 | luarocks commands above. 86 | 87 | [rockspec-format]: https://github.com/luarocks/luarocks/wiki/Rockspec-format 88 | [luarocks]: https://luarocks.org 89 | [luarocks-api-key]: https://luarocks.org/settings/api-keys 90 | [gh-actions-secrets]: https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository 91 | [busted]: https://lunarmodules.github.io/busted/ 92 | [nlua]: https://github.com/mfussenegger/nlua 93 | [use-this-template]: https://github.com/new?template_name=nvim-lua-plugin-template&template_owner=nvim-lua 94 | --------------------------------------------------------------------------------