kylechui / nvim-surround

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

feat: Use tabular aliases for targeting when adding surrounds #125

Closed Speculative closed 2 years ago

Speculative commented 2 years ago

Checklist

Is your feature request related to a problem? Please describe. It doesn't seem currently possible to use tabular aliases as targets when adding surrounds.

Describe the solution you'd like If we have a surround that's targetable by a tabular alias q, "Some text" Then in normal mode, ysaq) should result in: ("Some text")

Additional context Is it possible to do this on the user side? It seems unclear if adding new global motions is desirable as per #43. Per the docs for aliases:

Note: While `ysabB` is a valid surround action, `ysarB` is not, since `ar` is
not a valid Vim motion. This can be side-stepped by creating the following
operator-mode maps:
>
    vim.keymap.set("o", "ir", "i[")
    vim.keymap.set("o", "ar", "a[")
    vim.keymap.set("o", "ia", "i<")
    vim.keymap.set("o", "aa", "a<")

Thanks for your work on this plugin!

kylechui commented 2 years ago

This is honestly something that's quite large from a coding perspective; I would recommend you take a look at something like targets.vim or the recently released mini.ai. The main problem with implementing this is that whenever you call ys[motion], there is no way for me to actually check what motion you entered, or modify it (see this upstream issue). The main reason I'm able to alias characters for delete/change operations is that whenever you call dsq, nvim-surround actually calls ds', ds", and ds`, then taking the "best" result. Something similar for normal-mode surrounds is impossible as of right now.

Speculative commented 2 years ago

Makes sense, thanks for the suggestions :+1: