diff options
author | Bobby Bingham <koorogi@koorogi.info> | 2023-04-30 18:15:18 -0500 |
---|---|---|
committer | Bobby Bingham <koorogi@koorogi.info> | 2023-04-30 18:15:18 -0500 |
commit | f9ea9ae5b35e4e7118f1d8f5bf9ef833fd87073a (patch) | |
tree | 7f079af2a82278ae91820e918b986d3bdb876bca | |
parent | d853482e86c1bf50da39c134eefad4ddbe9448bd (diff) |
nvim: auto-install packer
-rw-r--r-- | nvim/.config/nvim/lua/plugins.lua | 21 |
1 files changed, 18 insertions, 3 deletions
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 |