move plugin override function to utils | increase packer clone timeout
This commit is contained in:
parent
b4c50fa443
commit
a256591e90
3 changed files with 30 additions and 35 deletions
|
@ -356,4 +356,27 @@ M.fg_bg = function(group, fgcol, bgcol)
|
||||||
cmd("hi " .. group .. " guifg=" .. fgcol .. " guibg=" .. bgcol)
|
cmd("hi " .. group .. " guifg=" .. fgcol .. " guibg=" .. bgcol)
|
||||||
end
|
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
|
return M
|
||||||
|
|
|
@ -8,38 +8,13 @@ local use = packer.use
|
||||||
|
|
||||||
return packer.startup(function()
|
return packer.startup(function()
|
||||||
local plugin_settings = require("core.utils").load_config().plugins
|
local plugin_settings = require("core.utils").load_config().plugins
|
||||||
|
local override_req = require("core.utils").override_req
|
||||||
-- 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
|
|
||||||
|
|
||||||
-- this is arranged on the basis of when a plugin starts
|
-- 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
|
-- this is the nvchad core repo containing utilities for some features like theme swticher, no need to lazy load
|
||||||
use {
|
use "Nvchad/extensions"
|
||||||
"Nvchad/extensions",
|
use "nvim-lua/plenary.nvim"
|
||||||
}
|
|
||||||
|
|
||||||
use {
|
|
||||||
"nvim-lua/plenary.nvim",
|
|
||||||
}
|
|
||||||
|
|
||||||
use {
|
use {
|
||||||
"wbthomason/packer.nvim",
|
"wbthomason/packer.nvim",
|
||||||
|
@ -259,6 +234,6 @@ return packer.startup(function()
|
||||||
require("core.mappings").telescope()
|
require("core.mappings").telescope()
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
-- load user defined plugins
|
||||||
require("core.hooks").run("install_plugins", use)
|
require("core.hooks").run("install_plugins", use)
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
local cmd = vim.cmd
|
vim.cmd "packadd packer.nvim"
|
||||||
|
|
||||||
cmd "packadd packer.nvim"
|
|
||||||
|
|
||||||
local present, packer = pcall(require, "packer")
|
local present, packer = pcall(require, "packer")
|
||||||
|
|
||||||
|
@ -19,7 +17,7 @@ if not present then
|
||||||
packer_path,
|
packer_path,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd "packadd packer.nvim"
|
vim.cmd "packadd packer.nvim"
|
||||||
present, packer = pcall(require, "packer")
|
present, packer = pcall(require, "packer")
|
||||||
|
|
||||||
if present then
|
if present then
|
||||||
|
@ -37,11 +35,10 @@ packer.init {
|
||||||
prompt_border = "single",
|
prompt_border = "single",
|
||||||
},
|
},
|
||||||
git = {
|
git = {
|
||||||
clone_timeout = 600, -- Timeout, in seconds, for git clones
|
clone_timeout = 6000, -- seconds
|
||||||
},
|
},
|
||||||
auto_clean = true,
|
auto_clean = true,
|
||||||
compile_on_sync = true,
|
compile_on_sync = true,
|
||||||
-- auto_reload_compiled = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return packer
|
return packer
|
||||||
|
|
Loading…
Reference in a new issue