From df1565e80c040bb8d0ccc34f690c5f85fc188b33 Mon Sep 17 00:00:00 2001 From: mathew Date: Fri, 16 Jun 2023 16:10:41 +0800 Subject: [PATCH] update --- .github/workflows/ci.yml | 63 +++++++++++++++++++++++++++++++ .stylua.toml | 6 +++ README.md | 19 ++++++++++ doc/nvim-plugin-template.txt | 0 lua/nvim-plugin-template/init.lua | 0 plugin/nvim-plugin-template.lua | 0 rename.py | 24 ++++++++++++ test/plugin_spec.lua | 5 +++ 8 files changed, 117 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .stylua.toml create mode 100644 doc/nvim-plugin-template.txt create mode 100644 lua/nvim-plugin-template/init.lua create mode 100644 plugin/nvim-plugin-template.lua create mode 100644 rename.py create mode 100644 test/plugin_spec.lua diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a8a2da8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,63 @@ +name: Ci + +on: [push] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Stylua + uses: JohnnyMorganz/stylua-action@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest + args: --check . + + + docs: + runs-on: ubuntu-latest + name: pandoc to vimdoc + if: ${{ github.ref == 'refs/heads/main' }} + steps: + - uses: actions/checkout@v3 + - name: panvimdoc + uses: kdheepak/panvimdoc@main + with: + vimdoc: nvim-plugin-template.nvim + treesitter: true + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: 'chore(doc): auto generate docs' + commit_user_name: "github-actions[bot]" + commit_user_email: "github-actions[bot]@users.noreply.github.com" + commit_author: "github-actions[bot] " + + test: + name: Run Test + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v3 + - uses: rhysd/action-setup-vim@v1 + id: vim + with: + neovim: true + version: nightly + + - name: luajit + uses: leafo/gh-actions-lua@v10 + with: + luaVersion: "luajit-2.1.0-beta3" + + - name: luarocks + uses: leafo/gh-actions-luarocks@v4 + + - name: run test + shell: bash + run: | + luarocks install luacheck + luarocks install vusted + vusted ./test diff --git a/.stylua.toml b/.stylua.toml new file mode 100644 index 0000000..a2b3447 --- /dev/null +++ b/.stylua.toml @@ -0,0 +1,6 @@ +column_width = 100 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferSingle" +call_parentheses = "Always" diff --git a/README.md b/README.md index dc9fd06..34d3b93 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ # nvim-plugin-template neovim plugin template integration test and doc publish + +## Usage + +click `use this template` button generate a repo on your github. then clone your plugin repo.open +terminal then cd plugin directory , run `python3 rename.py your-plugin-name` this will replace all +`nvim-plugin-template` to your `pluing-name`. Then develope your plugin. Enjoy! + +## Test +use vusted for test install by using `luarocks --lua-version=5.1 install vusted` then run `vusted test` +for your test cases + +## Ci +Ci support auto generate doc from README and integration test. + + +## More +Other usage you can look at my plugins + +## License MIT diff --git a/doc/nvim-plugin-template.txt b/doc/nvim-plugin-template.txt new file mode 100644 index 0000000..e69de29 diff --git a/lua/nvim-plugin-template/init.lua b/lua/nvim-plugin-template/init.lua new file mode 100644 index 0000000..e69de29 diff --git a/plugin/nvim-plugin-template.lua b/plugin/nvim-plugin-template.lua new file mode 100644 index 0000000..e69de29 diff --git a/rename.py b/rename.py new file mode 100644 index 0000000..7d6a6b4 --- /dev/null +++ b/rename.py @@ -0,0 +1,24 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +import os, sys + +if len(sys.argv) == 2: + new_name = sys.argv[1] + for dir in os.listdir(os.getcwd()): + if dir == "lua": + os.rename(os.path.join("lua", "nvim-plugin-template"), os.path.join("lua",new_name)) + if dir == "plugin": + os.rename(os.path.join("plugin", "nvim-plugin-template.lua"), + os.path.join("plugin",new_name + ".lua")) + if dir == 'doc': + os.rename(os.path.join("doc", "nvim-plugin-template.txt"), + os.path.join("doc",new_name + ".txt")) + if dir == '.github': + with open(os.path.join(".github","workflows","ci.yml"), 'r+') as f: + d = f.read() + t = d.replace('nvim-plugin-template', new_name) + f.seek(0, 0) + f.write(t) + + os.remove(os.path.join(os.getcwd(), 'rename.py')) diff --git a/test/plugin_spec.lua b/test/plugin_spec.lua new file mode 100644 index 0000000..774fde0 --- /dev/null +++ b/test/plugin_spec.lua @@ -0,0 +1,5 @@ +describe('neovim plugin', function() + it('work as expect', function() + assert.is_true(true) + end) +end)