Closed alexmozaidze closed 1 month ago
Tree-sitter is useful for structurally matching text inside the buffer; it's for figuring out what to surround, not what to surround with. As far as I know, the only way to implement this is to manually add per-filetype surrounds. I'm not keen on integrating this into the base plugin, as I don't know how to "guarantee" that a filetype-specific setup function defined by nvim-surround
would run before a user-defined filetype-specific setup function. If anybody has any ideas for how this could be made feasible, feel free to leave them here.
Further consideration has me thinking that the core of nvim-surround
should remain simple and not try to handle any filetype-specific options by default. If you would like an F
surround, please define it yourself using buffer_setup
.
Checklist
:h nvim-surround
to see if there might be any relevant information there?Is your feature request related to a problem? Please describe.
I wanted to surround my code with an anonymous function (aka lambda), I tried to use
sf
, but it surrounds in function call. "No problem!", I thought to myself, "I will use the capitalF
to get the desired result!". But the desired result never came.Describe the solution you'd like
It'd be very handy to just
sF
and surround something in a function definition, like this:Before (* represents cursor):
After
yst)F
:In order to determine if it should be inlined or multiline, I thought of using
l
/L
instead ofF
.l
for inline lambda, andL
for multiline lambda.Additional context
I am not aware of how this could be achieved without the help of treesitter (besides manually defining it for every file type), but it'd actually be cool to have a treesitter-powered function wrap.