From a6b9c0cae5134ce7578160f69b46e0bf83e8988f Mon Sep 17 00:00:00 2001 From: siduck Date: Sun, 19 Feb 2023 07:19:01 +0530 Subject: [PATCH] wrap some opt modules with function not doing so will make those modules load by default which isnt good --- lua/core/bootstrap.lua | 3 ++- lua/plugins/configs/others.lua | 28 +++++++++++++--------------- lua/plugins/init.lua | 29 ++++++++++++++++++++--------- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/lua/core/bootstrap.lua b/lua/core/bootstrap.lua index bca43c3..26e0eb7 100644 --- a/lua/core/bootstrap.lua +++ b/lua/core/bootstrap.lua @@ -19,7 +19,8 @@ M.lazy = function(install_path) vim.fn.mkdir(vim.g.base46_cache, "p") require("base46").load_all_highlights() - require("lazy").load { plugins = "nvim-treesitter" } + + vim.cmd "silent! lua require('lazy').load { plugins = 'nvim-treesitter' }" -- install binaries from mason.nvim & tsparsers on LazySync vim.schedule(function() diff --git a/lua/plugins/configs/others.lua b/lua/plugins/configs/others.lua index b4bc6b7..0c1fffd 100644 --- a/lua/plugins/configs/others.lua +++ b/lua/plugins/configs/others.lua @@ -43,20 +43,18 @@ M.luasnip = function() }) end -M.gitsigns = function() - return { - signs = { - add = { hl = "DiffAdd", text = "│", numhl = "GitSignsAddNr" }, - change = { hl = "DiffChange", text = "│", numhl = "GitSignsChangeNr" }, - delete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" }, - topdelete = { hl = "DiffDelete", text = "‾", numhl = "GitSignsDeleteNr" }, - changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" }, - untracked = { hl = "GitSignsAdd", text = "│", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, - }, - on_attach = function(bufnr) - utils.load_mappings("gitsigns", { buffer = bufnr }) - end, - } -end +M.gitsigns = { + signs = { + add = { hl = "DiffAdd", text = "│", numhl = "GitSignsAddNr" }, + change = { hl = "DiffChange", text = "│", numhl = "GitSignsChangeNr" }, + delete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" }, + topdelete = { hl = "DiffDelete", text = "‾", numhl = "GitSignsDeleteNr" }, + changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" }, + untracked = { hl = "GitSignsAdd", text = "│", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, + }, + on_attach = function(bufnr) + utils.load_mappings("gitsigns", { buffer = bufnr }) + end, +} return M diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index c6f1c21..64a8493 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -20,7 +20,6 @@ local default_plugins = { { "NvChad/nvterm", init = require("core.utils").load_mappings "nvterm", - opts = {}, config = function(_, opts) require "base46.term" require("nvterm").setup(opts) @@ -30,8 +29,8 @@ local default_plugins = { { "NvChad/nvim-colorizer.lua", init = require("core.utils").lazy_load "nvim-colorizer.lua", - config = function() - require("colorizer").setup() + config = function(_, opts) + require("colorizer").setup(opts) -- execute colorizer as soon as possible vim.defer_fn(function() @@ -57,7 +56,9 @@ local default_plugins = { require("core.utils").lazy_load "indent-blankline.nvim" require("core.utils").load_mappings "blankline" end, - opts = require("plugins.configs.others").blankline, + opts = function() + return require("plugins.configs.others").blankline + end, config = function(_, opts) dofile(vim.g.base46_cache .. "blankline") require("indent_blankline").setup(opts) @@ -69,7 +70,9 @@ local default_plugins = { init = require("core.utils").lazy_load "nvim-treesitter", cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, build = ":TSUpdate", - opts = require "plugins.configs.treesitter", + opts = function() + return require "plugins.configs.treesitter" + end, config = function(_, opts) dofile(vim.g.base46_cache .. "syntax") require("nvim-treesitter.configs").setup(opts) @@ -95,7 +98,9 @@ local default_plugins = { end, }) end, - opts = require("plugins.configs.others").gitsigns, + opts = function() + return require("plugins.configs.others").gitsigns + end, config = function(_, opts) dofile(vim.g.base46_cache .. "git") require("gitsigns").setup(opts) @@ -106,7 +111,9 @@ local default_plugins = { { "williamboman/mason.nvim", cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" }, - opts = require "plugins.configs.mason", + opts = function() + return require "plugins.configs.mason" + end, config = function(_, opts) dofile(vim.g.base46_cache .. "mason") require("mason").setup(opts) @@ -188,7 +195,9 @@ local default_plugins = { "nvim-tree/nvim-tree.lua", cmd = { "NvimTreeToggle", "NvimTreeFocus" }, init = require("core.utils").load_mappings "nvimtree", - opts = require "plugins.configs.nvimtree", + opts = function() + return require "plugins.configs.nvimtree" + end, config = function(_, opts) dofile(vim.g.base46_cache .. "nvimtree") require("nvim-tree").setup(opts) @@ -222,7 +231,9 @@ local default_plugins = { enabled = false, keys = { "", '"', "'", "`" }, init = require("core.utils").load_mappings "whichkey", - opts = require "plugins.configs.whichkey", + opts = function() + return require "plugins.configs.whichkey" + end, config = function(_, opts) dofile(vim.g.base46_cache .. "whichkey") require("which-key").setup(opts)