summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugin-loader.lua
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2022-01-13 19:12:32 +0100
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2022-01-13 19:12:32 +0100
commit73a60f5ee71bb60265ec0c97be7531a5e7605d8c (patch)
treed46283a3d04285c5a5ead92d5bbb3b1fe424b736 /.config/nvim/lua/plugin-loader.lua
parent19c1942757f07387b95db3ddbc39d9b561d5b51d (diff)
Remove bloat nvim config
Diffstat (limited to '.config/nvim/lua/plugin-loader.lua')
-rw-r--r--.config/nvim/lua/plugin-loader.lua110
1 files changed, 0 insertions, 110 deletions
diff --git a/.config/nvim/lua/plugin-loader.lua b/.config/nvim/lua/plugin-loader.lua
deleted file mode 100644
index 9c83e46..0000000
--- a/.config/nvim/lua/plugin-loader.lua
+++ /dev/null
@@ -1,110 +0,0 @@
-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"
-
- 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,
- }
- vim.cmd "packadd packer.nvim"
- end
-
- if options.log and options.log.level then
- log_level = options.log.level
- end
-
- local _, packer = pcall(require, "packer")
- packer.init {
- package_root = package_root,
- compile_path = compile_path,
- log = { level = log_level },
- git = { clone_timeout = 300 },
- max_jobs = 50,
- display = {
- open_fn = function()
- return require("packer.util").float { border = "rounded" }
- end,
- },
- }
-end
-
--- packer expects a space separated list
-local function pcall_packer_command(cmd, kwargs)
- local status_ok, msg = pcall(function()
- require("packer")[cmd](unpack(kwargs or {}))
- end)
- if not status_ok then
- Log:warn(cmd .. " failed with: " .. vim.inspect(msg))
- Log:trace(vim.inspect(vim.fn.eval "v:errmsg"))
- end
-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.recompile()
- plugin_loader.cache_clear()
- pcall_packer_command "compile"
- if utils.is_file(compile_path) then
- Log:debug "generated packer_compiled.lua"
- end
-end
-
-function plugin_loader.load(configurations)
- Log:debug "loading plugins configuration"
- local packer_available, packer = pcall(require, "packer")
- if not packer_available then
- Log:warn "skipping loading plugins until Packer is installed"
- return
- end
- local status_ok, _ = xpcall(function()
- packer.startup(function(use)
- for _, plugins in ipairs(configurations) do
- for _, plugin in ipairs(plugins) do
- use(plugin)
- end
- end
- end)
- end, debug.traceback)
- if not status_ok then
- Log:warn "problems detected while loading plugins' configurations"
- Log:trace(debug.traceback())
- end
-end
-
-function plugin_loader.get_core_plugins()
- local list = {}
- local plugins = require "plugins"
- for _, item in pairs(plugins) do
- table.insert(list, item[1]:match "/(%S*)")
- end
- return list
-end
-
-function plugin_loader.sync_core_plugins()
- local core_plugins = plugin_loader.get_core_plugins()
- Log:trace(
- string.format("Syncing core plugins: [%q]", table.concat(core_plugins, ", "))
- )
- pcall_packer_command("sync", core_plugins)
-end
-
-return plugin_loader