Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mini-surround): use keys to lazy load instead #449

Merged
merged 2 commits into from
Jul 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions lua/astrocommunity/motion/mini-surround/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,29 @@ 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
delete = prefix .. "d", -- Delete surrounding
find = prefix .. "f", -- Find surrounding (to the right)
find_left = prefix .. "F", -- Find surrounding (to the left)
highlight = prefix .. "h", -- Highlight surrounding
replace = prefix .. "r", -- Replace surrounding
update_n_lines = prefix .. "n", -- Update `n_lines`
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`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should be reverted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. You need those lines in order for mini-surround to map the keys to the actions. No?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were already set previously

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were just using a common prefix variable rather than hard coding each one with the same prefix. So we should stay with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes, I totally missed that. Will fix.

mehalter marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
Expand Down