perf: lazy load most plugins (#3750)

* perf: lazy load most plugins

* fix(lazy): suggested fixes for pref/lazyloading branch (#3754)

fix(lazy): Suggested fixes from previous comments

fix(lazy): applying suggestions from code review

Co-authored-by: LostNeophyte <lostneophyte@tuta.io>

Co-authored-by: Pratyush Bharati <pbharati@Pratyushs-MacBook-Pro.local>
Co-authored-by: LostNeophyte <lostneophyte@tuta.io>

* chore: format

* move lazy utils to modules.lua

* simplify telescope actions

* refactor: cmp_window local name

* feat: more lazy loading cmds

* refactor(cmp): minor clean up

* perf: set lazy loading by default

* refactor(alpha): remove broken lazy load

* revert: explictily set lazy loading

This reverts commit ba38193e4e.

* test: enable lazy-loading for bigfile

* perf: defer projects and alpha to VimEnter

* refactor(bufferline): add comment

* perf: better lazy load dap/dapui

* perf: lazy load ts-commentstring with Comment.nvim pre_hook

---------

Co-authored-by: pr-313 <46706232+pr-313@users.noreply.github.com>
Co-authored-by: Pratyush Bharati <pbharati@Pratyushs-MacBook-Pro.local>
Co-authored-by: opalmay <opal.mizrahi2@gmail.com>
Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com>
This commit is contained in:
LostNeophyte 2023-02-04 16:22:41 +01:00 committed by GitHub
parent c18cd3f0a8
commit 60c7ad77fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 172 additions and 89 deletions

View file

@ -6,25 +6,34 @@ local core_plugins = {
lazy = true,
dependencies = { "mason-lspconfig.nvim", "nlsp-settings.nvim" },
},
{ "williamboman/mason-lspconfig.nvim", lazy = true },
{ "tamago324/nlsp-settings.nvim", lazy = true },
{
"williamboman/mason-lspconfig.nvim",
cmd = { "LspInstall", "LspUninstall" },
lazy = true,
dependencies = "mason.nvim",
},
{ "tamago324/nlsp-settings.nvim", cmd = "LspSettings", lazy = true },
{ "jose-elias-alvarez/null-ls.nvim", lazy = true },
{
"williamboman/mason.nvim",
config = function()
require("lvim.core.mason").setup()
end,
cmd = { "Mason", "MasonInstall", "MasonUninstall", "MasonUninstallAll", "MasonLog" },
lazy = true,
},
{
"folke/tokyonight.nvim",
lazy = not vim.startswith(lvim.colorscheme, "tokyonight"),
},
{
"lunarvim/lunar.nvim",
lazy = lvim.colorscheme ~= "lunar",
},
{ "Tastyep/structlog.nvim" },
{ "Tastyep/structlog.nvim", lazy = true },
{ "nvim-lua/popup.nvim" },
{ "nvim-lua/plenary.nvim" },
{ "nvim-lua/popup.nvim", lazy = true },
{ "nvim-lua/plenary.nvim", cmd = { "PlenaryBustedFile", "PlenaryBustedDirectory" }, lazy = true },
-- Telescope
{
"nvim-telescope/telescope.nvim",
@ -113,21 +122,24 @@ local core_plugins = {
vim.opt.rtp:prepend(path) -- treesitter needs to be before nvim's runtime in rtp
require("lvim.core.treesitter").setup()
end,
cmd = { "TSInstall", "TSUninstall", "TSUpdate", "TSInstallInfo", "TSInstallSync", "TSInstallFromGrammar" },
event = "User FileOpened",
},
{
-- Lazy loaded by Comment.nvim pre_hook
"JoosepAlviste/nvim-ts-context-commentstring",
event = "VeryLazy",
lazy = true,
},
-- NvimTree
{
"kyazdani42/nvim-tree.lua",
-- event = "BufWinOpen",
-- cmd = "NvimTreeToggle",
config = function()
require("lvim.core.nvimtree").setup()
end,
enabled = lvim.builtin.nvimtree.active,
cmd = { "NvimTreeToggle", "NvimTreeOpen", "NvimTreeFocus", "NvimTreeFindFileToggle" },
event = "User DirOpened",
},
-- Lir
{
@ -136,13 +148,15 @@ local core_plugins = {
require("lvim.core.lir").setup()
end,
enabled = lvim.builtin.lir.active,
event = "User DirOpened",
},
{
"lewis6991/gitsigns.nvim",
config = function()
require("lvim.core.gitsigns").setup()
end,
event = "BufRead",
event = "User FileOpened",
cmd = "Gitsigns",
enabled = lvim.builtin.gitsigns.active,
},
@ -152,6 +166,7 @@ local core_plugins = {
config = function()
require("lvim.core.which-key").setup()
end,
cmd = "WhichKey",
event = "VeryLazy",
enabled = lvim.builtin.which_key.active,
},
@ -159,10 +174,11 @@ local core_plugins = {
-- Comments
{
"numToStr/Comment.nvim",
event = "BufRead",
config = function()
require("lvim.core.comment").setup()
end,
keys = { { "gc", mode = { "n", "v" } }, { "gb", mode = { "n", "v" } } },
event = "User FileOpened",
enabled = lvim.builtin.comment.active,
},
@ -173,12 +189,15 @@ local core_plugins = {
require("lvim.core.project").setup()
end,
enabled = lvim.builtin.project.active,
event = "VimEnter",
cmd = "Telescope projects",
},
-- Icons
{
"nvim-tree/nvim-web-devicons",
enabled = lvim.use_icons,
lazy = true,
},
-- Status Line and Bufferline
@ -189,6 +208,7 @@ local core_plugins = {
config = function()
require("lvim.core.lualine").setup()
end,
event = "VimEnter",
enabled = lvim.builtin.lualine.active,
},
@ -198,6 +218,7 @@ local core_plugins = {
config = function()
require("lvim.core.breadcrumbs").setup()
end,
event = "User FileOpened",
enabled = lvim.builtin.breadcrumbs.active,
},
@ -207,16 +228,17 @@ local core_plugins = {
require("lvim.core.bufferline").setup()
end,
branch = "main",
event = "User FileOpened",
enabled = lvim.builtin.bufferline.active,
},
-- Debugging
{
"mfussenegger/nvim-dap",
-- event = "BufWinEnter",
config = function()
require("lvim.core.dap").setup()
end,
lazy = true,
enabled = lvim.builtin.dap.active,
},
@ -226,6 +248,7 @@ local core_plugins = {
config = function()
require("lvim.core.dap").setup_ui()
end,
lazy = true,
enabled = lvim.builtin.dap.active,
},
@ -236,6 +259,7 @@ local core_plugins = {
require("lvim.core.alpha").setup()
end,
enabled = lvim.builtin.alpha.active,
event = "VimEnter",
},
-- Terminal
@ -260,7 +284,7 @@ local core_plugins = {
config = function()
require("lvim.core.illuminate").setup()
end,
event = "VeryLazy",
event = "User FileOpened",
enabled = lvim.builtin.illuminate.active,
},
@ -269,6 +293,7 @@ local core_plugins = {
config = function()
require("lvim.core.indentlines").setup()
end,
event = "User FileOpened",
enabled = lvim.builtin.indentlines.active,
},
@ -283,7 +308,7 @@ local core_plugins = {
end
end)
end,
enabled = lvim.colorscheme == "onedarker",
lazy = lvim.colorscheme ~= "onedarker",
},
{
@ -294,6 +319,7 @@ local core_plugins = {
end)
end,
enabled = lvim.builtin.bigfile.active,
event = { "FileReadPre", "BufReadPre", "User FileOpened" },
},
}