diff --git a/lua/core/utils.lua b/lua/core/utils.lua index d7fa99b..d3e0df5 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -356,4 +356,27 @@ M.fg_bg = function(group, fgcol, bgcol) cmd("hi " .. group .. " guifg=" .. fgcol .. " guibg=" .. bgcol) end +-- Override default config of a plugin based on the path provided in the chadrc + +-- FUNCTION: override_req, use `chadrc` plugin config override if present +-- name = name inside `default_config` / `chadrc` +-- default_req = run this if 'name' does not exist in `default_config` / `chadrc` +-- if override or default_req start with `(`, then strip that and assume override calls a function, not a whole file +M.override_req = function(name, default_req) + local override = require("core.utils").load_config().plugins.default_plugin_config_replace[name] + local result = default_req + + if override ~= nil then + result = override + end + + if string.match(result, "^%(") then + result = result:sub(2) + result = result:gsub("%)%.", "').", 1) + return "require('" .. result + else + return "require('" .. result .. "')" + end +end + return M diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 078233d..39a3c14 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -8,38 +8,13 @@ local use = packer.use return packer.startup(function() local plugin_settings = require("core.utils").load_config().plugins - - -- FUNCTION: override_req, use `chadrc` plugin config override if present - -- name = name inside `default_config` / `chadrc` - -- default_req = run this if 'name' does not exist in `default_config` / `chadrc` - -- if override or default_req start with `(`, then strip that and assume override calls a function, not a whole file - local override_req = function(name, default_req) - local override = require("core.utils").load_config().plugins.default_plugin_config_replace[name] - local result = default_req - - if override ~= nil then - result = override - end - - if string.match(result, "^%(") then - result = result:sub(2) - result = result:gsub("%)%.", "').", 1) - return "require('" .. result - else - return "require('" .. result .. "')" - end - end + local override_req = require("core.utils").override_req -- this is arranged on the basis of when a plugin starts -- this is the nvchad core repo containing utilities for some features like theme swticher, no need to lazy load - use { - "Nvchad/extensions", - } - - use { - "nvim-lua/plenary.nvim", - } + use "Nvchad/extensions" + use "nvim-lua/plenary.nvim" use { "wbthomason/packer.nvim", @@ -259,6 +234,6 @@ return packer.startup(function() require("core.mappings").telescope() end, } - + -- load user defined plugins require("core.hooks").run("install_plugins", use) end) diff --git a/lua/plugins/packerInit.lua b/lua/plugins/packerInit.lua index 964ff59..cafdd4f 100644 --- a/lua/plugins/packerInit.lua +++ b/lua/plugins/packerInit.lua @@ -1,6 +1,4 @@ -local cmd = vim.cmd - -cmd "packadd packer.nvim" +vim.cmd "packadd packer.nvim" local present, packer = pcall(require, "packer") @@ -19,7 +17,7 @@ if not present then packer_path, } - cmd "packadd packer.nvim" + vim.cmd "packadd packer.nvim" present, packer = pcall(require, "packer") if present then @@ -37,11 +35,10 @@ packer.init { prompt_border = "single", }, git = { - clone_timeout = 600, -- Timeout, in seconds, for git clones + clone_timeout = 6000, -- seconds }, auto_clean = true, compile_on_sync = true, - -- auto_reload_compiled = true } return packer