diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-10-05 08:46:35 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-10-05 08:46:35 +0200 |
commit | 77cdf208765ad351e48724ed5ad57e55703eca61 (patch) | |
tree | 7f19757b255ab66895d9240a5aca77a35cef8aac /.config/nvim/lua/plugin-loader.lua | |
parent | 4fd170aa9d55b7bcd1f0a9445c9e136b560e3220 (diff) |
Add major update to LSP from lunarvim
Diffstat (limited to '.config/nvim/lua/plugin-loader.lua')
-rw-r--r-- | .config/nvim/lua/plugin-loader.lua | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/.config/nvim/lua/plugin-loader.lua b/.config/nvim/lua/plugin-loader.lua index fed4995..f2c1dad 100644 --- a/.config/nvim/lua/plugin-loader.lua +++ b/.config/nvim/lua/plugin-loader.lua @@ -1,11 +1,23 @@ local plugin_loader = {} -function plugin_loader:init() - local install_path = "~/.local/share/nvim/site/pack/packer/start/packer.nvim" +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" + 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, } @@ -17,15 +29,13 @@ function plugin_loader:init() return end - local util = require "packer.util" - packer.init { - package_root = util.join_paths "~/.local/share/nvim/site/pack/", - compile_path = util.join_paths("~/.config/nvim", "plugin", "packer_compiled.lua"), + package_root = package_root, + compile_path = compile_path, git = { clone_timeout = 300 }, display = { open_fn = function() - return util.float { border = "rounded" } + return require("packer.util").float { border = "rounded" } end, }, } @@ -34,6 +44,20 @@ function plugin_loader:init() 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 @@ -44,8 +68,4 @@ function plugin_loader:load(configurations) end) end -return { - init = function() - return plugin_loader:init() - end, -} +return plugin_loader |