-
Notifications
You must be signed in to change notification settings - Fork 1k
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
bug: can not overwrite mini.surround keybinds #172
Comments
|
These are the default keybinds for Also other keymaps don't work either. I can not change the keymaps at all, I just used For example, the following config doesn't work either: return {
{
"echasnovski/mini.surround",
opts = {
mappings = {
add = "<leader>ma",
delete = "<leader>md",
find = "<leader>mf",
find_left = "<leader>mF",
highlight = "<leader>mh",
replace = "<leader>mr",
update_n_lines = "<leader>mn",
},
},
},
}
|
I redefined mini.surround keymaps using this:
|
{
"echasnovski/mini.surround",
keys = function(plugin, keys)
-- Populate the keys based on the user's options
local opts = require("lazy.core.plugin").values(plugin, "opts", false)
local mappings = {
{ opts.mappings.add, desc = "Add surrounding", mode = { "n", "v" } },
{ opts.mappings.delete, desc = "Delete surrounding" },
{ opts.mappings.find, desc = "Find right surrounding" },
{ opts.mappings.find_left, desc = "Find left surrounding" },
{ opts.mappings.highlight, desc = "Highlight surrounding" },
{ opts.mappings.replace, desc = "Replace surrounding" },
{ opts.mappings.update_n_lines, desc = "Update `MiniSurround.config.n_lines`" },
}
return vim.list_extend(mappings, keys)
end,
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
require("mini.surround").setup(opts)
end,
}, If you use this config and just replace the mappings with for example Edit: the previous post from @alezunino is much more elegant so you should prefer his solution. |
@dpetka2001 This works but I already mentioned this in my original post. This results in duplicate keybindings, so it is not a good solution. @alezunino's solution works! Thanks In my opinion this should still be considered a bug, since you have to go out of your way to get this working properly. It's good there is a workaround though! |
@pprotas It doesn't result in duplicate keybindings for me. I only have the I don't see how this could be considered a bug. You have to customize the configuration to apply for your |
Yes you are correct!! I must have done something wrong in my previous test with the config provided. Just tested |
Yes, that is because we use Edit: just use |
Hmm I am back to sew some chaos in this thread... I was too hasty in saying that @alezunino's solution worked. It does add the mappings to my WhichKey, but the keys don't actually don't do anything. I am now using @dpetka2001's solution with |
My solution does work. I use it on several computers. Besides, I am addicted to "sa" "se" and "sd" keys 😜. Just copy the code I posted before, including: event = "BufRead" |
Could you plz elaborate on what |
I made a PR to fix the bug, see #177. |
The "BufRead" event is triggered when starting to edit a new buffer. On the other hand, the original config of mini.surround will load it "VeryLazy"ly, which is AFAIK after than BufRead. In other words, BufRead in my config seems to take precedence over the one defined in LazyVim. Not 100% sure about this... Anyway, in my code the keybindings defined by mini.surround are not modified (meaning that sa, sd, etc... are defined in mini). To modify the keys you should use something like this: the difference here is that we are passing the "opts" parameter to mini, where "opts" contain the keys. |
This should now be fixed. You can just change the opts and the keys will be updated as expected. |
Did you check docs and existing issues?
Neovim version (nvim -v)
v0.9.0-dev-2057+g8376486e8-dirty
Operating system/version
MacOS 13.2
Describe the bug
You can not overwrite the keybinds for surround objects with
mini.surround
. Here is an example config:This doesn't work, see how the keybinds look like in Telescope:
I tried replicating the full spec from the docs, but now I have duplicate keybinds:
Flit and Leap are both disabled.
Steps To Reproduce
Expected Behavior
I can use
s
instead ofgz
for surroundingRepro
The text was updated successfully, but these errors were encountered: