Created
February 28, 2023 09:39
-
-
Save 0xlkda/53620e2609bfb6a353af0dc2fa86b3d4 to your computer and use it in GitHub Desktop.
template for new neovim plugin
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
function M.setup(opts) | |
-- Look up keys in user-defined table with fallback to defaults. | |
M.opts = setmetatable(opts or {}, {__index = require'app.defaults'}) | |
M.initialized = true | |
-- Insert the engine and register the autocommand if asked to. | |
local engine = require'app.engine' | |
-- engine.do_work() | |
if M.opts.create_app_autocmd then | |
engine.create_autocmd() | |
end | |
-- register App extensions, if any | |
if M.opts.extensions ~= nil then | |
for _, ext_name in pairs(opts.extensions) do | |
local ok, extension = pcall(require, ext_name) | |
if not ok then | |
-- 4 is error; thanks Neovim… :( | |
vim.notify(string.format('extension %s wasn’t correctly loaded', ext_name), 4) | |
else | |
if extension.register == nil then | |
vim.notify(string.format('extension %s lacks the register function', ext_name), 4) | |
else | |
extension.register(opts) | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment