Skip to content

Commit

Permalink
fix(mini-surround): use keys to lazy load instead (#449)
Browse files Browse the repository at this point in the history
* fix(mini-surround): use keys to lazy load instead

* Update lua/astrocommunity/motion/mini-surround/init.lua

---------

Co-authored-by: Micah Halter <[email protected]>
  • Loading branch information
pkazmier and mehalter authored Jul 16, 2023
1 parent e9244d8 commit 959d180
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lua/astrocommunity/motion/mini-surround/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@ return {
{ "machakann/vim-sandwich", enabled = false },
{
"echasnovski/mini.surround",
event = "User AstroFile",
keys = function(plugin, keys)
-- Populate the keys based on the user's options
local mappings = {
{ plugin.opts.mappings.add, desc = "Add surrounding", mode = { "n", "v" } },
{ plugin.opts.mappings.delete, desc = "Delete surrounding" },
{ plugin.opts.mappings.find, desc = "Find right surrounding" },
{ plugin.opts.mappings.find_left, desc = "Find left surrounding" },
{ plugin.opts.mappings.highlight, desc = "Highlight surrounding" },
{ plugin.opts.mappings.replace, desc = "Replace surrounding" },
{ plugin.opts.mappings.update_n_lines, desc = "Update `MiniSurround.config.n_lines`" },
}
mappings = vim.tbl_filter(function(m) return m[1] and #m[1] > 0 end, mappings)
return vim.list_extend(mappings, keys)
end,
opts = {
mappings = {
add = prefix .. "a", -- Add surrounding in Normal and Visual modes
Expand Down

0 comments on commit 959d180

Please sign in to comment.