From 1c983b2dce235f9459498cef69367da38ab96b9e Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 8 Dec 2022 13:30:20 +0100 Subject: [PATCH] nvim: Fix automatic packer installation Updated to new recommended bootstrapping for packer itself, straight from the project respository. --- nvim/.config/nvim/lua/plugins.lua | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index c2990d4..bee0e73 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -1,10 +1,16 @@ -local install_path = vim.fn.stdpath("data") .. "/pack/packer/start/packer.nvim" - -if vim.fn.empty(vim.fn.glob(install_path)) > 0 then - vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. - install_path) +local ensure_packer = function() + 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', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path }) + vim.cmd [[packadd packer.nvim]] + return true + end + return false end +local packer_bootstrap = ensure_packer() + -- Compile on plugin edits vim.api.nvim_create_autocmd({ "BufWritePost" }, { pattern = "plugins.lua", @@ -233,4 +239,9 @@ require("packer").startup(function() } require('plug._cmp') + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if packer_bootstrap then + require('packer').sync() + end end)