kylechui / nvim-surround

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

Generics #310

Closed bendk closed 4 months ago

bendk commented 4 months ago

Checklist

Is your feature request related to a problem? Please describe.

Thanks for the great plugin. One feature I'd love to see is generic support, similar to functions. For example, if I'm editing a Rust file and have Foo under the cursor, I'd love to be able to type ysiwgBox to turn that into Box<Foo>. The feature would work exactly the same as function surrounds, but just use <> instead of ().

Additional context

You have a nice configuration system and I found it pretty easy to add this myself for Rust, but built-in support would be even better.

kylechui commented 4 months ago

Hi there, since this would be a filetype-specific configuration and only really applicable to {cpp, rust, java, typescript} and similar, I would prefer to keep the core body of the plugin simple, and "offload" any more specific configuration to the end user. I'm open to hearing any other points you may have about it though. You can also feel free to check/post to #53.

bendk commented 4 months ago

Fair enough, that makes sense to me. The main reason I'd like to see it built-in is that I'm not sure my treesitter node type will work with other languages. If it was part of the repo, then maybe others could add support for those. That said, it doesn't really feel like nvim-surround needs to handle that issue. I'll post to #53 and close this one.

kylechui commented 4 months ago

I think the "real" solution would be to write some query for nvim-treesitter-textobjects (or similar) that would handle all of the filetypes and group them under one umbrella, then match on query instead of treesitter node. Thanks for understanding!