From b51f1ae28924a752258e7607fbc3210f9b18eaac Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Thu, 22 Jul 2021 00:08:36 +0200 Subject: Updates based on Chris's lunarvim --- .config/nvim/lua/plugin-loader.lua | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .config/nvim/lua/plugin-loader.lua (limited to '.config/nvim/lua/plugin-loader.lua') diff --git a/.config/nvim/lua/plugin-loader.lua b/.config/nvim/lua/plugin-loader.lua new file mode 100644 index 0000000..4cf72c8 --- /dev/null +++ b/.config/nvim/lua/plugin-loader.lua @@ -0,0 +1,49 @@ +local plugin_loader = {} + +function plugin_loader:init() + local execute = vim.api.nvim_command + local fn = vim.fn + + local install_path = "~/.local/share/nvim/site/pack/packer/start/packer.nvim" + if fn.empty(fn.glob(install_path)) > 0 then + execute("!git clone https://github.com/wbthomason/packer.nvim " .. install_path) + execute "packadd packer.nvim" + end + + local packer_ok, packer = pcall(require, "packer") + if not packer_ok then + 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"), + git = { clone_timeout = 300 }, + display = { + open_fn = function() + return util.float { border = "single" } + end, + }, + } + + self.packer = packer + return self +end + +function plugin_loader:load(configurations) + return self.packer.startup(function(use) + for _, plugins in ipairs(configurations) do + for _, plugin in ipairs(plugins) do + use(plugin) + end + end + end) +end + +return { + init = function() + return plugin_loader:init() + end, +} -- cgit v1.2.3-70-g09d2