diff options
author | kylo252 <[email protected]> | 2022-05-03 08:55:15 +0200 |
---|---|---|
committer | kylo252 <[email protected]> | 2022-05-03 08:55:15 +0200 |
commit | e264bff7e820ba891cd16892de52236d62f7821f (patch) | |
tree | 4262530ac7738ebdec0fa6abab560610789b72f3 /lua/lvim/plugin-loader.lua | |
parent | ad5eeaf6ad12cf05e4b936690bf78bc53827b12c (diff) | |
parent | cfa702e6fe2f875a2c674182fe2f86e8f613aa1e (diff) |
Merge remote-tracking branch 'origin/rolling'
Diffstat (limited to 'lua/lvim/plugin-loader.lua')
-rw-r--r-- | lua/lvim/plugin-loader.lua | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/lua/lvim/plugin-loader.lua b/lua/lvim/plugin-loader.lua index e42be52e..aa275da2 100644 --- a/lua/lvim/plugin-loader.lua +++ b/lua/lvim/plugin-loader.lua @@ -35,7 +35,7 @@ function plugin_loader.init(opts) init_opts.display = nil end - if vim.fn.empty(vim.fn.glob(install_path)) > 0 then + if not utils.is_directory(install_path) then vim.fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path } vim.cmd "packadd packer.nvim" -- IMPORTANT: we only set this the very first time to avoid constantly triggering the rollback function @@ -86,7 +86,7 @@ function plugin_loader.reload(configurations) end plugin_loader.load(configurations) - pcall_packer_command "sync" + plugin_loader.ensure_plugins() end function plugin_loader.load(configurations) @@ -140,8 +140,27 @@ function plugin_loader.sync_core_plugins() -- problem: rollback() will get stuck if a plugin directory doesn't exist -- solution: call sync() beforehand -- see https://github.com/wbthomason/packer.nvim/issues/862 - vim.cmd [[autocmd User PackerComplete ++once lua require("lvim.plugin-loader").load_snapshot() ]] + vim.api.nvim_create_autocmd("User", { + pattern = "PackerComplete", + once = true, + callback = function() + require("lvim.plugin-loader").load_snapshot(default_snapshot) + end, + }) pcall_packer_command "sync" end +function plugin_loader.ensure_plugins() + vim.api.nvim_create_autocmd("User", { + pattern = "PackerComplete", + once = true, + callback = function() + Log:debug "calling packer.clean()" + pcall_packer_command "clean" + end, + }) + Log:debug "calling packer.install()" + pcall_packer_command "install" +end + return plugin_loader |