summaryrefslogtreecommitdiff
path: root/lua/plugin-loader.lua
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-09-16 09:58:32 +0200
committerGitHub <[email protected]>2021-09-16 12:28:32 +0430
commite22f9a21c179901e6dfcbdb68d035e70eae4d9e8 (patch)
tree95fc4bbb019089cc62de91d4c722067ea313e10b /lua/plugin-loader.lua
parent168eb232d12f86e98f0d90c4e73e0c9968a3cb8e (diff)
fix: more robust reloading (#1556)
Diffstat (limited to 'lua/plugin-loader.lua')
-rw-r--r--lua/plugin-loader.lua20
1 files changed, 19 insertions, 1 deletions
diff --git a/lua/plugin-loader.lua b/lua/plugin-loader.lua
index 08f0e5a0..c20dd21a 100644
--- a/lua/plugin-loader.lua
+++ b/lua/plugin-loader.lua
@@ -1,11 +1,15 @@
local plugin_loader = {}
+local utils = require "utils"
+local Log = require "core.log"
+-- we need to reuse this outside of init()
+local compile_path = get_config_dir() .. "/plugin/packer_compiled.lua"
+
function plugin_loader:init(opts)
opts = opts or {}
local install_path = opts.install_path or vim.fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim"
local package_root = opts.package_root or vim.fn.stdpath "data" .. "/site/pack"
- local compile_path = opts.compile_path or vim.fn.stdpath "config" .. "/plugin/packer_compile.lua"
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }
@@ -32,6 +36,20 @@ function plugin_loader:init(opts)
return self
end
+function plugin_loader:cache_clear()
+ if vim.fn.delete(compile_path) == 0 then
+ Log:debug "deleted packer_compiled.lua"
+ end
+end
+
+function plugin_loader:cache_reset()
+ self.cache_clear()
+ require("packer").compile()
+ if utils.is_file(compile_path) then
+ Log:debug "generated packer_compiled.lua"
+ end
+end
+
function plugin_loader:load(configurations)
return self.packer.startup(function(use)
for _, plugins in ipairs(configurations) do