mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-07-21 19:24:25 +02:00
Split plugin loading logic from the configuration (#796)
This commit is contained in:
parent
56f17cebd4
commit
6f9c521e22
3 changed files with 113 additions and 92 deletions
46
lua/plugin-loader.lua
Normal file
46
lua/plugin-loader.lua
Normal file
|
@ -0,0 +1,46 @@
|
|||
local plugin_loader = {}
|
||||
|
||||
function plugin_loader:init()
|
||||
local execute = vim.api.nvim_command
|
||||
local fn = vim.fn
|
||||
|
||||
local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim"
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
execute("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
|
||||
execute "packadd packer.nvim"
|
||||
end
|
||||
|
||||
local packer_ok, packer = pcall(require, "packer")
|
||||
if not packer_ok then
|
||||
return
|
||||
end
|
||||
|
||||
packer.init {
|
||||
-- package_root = require("packer.util").join_paths(vim.fn.stdpath "data", "lvim", "pack"),
|
||||
git = { clone_timeout = 300 },
|
||||
display = {
|
||||
open_fn = function()
|
||||
return require("packer.util").float { border = "single" }
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
self.packer = packer
|
||||
return self
|
||||
end
|
||||
|
||||
function plugin_loader:load(configurations)
|
||||
return self.packer.startup(function(use)
|
||||
for _, plugins in ipairs(configurations) do
|
||||
for _, plugin in ipairs(plugins) do
|
||||
use(plugin)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
return {
|
||||
init = function()
|
||||
return plugin_loader:init()
|
||||
end,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue