From 92eb5ca7404081e916b2f58ba15450a5a4870440 Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Fri, 23 Jul 2021 20:41:09 +0530 Subject: [PATCH] Do not load packer on startup Actually saved some milliseconds, can be observed in benchmarks too from packer readme ``` To optimize startup time, packer.nvim compiles code to perform the lazy-loading operations you specify. This means that you do not need to load packer.nvim unless you want to perform some plugin management operations. ``` Add packer commands manually to mappings.lua, but with basic functionalty By this, we don't losr the packer commands and don't even load at startup After some command is actually executed, it will load the PackerCommands as they were --- init.lua | 1 - lua/mappings.lua | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 0e533cc..49bc3ed 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,5 @@ local chad_modules = { "options", - "pluginList", "mappings", "utils" } diff --git a/lua/mappings.lua b/lua/mappings.lua index 0ff8a87..c59592f 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -146,3 +146,10 @@ map("n", "", ":noh", opt) -- get out of terminal with jk map("t", "jk", "", opt) + +-- Packer commands till because we are not loading it at startup +vim.cmd("silent! command PackerCompile lua require 'pluginList' require('packer').compile()") +vim.cmd("silent! command PackerInstall lua require 'pluginList' require('packer').install()") +vim.cmd("silent! command PackerStatus lua require 'pluginList' require('packer').status()") +vim.cmd("silent! command PackerSync lua require 'pluginList' require('packer').sync()") +vim.cmd("silent! command PackerUpdate lua require 'pluginList' require('packer').update()")