From f9ea9ae5b35e4e7118f1d8f5bf9ef833fd87073a Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Sun, 30 Apr 2023 18:15:18 -0500 Subject: nvim: auto-install packer --- nvim/.config/nvim/lua/plugins.lua | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'nvim') diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 6b93345..a60c9de 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -1,7 +1,18 @@ -- This file can be loaded by calling `lua require('plugins')` from your init.vim --- Only required if you have packer configured as `opt` -vim.cmd [[packadd packer.nvim]] +-- ensure packer is installed +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() -- Recompile packer config after editing this file vim.cmd([[ @@ -11,7 +22,7 @@ vim.cmd([[ augroup end ]]) -return require('packer').startup(function() +require('packer').startup(function() -- Packer can manage itself use 'wbthomason/packer.nvim' @@ -105,3 +116,7 @@ return require('packer').startup(function() } end) +-- the first run will install package and our plugins +if packer_bootstrap then + require("packer").sync() +end -- cgit v1.2.3