feat: allow packaged plugin config overrides within chadrc
This commit is contained in:
parent
a5a5a8220c
commit
80c8bf4243
@ -10,6 +10,17 @@ M.ui, M.options, M.plugin_status, M.mappings, M.custom = {}, {}, {}, {}, {}
|
|||||||
-- relativenumber = true,
|
-- relativenumber = true,
|
||||||
-- }
|
-- }
|
||||||
|
|
||||||
|
|
||||||
|
-- To change the Packer `config` of a plugin that comes with NvChad,
|
||||||
|
-- add a table entry below matching the plugin github name
|
||||||
|
-- '-' -> '_', remove any '.lua', '.nvim' extensions
|
||||||
|
-- this string will be called in a `require`
|
||||||
|
-- use "(custom.configs).my_func()" to call a function
|
||||||
|
-- use "custom.blankline" to call a file
|
||||||
|
M.custom.default_plugin_overrides = {
|
||||||
|
-- indent_blankline = "custom.blankline",
|
||||||
|
}
|
||||||
|
|
||||||
-- user custom mappings
|
-- user custom mappings
|
||||||
-- e.g: name = { "mode" , "keys" , "cmd" , "options"}
|
-- e.g: name = { "mode" , "keys" , "cmd" , "options"}
|
||||||
-- name: can be empty or something unique with repect to other custom mappings
|
-- name: can be empty or something unique with repect to other custom mappings
|
||||||
|
@ -9,6 +9,31 @@ local use = packer.use
|
|||||||
return packer.startup(function()
|
return packer.startup(function()
|
||||||
local plugin_status = require("core.utils").load_config().plugin_status
|
local plugin_status = require("core.utils").load_config().plugin_status
|
||||||
|
|
||||||
|
-- local plugin_overrides = require("core.utils").load_config().custom.plugin_overrides
|
||||||
|
|
||||||
|
-- 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().custom.default_plugin_overrides[name]
|
||||||
|
local result
|
||||||
|
|
||||||
|
if override == nil then
|
||||||
|
result = default_req
|
||||||
|
else
|
||||||
|
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
|
||||||
@ -36,57 +61,46 @@ return packer.startup(function()
|
|||||||
use {
|
use {
|
||||||
"kyazdani42/nvim-web-devicons",
|
"kyazdani42/nvim-web-devicons",
|
||||||
after = "nvim-base16.lua",
|
after = "nvim-base16.lua",
|
||||||
config = function()
|
config = override_req("nvim_web_devicons", "plugins.configs.icons"),
|
||||||
require "plugins.configs.icons"
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use {
|
use {
|
||||||
"famiu/feline.nvim",
|
"famiu/feline.nvim",
|
||||||
disable = not plugin_status.feline,
|
disable = not plugin_status.feline,
|
||||||
after = "nvim-web-devicons",
|
after = "nvim-web-devicons",
|
||||||
config = function()
|
config = override_req("feline", "plugins.configs.statusline"),
|
||||||
require "plugins.configs.statusline"
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use {
|
use {
|
||||||
"akinsho/bufferline.nvim",
|
"akinsho/bufferline.nvim",
|
||||||
disable = not plugin_status.bufferline,
|
disable = not plugin_status.bufferline,
|
||||||
after = "nvim-web-devicons",
|
after = "nvim-web-devicons",
|
||||||
config = function()
|
config = override_req("bufferline", "plugins.configs.bufferline"),
|
||||||
require "plugins.configs.bufferline"
|
|
||||||
end,
|
|
||||||
setup = function()
|
setup = function()
|
||||||
require("core.mappings").bufferline()
|
require("core.mappings").bufferline()
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
use {
|
use {
|
||||||
"lukas-reineke/indent-blankline.nvim",
|
"lukas-reineke/indent-blankline.nvim",
|
||||||
disable = not plugin_status.blankline,
|
disable = not plugin_status.blankline,
|
||||||
event = "BufRead",
|
event = "BufRead",
|
||||||
config = function()
|
config = override_req("indent_blankline", "(plugins.configs.others).blankline()"),
|
||||||
require("plugins.configs.others").blankline()
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use {
|
use {
|
||||||
"norcalli/nvim-colorizer.lua",
|
"norcalli/nvim-colorizer.lua",
|
||||||
disable = not plugin_status.colorizer,
|
disable = not plugin_status.colorizer,
|
||||||
event = "BufRead",
|
event = "BufRead",
|
||||||
config = function()
|
config = override_req("nvim_colorizer", "(plugins.configs.others).colorizer()"),
|
||||||
require("plugins.configs.others").colorizer()
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use {
|
use {
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
branch = "0.5-compat",
|
branch = "0.5-compat",
|
||||||
event = "BufRead",
|
event = "BufRead",
|
||||||
config = function()
|
config = override_req("nvim_treesitter", "plugins.configs.treesitter"),
|
||||||
require "plugins.configs.treesitter"
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- git stuff
|
-- git stuff
|
||||||
@ -94,9 +108,7 @@ return packer.startup(function()
|
|||||||
"lewis6991/gitsigns.nvim",
|
"lewis6991/gitsigns.nvim",
|
||||||
disable = not plugin_status.gitsigns,
|
disable = not plugin_status.gitsigns,
|
||||||
opt = true,
|
opt = true,
|
||||||
config = function()
|
config = override_req("gitsigns", "plugins.configs.gitsigns"),
|
||||||
require "plugins.configs.gitsigns"
|
|
||||||
end,
|
|
||||||
setup = function()
|
setup = function()
|
||||||
require("core.utils").packer_lazy_load "gitsigns.nvim"
|
require("core.utils").packer_lazy_load "gitsigns.nvim"
|
||||||
end,
|
end,
|
||||||
@ -107,9 +119,7 @@ return packer.startup(function()
|
|||||||
"karb94/neoscroll.nvim",
|
"karb94/neoscroll.nvim",
|
||||||
disable = not plugin_status.neoscroll,
|
disable = not plugin_status.neoscroll,
|
||||||
opt = true,
|
opt = true,
|
||||||
config = function()
|
config = override_req("neoscroll", "(plugins.configs.others).neoscroll()"),
|
||||||
require("plugins.configs.others").neoscroll()
|
|
||||||
end,
|
|
||||||
setup = function()
|
setup = function()
|
||||||
require("core.utils").packer_lazy_load "neoscroll.nvim"
|
require("core.utils").packer_lazy_load "neoscroll.nvim"
|
||||||
end,
|
end,
|
||||||
@ -154,9 +164,7 @@ return packer.startup(function()
|
|||||||
use {
|
use {
|
||||||
disable = not plugin_status.autosave,
|
disable = not plugin_status.autosave,
|
||||||
"Pocco81/AutoSave.nvim",
|
"Pocco81/AutoSave.nvim",
|
||||||
config = function()
|
config = override_req("autosave", "(plugins.configs.others).autosave()"),
|
||||||
require("plugins.configs.others").autosave()
|
|
||||||
end,
|
|
||||||
cond = function()
|
cond = function()
|
||||||
return require("core.utils").load_config().options.plugin.autosave == true
|
return require("core.utils").load_config().options.plugin.autosave == true
|
||||||
end,
|
end,
|
||||||
@ -166,9 +174,7 @@ return packer.startup(function()
|
|||||||
"max397574/better-escape.nvim",
|
"max397574/better-escape.nvim",
|
||||||
disable = not plugin_status.esc_insertmode,
|
disable = not plugin_status.esc_insertmode,
|
||||||
event = "InsertEnter",
|
event = "InsertEnter",
|
||||||
config = function()
|
config = override_req("better_escape", "(plugins.configs.others).better_escape()"),
|
||||||
require("plugins.configs.others").better_escape()
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- load luasnips + cmp related in insert mode only
|
-- load luasnips + cmp related in insert mode only
|
||||||
@ -181,18 +187,14 @@ return packer.startup(function()
|
|||||||
use {
|
use {
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
after = "friendly-snippets",
|
after = "friendly-snippets",
|
||||||
config = function()
|
config = override_req("nvim_cmp", "plugins.configs.cmp"),
|
||||||
require "plugins.configs.cmp"
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use {
|
use {
|
||||||
"L3MON4D3/LuaSnip",
|
"L3MON4D3/LuaSnip",
|
||||||
wants = "friendly-snippets",
|
wants = "friendly-snippets",
|
||||||
after = "nvim-cmp",
|
after = "nvim-cmp",
|
||||||
config = function()
|
config = override_req("luasnip", "(plugins.configs.others).luasnip()"),
|
||||||
require("plugins.configs.others").luasnip()
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use {
|
use {
|
||||||
@ -219,17 +221,13 @@ return packer.startup(function()
|
|||||||
use {
|
use {
|
||||||
"windwp/nvim-autopairs",
|
"windwp/nvim-autopairs",
|
||||||
after = "nvim-cmp",
|
after = "nvim-cmp",
|
||||||
config = function()
|
config = override_req("nvim_autopairs", "(plugins.configs.others).autopairs()"),
|
||||||
require("plugins.configs.others").autopairs()
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use {
|
use {
|
||||||
"glepnir/dashboard-nvim",
|
"glepnir/dashboard-nvim",
|
||||||
disable = not plugin_status.dashboard,
|
disable = not plugin_status.dashboard,
|
||||||
config = function()
|
config = override_req("dashboard", "plugins.configs.dashboard"),
|
||||||
require "plugins.configs.dashboard"
|
|
||||||
end,
|
|
||||||
setup = function()
|
setup = function()
|
||||||
require("core.mappings").dashboard()
|
require("core.mappings").dashboard()
|
||||||
end,
|
end,
|
||||||
@ -249,9 +247,7 @@ return packer.startup(function()
|
|||||||
"terrortylor/nvim-comment",
|
"terrortylor/nvim-comment",
|
||||||
disable = not plugin_status.comment,
|
disable = not plugin_status.comment,
|
||||||
cmd = "CommentToggle",
|
cmd = "CommentToggle",
|
||||||
config = function()
|
config = override_req("nvim_comment", "(plugins.configs.others).comment()"),
|
||||||
require("plugins.configs.others").comment()
|
|
||||||
end,
|
|
||||||
setup = function()
|
setup = function()
|
||||||
require("core.mappings").comment()
|
require("core.mappings").comment()
|
||||||
end,
|
end,
|
||||||
@ -261,9 +257,7 @@ return packer.startup(function()
|
|||||||
use {
|
use {
|
||||||
"kyazdani42/nvim-tree.lua",
|
"kyazdani42/nvim-tree.lua",
|
||||||
cmd = { "NvimTreeToggle", "NvimTreeFocus" },
|
cmd = { "NvimTreeToggle", "NvimTreeFocus" },
|
||||||
config = function()
|
config = override_req("nvim_tree", "plugins.configs.nvimtree"),
|
||||||
require "plugins.configs.nvimtree"
|
|
||||||
end,
|
|
||||||
setup = function()
|
setup = function()
|
||||||
require("core.mappings").nvimtree()
|
require("core.mappings").nvimtree()
|
||||||
end,
|
end,
|
||||||
@ -279,9 +273,7 @@ return packer.startup(function()
|
|||||||
"sudormrfbin/cheatsheet.nvim",
|
"sudormrfbin/cheatsheet.nvim",
|
||||||
disable = not plugin_status.cheatsheet,
|
disable = not plugin_status.cheatsheet,
|
||||||
after = "telescope.nvim",
|
after = "telescope.nvim",
|
||||||
config = function()
|
config = override_req("cheatsheet", "plugins.configs.cheatsheet"),
|
||||||
require "plugins.configs.cheatsheet"
|
|
||||||
end,
|
|
||||||
setup = function()
|
setup = function()
|
||||||
require("core.mappings").cheatsheet()
|
require("core.mappings").cheatsheet()
|
||||||
end,
|
end,
|
||||||
@ -298,9 +290,7 @@ return packer.startup(function()
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
config = function()
|
config = override_req("telescope", "plugins.configs.telescope"),
|
||||||
require "plugins.configs.telescope"
|
|
||||||
end,
|
|
||||||
setup = function()
|
setup = function()
|
||||||
require("core.mappings").telescope()
|
require("core.mappings").telescope()
|
||||||
end,
|
end,
|
||||||
@ -314,9 +304,7 @@ return packer.startup(function()
|
|||||||
"TZMinimalist",
|
"TZMinimalist",
|
||||||
"TZFocus",
|
"TZFocus",
|
||||||
},
|
},
|
||||||
config = function()
|
config = override_req("truezen", "plugins.configs.zenmode"),
|
||||||
require "plugins.configs.zenmode"
|
|
||||||
end,
|
|
||||||
setup = function()
|
setup = function()
|
||||||
require("core.mappings").truezen()
|
require("core.mappings").truezen()
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user