diff --git a/README.md b/README.md index 98aff41..977faee 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,15 @@ 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! +1. click `use this template` button generate a repo on your github. +2. clone your plugin repo.open terminal then cd plugin directory. +3. run `python3 rename.py your-plugin-name` this will replace all `nvim-plugin-template` to your `pluing-name`. + then it will prompt you input `y` or `n` to remove example codes in `init.lua` and + `test/plugin_spec.lua`. if you are familiar this repo just input y. if you are first look at this + template I suggest you look at them first. after these step the `rename.py` will also auto + remove. + +now you have a clean plugin env . enjoy! ## Format diff --git a/lua/nvim-plugin-template/init.lua b/lua/nvim-plugin-template/init.lua index e69de29..afa0777 100644 --- a/lua/nvim-plugin-template/init.lua +++ b/lua/nvim-plugin-template/init.lua @@ -0,0 +1,7 @@ +local function example() + return true +end + +return { + example = example, +} diff --git a/rename.py b/rename.py index 7d6a6b4..01a06b1 100644 --- a/rename.py +++ b/rename.py @@ -3,9 +3,11 @@ import os, sys +pdir = os.getcwd() + if len(sys.argv) == 2: new_name = sys.argv[1] - for dir in os.listdir(os.getcwd()): + for dir in os.listdir(pdir): if dir == "lua": os.rename(os.path.join("lua", "nvim-plugin-template"), os.path.join("lua",new_name)) if dir == "plugin": @@ -21,4 +23,12 @@ if len(sys.argv) == 2: f.seek(0, 0) f.write(t) + choice = input("Do you want also remove example code in init.lua and test (y|n): ") + if choice.lower() == 'y': + with open(os.path.join(pdir, 'lua','nvim-plugin-template','init.lua'), 'w') as f: + f.truncate() + + with open(os.path.join(pdir, 'test','plugin_spec.lua'), 'w') as f: + f.truncate() + os.remove(os.path.join(os.getcwd(), 'rename.py')) diff --git a/test/plugin_spec.lua b/test/plugin_spec.lua index 774fde0..4f1ef32 100644 --- a/test/plugin_spec.lua +++ b/test/plugin_spec.lua @@ -1,5 +1,8 @@ +local example = require('nvim-plugin-template').example + describe('neovim plugin', function() it('work as expect', function() - assert.is_true(true) + local result = example() + assert.is_true(result) end) end)