[nvim] feat: packer boostrapping on first install

This commit is contained in:
David JULIEN 2022-04-27 20:05:27 +02:00
parent 4e95af5b7a
commit 98b6a428a7
1 changed files with 19 additions and 8 deletions

View File

@ -4,14 +4,19 @@
-- Description : neovim plugins file
local execute = vim.api.nvim_command
local fn = vim.fn
local install_path = fn.stdpath("data").."/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({"git", "clone", "https://github.com/wbthomason/packer.nvim", install_path})
execute "packadd packer.nvim"
local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
print("Cloning packer...")
PACKER_BOOTSTRAP = vim.fn.system({
"git",
"clone",
"--depth",
"1",
"https://github.com/wbthomason/packer.nvim",
install_path,
})
vim.cmd([[packadd packer.nvim]])
print("Done.")
end
return require("packer").startup(function()
@ -102,4 +107,10 @@ return require("packer").startup(function()
"norcalli/nvim-colorizer.lua",
cmd = "ColorizerToggle"
}
-- automatically setup the config after cloning
if PACKER_BOOTSTRAP then
require("packer").sync()
end
end)