kylechui / nvim-surround

Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua.
MIT License
2.92k stars 60 forks source link

Conflicts with leap.nvim #253

Closed xbladesub closed 11 months ago

xbladesub commented 11 months ago

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'.

kylechui commented 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).

mrs4ndman commented 11 months ago

Sorry for meddling If it helps, I got this to work by using this configuration:

kylechui commented 11 months ago

All of the keymaps you listed are default; you should be able to just call require("nvim-surround").setup().

kevintraver commented 11 months ago

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

Subjective commented 9 months ago

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.