feat: dynamically import lua/plugins/*.lua
This commit is contained in:
parent
1057b83693
commit
569c1faf7d
|
@ -1,4 +1,4 @@
|
||||||
-- Bootstrap 'mini.nvim' manually in a way that it gets managed by 'mini.deps'
|
-- bootstrap 'mini.nvim' manually in a way that it gets managed by 'mini.deps'
|
||||||
local mini_path = vim.fn.stdpath("data") .. "/site/pack/deps/start/mini.nvim"
|
local mini_path = vim.fn.stdpath("data") .. "/site/pack/deps/start/mini.nvim"
|
||||||
if not vim.loop.fs_stat(mini_path) then
|
if not vim.loop.fs_stat(mini_path) then
|
||||||
vim.cmd('echo "Installing `mini.nvim`" | redraw')
|
vim.cmd('echo "Installing `mini.nvim`" | redraw')
|
||||||
|
@ -14,10 +14,10 @@ if not vim.loop.fs_stat(mini_path) then
|
||||||
vim.cmd('echo "Installed `mini.nvim`" | redraw')
|
vim.cmd('echo "Installed `mini.nvim`" | redraw')
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set up 'mini.deps' immediately to have its `now()` and `later()` helpers
|
-- set up 'mini.deps' immediately to have its `now()` and `later()` helpers
|
||||||
require("mini.deps").setup()
|
require("mini.deps").setup()
|
||||||
|
|
||||||
-- Also setup this user command to always save a new lockfile after update
|
-- also setup this user command to always save a new lockfile after update
|
||||||
vim.api.nvim_create_user_command("DepsUpdateSnapSave", function(opts)
|
vim.api.nvim_create_user_command("DepsUpdateSnapSave", function(opts)
|
||||||
local name = opts.args ~= "" and opts.args or nil
|
local name = opts.args ~= "" and opts.args or nil
|
||||||
MiniDeps.update(name)
|
MiniDeps.update(name)
|
||||||
|
@ -37,18 +37,28 @@ end, {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Define main config table to be able to use it in scripts
|
-- define main config table to be able to use it in scripts
|
||||||
_G.Config = {}
|
_G.Config = {}
|
||||||
|
|
||||||
-- import other plugins
|
-- dyncamically import lua/plugins/*.lua
|
||||||
local r = function(m) require("plugins." .. m) end
|
local path = vim.fn.stdpath("config") .. "/lua/plugins"
|
||||||
|
|
||||||
local order = {
|
local plugins = vim.iter(vim.fs.dir(path))
|
||||||
"colorscheme",
|
:filter(function(n, t) return t == "file" and n:match("%.lua") end)
|
||||||
"oil",
|
:map(function(n, _)
|
||||||
"fzf_lua",
|
local s, _ = n:gsub("%.lua$", "")
|
||||||
}
|
return s
|
||||||
|
end)
|
||||||
|
:totable()
|
||||||
|
|
||||||
for _, m in ipairs(order) do
|
-- gather errors so any vim.notify overrides happen
|
||||||
r(m)
|
local errors = {}
|
||||||
|
|
||||||
|
for _, p in ipairs(plugins) do
|
||||||
|
local ok, err = pcall(require, "plugins." .. p)
|
||||||
|
if not ok then table.insert(errors, "'" .. p .. ".lua'\n\t" .. err) end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, error in ipairs(errors) do
|
||||||
|
vim.notify(error, vim.log.levels.ERROR)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue