plugins: More lazy load, yay

use vim.defer_fn to load the plugins after entering the ui

add the lazy load to setup

lazy load gitsigns, neoscroll, lspinstall and vim-matchup using this method

rearrange according to startup sequence
This commit is contained in:
Akianonymus 2021-08-26 15:10:26 +05:30 committed by siduck76
parent 66de975543
commit adf0168dcc
2 changed files with 66 additions and 46 deletions

View file

@ -310,4 +310,14 @@ end]]
return into
end
-- load plugin after entering vim ui
M.packer_lazy_load = function(plugin, timer)
if plugin then
timer = timer or 0
vim.defer_fn(function()
require("packer").loader(plugin)
end, timer)
end
end
return M

View file

@ -16,6 +16,10 @@ return packer.startup(function()
"Nvchad/extensions",
}
use {
"nvim-lua/plenary.nvim",
}
use {
"wbthomason/packer.nvim",
event = "VimEnter",
@ -49,7 +53,7 @@ return packer.startup(function()
use {
"akinsho/bufferline.nvim",
disable = not plugin_status.bufferline,
after = "feline.nvim",
after = "nvim-web-devicons",
config = function()
require "plugins.configs.bufferline"
end,
@ -58,34 +62,6 @@ return packer.startup(function()
end,
}
use {
"nvim-lua/plenary.nvim",
}
-- git stuff
use {
"lewis6991/gitsigns.nvim",
disable = not plugin_status.gitsigns,
cond = function()
return vim.fn.isdirectory ".git" == 1
end,
config = function()
require "plugins.configs.gitsigns"
end,
}
-- load autosave only if its globally enabled
use {
disable = not plugin_status.autosave,
"Pocco81/AutoSave.nvim",
config = function()
require "plugins.configs.autosave"
end,
cond = function()
return require("core.utils").load_config().options.plugin.autosave == true
end,
}
use {
"lukas-reineke/indent-blankline.nvim",
disable = not plugin_status.blankline,
@ -113,9 +89,38 @@ return packer.startup(function()
end,
}
-- git stuff
use {
"lewis6991/gitsigns.nvim",
disable = not plugin_status.gitsigns,
opt = true,
config = function()
require "plugins.configs.gitsigns"
end,
setup = function()
require("core.utils").packer_lazy_load "gitsigns.nvim"
end,
}
-- smooth scroll
use {
"karb94/neoscroll.nvim",
disable = not plugin_status.neoscroll,
opt = true,
config = function()
require("plugins.configs.others").neoscroll()
end,
setup = function()
require("core.utils").packer_lazy_load "neoscroll.nvim"
end,
}
use {
"kabouzeid/nvim-lspinstall",
event = "BufRead",
opt = true,
setup = function()
require("core.utils").packer_lazy_load "nvim-lspinstall"
end,
}
use {
@ -135,6 +140,27 @@ return packer.startup(function()
end,
}
use {
"andymass/vim-matchup",
disable = not plugin_status.vim_matchup,
opt = true,
setup = function()
require("core.utils").packer_lazy_load "vim-matchup"
end,
}
-- load autosave only if its globally enabled
use {
disable = not plugin_status.autosave,
"Pocco81/AutoSave.nvim",
config = function()
require "plugins.configs.autosave"
end,
cond = function()
return require("core.utils").load_config().options.plugin.autosave == true
end,
}
use {
"onsails/lspkind-nvim",
disable = not plugin_status.lspkind,
@ -189,22 +215,6 @@ return packer.startup(function()
end,
}
use {
"andymass/vim-matchup",
disable = not plugin_status.vim_matchup,
event = "CursorMoved",
}
-- smooth scroll
use {
"karb94/neoscroll.nvim",
disable = not plugin_status.neoscroll,
event = "WinScrolled",
config = function()
require("plugins.configs.others").neoscroll()
end,
}
use {
"glepnir/dashboard-nvim",
disable = not plugin_status.dashboard,