Closed xbladesub closed 11 months ago
nvim-surround
doesn't use s
by default at all, see nvim-surround.config.keymaps
for help with remapping (although I suspect this might be an issue with something else).
Sorry for meddling If it helps, I got this to work by using this configuration:
-- Inside the return { "kylechui/nvim-surround" } statement
opts = {
keymaps = {
normal = "ys",
delete = "ds",
visual = "S",
visual_line = "gS",
change = "cs",
change_line = "cS",
}
}
-- In the after/plugin directory or inside the config = function() end block
require("nvim-surround").setup({
keymaps = {
normal = "ys",
delete = "ds",
visual = "S",
visual_line = "gS",
change = "cs",
change_line = "cS",
}
})
I use Lazy and leap.nvim / flit.nvim, and this still lets me jump with s / S / f / F / t T and surround things when I need to.
All of the keymaps you listed are default; you should be able to just call require("nvim-surround").setup()
.
One of the issues with leap.nvim, is that the s
is also mapped in operator mode when using the default keymaps.
So cs
initiates the leap functionality, which conflicts with surround default keymaps.
Same with ds
.
Instead of using the default leap.nvim keymaps, you can do something like this:
vim.keymap.set({ "n" }, "S", "<Plug>(leap-backward-to)")
vim.keymap.set({ "n" }, "s", "<Plug>(leap-forward-to)")
vim.keymap.set({ "o", "x" }, "Z", "<Plug>(leap-backward-till)")
vim.keymap.set({ "o", "x" }, "z", "<Plug>(leap-forward-till)")
or override the change
(cs
) and delete
(ds
) surround keymaps
You could also use the mappings suggested by leap.nvim
's author.
See https://github.com/ggandor/leap.nvim/discussions/59 and https://github.com/ggandor/leap.nvim/discussions/41 for ideas.
How can I remap surround to use some other character, not 's' ? I use leap plugin, seems like leap's bindings have "higher priority" and surround doesn't work at all because of 's'.