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:
parent
66de975543
commit
adf0168dcc
2 changed files with 66 additions and 46 deletions
|
@ -310,4 +310,14 @@ end]]
|
||||||
return into
|
return into
|
||||||
end
|
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
|
return M
|
||||||
|
|
|
@ -16,6 +16,10 @@ return packer.startup(function()
|
||||||
"Nvchad/extensions",
|
"Nvchad/extensions",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use {
|
||||||
|
"nvim-lua/plenary.nvim",
|
||||||
|
}
|
||||||
|
|
||||||
use {
|
use {
|
||||||
"wbthomason/packer.nvim",
|
"wbthomason/packer.nvim",
|
||||||
event = "VimEnter",
|
event = "VimEnter",
|
||||||
|
@ -49,7 +53,7 @@ return packer.startup(function()
|
||||||
use {
|
use {
|
||||||
"akinsho/bufferline.nvim",
|
"akinsho/bufferline.nvim",
|
||||||
disable = not plugin_status.bufferline,
|
disable = not plugin_status.bufferline,
|
||||||
after = "feline.nvim",
|
after = "nvim-web-devicons",
|
||||||
config = function()
|
config = function()
|
||||||
require "plugins.configs.bufferline"
|
require "plugins.configs.bufferline"
|
||||||
end,
|
end,
|
||||||
|
@ -58,34 +62,6 @@ return packer.startup(function()
|
||||||
end,
|
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 {
|
use {
|
||||||
"lukas-reineke/indent-blankline.nvim",
|
"lukas-reineke/indent-blankline.nvim",
|
||||||
disable = not plugin_status.blankline,
|
disable = not plugin_status.blankline,
|
||||||
|
@ -113,9 +89,38 @@ return packer.startup(function()
|
||||||
end,
|
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 {
|
use {
|
||||||
"kabouzeid/nvim-lspinstall",
|
"kabouzeid/nvim-lspinstall",
|
||||||
event = "BufRead",
|
opt = true,
|
||||||
|
setup = function()
|
||||||
|
require("core.utils").packer_lazy_load "nvim-lspinstall"
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
use {
|
use {
|
||||||
|
@ -135,6 +140,27 @@ return packer.startup(function()
|
||||||
end,
|
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 {
|
use {
|
||||||
"onsails/lspkind-nvim",
|
"onsails/lspkind-nvim",
|
||||||
disable = not plugin_status.lspkind,
|
disable = not plugin_status.lspkind,
|
||||||
|
@ -189,22 +215,6 @@ return packer.startup(function()
|
||||||
end,
|
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 {
|
use {
|
||||||
"glepnir/dashboard-nvim",
|
"glepnir/dashboard-nvim",
|
||||||
disable = not plugin_status.dashboard,
|
disable = not plugin_status.dashboard,
|
||||||
|
|
Loading…
Reference in a new issue