plugin-loader.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. local plugin_loader = {}
  2. function plugin_loader:init()
  3. local install_path = "~/.local/share/lunarvim/site/pack/packer/start/packer.nvim"
  4. if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
  5. vim.fn.system { "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path }
  6. vim.cmd "packadd packer.nvim"
  7. end
  8. local packer_ok, packer = pcall(require, "packer")
  9. if not packer_ok then
  10. return
  11. end
  12. local util = require "packer.util"
  13. packer.init {
  14. package_root = util.join_paths "~/.local/share/lunarvim/site/pack/",
  15. compile_path = util.join_paths("~/.config/lvim", "plugin", "packer_compiled.lua"),
  16. git = { clone_timeout = 300 },
  17. display = {
  18. open_fn = function()
  19. return util.float { border = "rounded" }
  20. end,
  21. },
  22. }
  23. self.packer = packer
  24. return self
  25. end
  26. function plugin_loader:load(configurations)
  27. return self.packer.startup(function(use)
  28. for _, plugins in ipairs(configurations) do
  29. for _, plugin in ipairs(plugins) do
  30. use(plugin)
  31. end
  32. end
  33. end)
  34. end
  35. return {
  36. init = function()
  37. return plugin_loader:init()
  38. end,
  39. }