-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: template cleanup and improvements (#11)
## 📃 Summary better initial setup and remove useless functions
- Loading branch information
Showing
7 changed files
with
47 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
YourPluginName.disable() neovim-plugin-boilerplate.txt /*YourPluginName.disable()* | ||
YourPluginName.enable() neovim-plugin-boilerplate.txt /*YourPluginName.enable()* | ||
YourPluginName.options neovim-plugin-boilerplate.txt /*YourPluginName.options* | ||
YourPluginName.setup() neovim-plugin-boilerplate.txt /*YourPluginName.setup()* | ||
YourPluginName.toggle() neovim-plugin-boilerplate.txt /*YourPluginName.toggle()* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,41 @@ | ||
local M = require("your-plugin-name.main") | ||
local YourPluginName = {} | ||
|
||
-- Toggle the plugin by calling the `enable`/`disable` methods respectively. | ||
function YourPluginName.toggle() | ||
-- when the config is not set to the global object, we set it | ||
if YourPluginName.config == nil then | ||
YourPluginName.config = require("your-plugin-name.config").options | ||
end | ||
local main = require("your-plugin-name.main") | ||
|
||
-- the internal toggle method tell us if the plugin was enabled or disabled. | ||
-- this allows us to init/reset the global object. | ||
if main[1].toggle() then | ||
YourPluginName.internal = { | ||
toggle = main[1].toggle, | ||
enable = main[1].enable, | ||
disable = main[1].disable, | ||
} | ||
else | ||
YourPluginName.internal = { | ||
toggle = nil, | ||
enable = nil, | ||
disable = nil, | ||
} | ||
if _G.YourPluginName.config == nil then | ||
_G.YourPluginName.config = require("your-plugin-name.config").options | ||
end | ||
|
||
YourPluginName.state = main[2] | ||
_G.YourPluginName.state = M.toggle() | ||
end | ||
|
||
-- starts YourPluginName and set internal functions and state. | ||
function YourPluginName.enable() | ||
local main = require("your-plugin-name.main") | ||
if _G.YourPluginName.config == nil then | ||
_G.YourPluginName.config = require("your-plugin-name.config").options | ||
end | ||
|
||
local state = M.enable() | ||
|
||
main[1].enable() | ||
if state ~= nil then | ||
_G.YourPluginName.state = state | ||
end | ||
|
||
YourPluginName.state = main[2] | ||
YourPluginName.internal = { | ||
toggle = main[1].toggle, | ||
enable = main[1].enable, | ||
disable = main[1].disable, | ||
} | ||
return state | ||
end | ||
|
||
-- disables YourPluginName and reset internal functions and state. | ||
function YourPluginName.disable() | ||
local main = require("your-plugin-name.main") | ||
|
||
main[1].disable() | ||
|
||
YourPluginName.state = main[2] | ||
_G.YourPluginName.state = M.disable() | ||
end | ||
|
||
-- setup YourPluginName options and merge them with user provided ones. | ||
function YourPluginName.setup(opts) | ||
YourPluginName.config = require("your-plugin-name.config").setup(opts) | ||
_G.YourPluginName.config = require("your-plugin-name.config").setup(opts) | ||
end | ||
|
||
_G.YourPluginName = YourPluginName | ||
|
||
return YourPluginName | ||
return _G.YourPluginName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.