refactor: use opts everywhere, so any plugin config can now be extended

This commit is contained in:
Folke Lemaitre 2023-01-08 16:13:22 +01:00
parent 6c73e775cf
commit 77b5e9ab56
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 40 additions and 32 deletions

View file

@ -83,8 +83,8 @@ return {
{ {
"echasnovski/mini.pairs", "echasnovski/mini.pairs",
event = "VeryLazy", event = "VeryLazy",
config = function() config = function(_, opts)
require("mini.pairs").setup({}) require("mini.pairs").setup(opts)
end, end,
}, },
@ -92,19 +92,20 @@ return {
{ {
"echasnovski/mini.surround", "echasnovski/mini.surround",
keys = { "gz" }, keys = { "gz" },
config = function() opts = {
mappings = {
add = "gza", -- Add surrounding in Normal and Visual modes
delete = "gzd", -- Delete surrounding
find = "gzf", -- Find surrounding (to the right)
find_left = "gzF", -- Find surrounding (to the left)
highlight = "gzh", -- Highlight surrounding
replace = "gzr", -- Replace surrounding
update_n_lines = "gzn", -- Update `n_lines`
},
},
config = function(_, opts)
-- use gz mappings instead of s to prevent conflict with leap -- use gz mappings instead of s to prevent conflict with leap
require("mini.surround").setup({ require("mini.surround").setup(opts)
mappings = {
add = "gza", -- Add surrounding in Normal and Visual modes
delete = "gzd", -- Delete surrounding
find = "gzf", -- Find surrounding (to the right)
find_left = "gzF", -- Find surrounding (to the left)
highlight = "gzh", -- Highlight surrounding
replace = "gzr", -- Replace surrounding
update_n_lines = "gzn", -- Update `n_lines`
},
})
end, end,
}, },
@ -113,14 +114,15 @@ return {
{ {
"echasnovski/mini.comment", "echasnovski/mini.comment",
event = "VeryLazy", event = "VeryLazy",
config = function() opts = {
require("mini.comment").setup({ hooks = {
hooks = { pre = function()
pre = function() require("ts_context_commentstring.internal").update_commentstring({})
require("ts_context_commentstring.internal").update_commentstring({}) end,
end, },
}, },
}) config = function(_, opts)
require("mini.comment").setup(opts)
end, end,
}, },

View file

@ -117,8 +117,12 @@ return {
"ggandor/leap.nvim", "ggandor/leap.nvim",
event = "VeryLazy", event = "VeryLazy",
dependencies = { { "ggandor/flit.nvim", opts = { labeled_modes = "nv" } } }, dependencies = { { "ggandor/flit.nvim", opts = { labeled_modes = "nv" } } },
config = function() config = function(_, opts)
require("leap").add_default_mappings(true) local leap = require("leap")
for k, v in pairs(opts) do
leap.opts[k] = v
end
leap.add_default_mappings(true)
end, end,
}, },
@ -196,8 +200,9 @@ return {
{ {
"RRethy/vim-illuminate", "RRethy/vim-illuminate",
event = "BufReadPost", event = "BufReadPost",
config = function() opts = { delay = 200 },
require("illuminate").configure({ delay = 200 }) config = function(_, opts)
require("illuminate").configure(opts)
end, end,
-- stylua: ignore -- stylua: ignore
keys = { keys = {

View file

@ -167,18 +167,19 @@ return {
"echasnovski/mini.indentscope", "echasnovski/mini.indentscope",
version = false, -- wait till new 0.7.0 release to put it back on semver version = false, -- wait till new 0.7.0 release to put it back on semver
event = "BufReadPre", event = "BufReadPre",
config = function() opts = {
-- symbol = "▏",
symbol = "",
options = { try_as_border = true },
},
config = function(_, opts)
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason" }, pattern = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason" },
callback = function() callback = function()
vim.b.miniindentscope_disable = true vim.b.miniindentscope_disable = true
end, end,
}) })
require("mini.indentscope").setup({ require("mini.indentscope").setup(opts)
-- symbol = "▏",
symbol = "",
options = { try_as_border = true },
})
end, end,
}, },