refactor: use more flexible paths (#1381)

This commit is contained in:
kylo252 2021-09-13 11:28:15 +02:00 committed by GitHub
parent 38b0c3d860
commit 8eed75d67f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 216 additions and 153 deletions

View file

@ -1,9 +1,13 @@
local plugin_loader = {}
function plugin_loader:init()
local install_path = "~/.local/share/lunarvim/site/pack/packer/start/packer.nvim"
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.fn.system { "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path }
function plugin_loader:init(opts)
opts = opts or {}
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(package_root)) > 0 then
vim.fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", package_root }
vim.cmd "packadd packer.nvim"
end
@ -12,15 +16,13 @@ function plugin_loader:init()
return
end
local util = require "packer.util"
packer.init {
package_root = util.join_paths "~/.local/share/lunarvim/site/pack/",
compile_path = util.join_paths("~/.config/lvim", "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,
},
}
@ -39,8 +41,4 @@ function plugin_loader:load(configurations)
end)
end
return {
init = function()
return plugin_loader:init()
end,
}
return plugin_loader