Closed tom-anders closed 6 months ago
I can't seem to reproduce this behavior. Have you tried updating the plugin to the latest tagged release, and updating your Rust Tree-sitter parser? Do you use nvim-treesitter-textobjects
? If so, try updating that plugin as well.
Updated both the plugin and nvim-treesitter, the issue still persists - Here's a minimal example:
fn foo() {
bar();
dbg!(123); // triggering dsf here deletes the line above
}
Interestingly, when the bar()
line is removed, dsf
works as expected
I'm now able to reproduce the issue; funnily enough it doesn't seem to happen if you just paste the code into a non-Rust file.
Try adding this to ~/.config/nvim/queries/rust/textobjects.scm
:
; Defines macro invocations as "function calls"
(macro_invocation) @call.outer
; Copy-pasted from nvim-treesitter-textobject's definition of @call.outer
(call_expression) @call.outer
(call_expression
arguments: (arguments . "(" . (_) @_start (_)? @_end . ")"
(#make-range! "call.inner" @_start @_end)))
If this works for you, I'll open a PR upstream and see if they can make the change.
Yeah that seems to work, thanks!
Upstream PR got merged; feel free to re-open if there are still issues!
Checklist
:h nvim-surround
to see if there might be any relevant information there?Is your feature request related to a problem? Please describe.
In Rust, functions are invoked like this
dbg!(x)
(note the exclamation mark). Right now, nvim-surround does not detect this as a function call, even though as a Rust user I'd expectdsf
to turn this into justx
.Describe the solution you'd like I know that I can customize the pattern for detecting function, but I think the behavior described above should be the default for Rust files (if this is possible)
Additional context Add any other context or screenshots about the feature request here.