Closed AradiPatrik closed 5 months ago
The code to demonstrate the issue main.rs
trait Messenger {
fn send(&self, message: &str);
}
struct LimitTracker<'a, T: Messenger> {
messenger: &'a T,
value: u32,
limit: u32,
}
impl<'a, T: Messenger> LimitTracker<'a, T> {
fn set_value(&mut self, value: u32) {
if self.limit as f32 / value as f32 > 0.5f32 {
self.messenger.send("You've consumed half of your quota");
} else if self.limit as f32 / value as f32 > 0.75f32 {
self.messenger
.send("Warning! You've consumed 75% of your quota");
} else if self.limit as f32 / value as f32 > 0.9f32 {
self.messenger
.send("Urgent! You've consumed 90% of your quota");
}
self.value = value
}
}
fn main() {}
Hey :wave:
Thanks for the detailed report. This is a rust-analyzer bug: https://github.com/rust-lang/rust-analyzer/issues/16607
@mrcjkb Looks like the problem is more complicated than it seems...
Coming exactly from https://github.com/rust-lang/rust-analyzer/issues/16867, I made my own tests and saw that even on Neovim v0.10 I can still reproduce this issue with this plugin enabled. However, if I disable this plugin, then the completion works fine.
@mrcjkb Looks like the problem is more complicated than it seems...
Coming exactly from rust-lang/rust-analyzer#16867, I made my own tests and saw that even on Neovim v0.10 I can still reproduce this issue with this plugin enabled. However, if I disable this plugin, then the completion works fine.
π€ vim.lua.buf.code_action()
isn't implemented by this plugin. It's a core neovim function.
So that sounds very fishy.
Are you sure you're using the same rust-analyzer version in both cases? Many neovim distributions use mason.nvim to install it.
@mrcjkb Thanks a lot for your timely reply! I did some more research and it did point me to a different direction.
Are you sure you're using the same rust-analyzer version in both cases?
I'm quite sure about this one. Initially I thought it was an r-a problem so that was my first thing to look into. However I do think the latest version of r-a is now generating the correct output.
π€
vim.lua.buf.code_action()
isn't implemented by this plugin. It's a core neovim function. So that sounds very fishy.
That's why I didn't think of disabling this plugin at first. However I'm not suggesting it's directly causing the problem.
I'm thinking in theory this plugin should do no harm to the whole code action thing, except it somehow puts r-a into an output mode Neovim cannot handle properly.
After some more research I've found https://github.com/fannheyward/coc-rust-analyzer/commit/5059573c3e6bd8b31315f1abec6007da14f77fd4 to support this theory. Looks like it has something to do with:
If this is the case, probably there're some problems remaining even with the updated Neovim after all.
@rami3l wow thanks for the thorough research! π
If I have some time in the next days, I'll see if can find the issue in neovim.
In the meantime, you should be able to work around this by explicitly setting the capability to false
via vim.g.rustaceanvim.server.capabilities
.
@rami3l wow thanks for the thorough research! π
If I have some time in the next days, I'll see if can find the issue in neovim.
In the meantime, you should be able to work around this by explicitly setting the capability to
false
viavim.g.rustaceanvim.server.capabilities
.
@mrcjkb Thanks for your pointers! Now I can 100% confirm that this problem can be worked around by setting vim.g.rustaceanvim.server.capabilities.experimental.snippetTextEdit
to false
.
:thinking: I can't reproduce this with my personal config, but I can with a minimal one. I wonder if there's a neovim setting or plugin that is fixing it in my config.
@rami3l wow thanks for the thorough research! π If I have some time in the next days, I'll see if can find the issue in neovim. In the meantime, you should be able to work around this by explicitly setting the capability to
false
viavim.g.rustaceanvim.server.capabilities
.@mrcjkb Thanks for your pointers! Now I can 100% confirm that this problem can be worked around by setting
vim.g.rustaceanvim.server.capabilities.experimental.snippetTextEdit
tofalse
.
@rami3l can I please ask how do you set vim.g.rustaceanvim.server.capabilities.experimental.snippetTextEdit
to false
? I am using LazyVim.
@rami3l wow thanks for the thorough research! π If I have some time in the next days, I'll see if can find the issue in neovim. In the meantime, you should be able to work around this by explicitly setting the capability to
false
viavim.g.rustaceanvim.server.capabilities
.@mrcjkb Thanks for your pointers! Now I can 100% confirm that this problem can be worked around by setting
vim.g.rustaceanvim.server.capabilities.experimental.snippetTextEdit
tofalse
.@rami3l can I please ask how do you set
vim.g.rustaceanvim.server.capabilities.experimental.snippetTextEdit
tofalse
? I am using LazyVim.
See :h rustaceanvim.config
and the LazyVim documentation on the rust extension pack.
@rami3l wow thanks for the thorough research! π If I have some time in the next days, I'll see if can find the issue in neovim. In the meantime, you should be able to work around this by explicitly setting the capability to
false
viavim.g.rustaceanvim.server.capabilities
.@mrcjkb Thanks for your pointers! Now I can 100% confirm that this problem can be worked around by setting
vim.g.rustaceanvim.server.capabilities.experimental.snippetTextEdit
tofalse
.@rami3l can I please ask how do you set
vim.g.rustaceanvim.server.capabilities.experimental.snippetTextEdit
tofalse
? I am using LazyVim.
@elithrade You seem to be using lazy.nvim to install this plugin, so you should be good to go after simply adding that assignment to this plugin's config
function.
ctx: https://github.com/folke/lazy.nvim?tab=readme-ov-file#-plugin-spec
π€ I can't reproduce this with my personal config, but I can with a minimal one. I wonder if there's a neovim setting or plugin that is fixing it in my config.
@mrcjkb Thanks again for your efforts! Would you like to share the minimal reproduction with Neovim? I guess it's still a problem to be addressed on their side...
π€ I can't reproduce this with my personal config, but I can with a minimal one. I wonder if there's a neovim setting or plugin that is fixing it in my config.
@mrcjkb Thanks again for your efforts! Would you like to share the minimal reproduction with Neovim? I guess it's still a problem to be addressed on their side...
I am planning to look into it, but haven't had the time yet π Since it's related to an experimental rust-analyzer feature, I don't think it's worth opening an issue with Neovim yet.
Have you read the docs and searched existing issues?
Neovim version (nvim -v)
v0.9.5
Operating system/version
macOS 14.3.1 (23D60)
Output of :checkhealth rustaceanvim
How to reproduce the issue
Expected behaviour
https://github.com/mrcjkb/rustaceanvim/assets/16306605/e00346dd-62c3-4d9d-848e-704e8c74060e
The expected behavior is to have regular closing braces generated
}
. Please check the video issue. It should be quite obvious.Actual behaviour
Right now closing braces are escaped for some reason
\}
instead of}
Please check the attached video.The minimal config used to reproduce this issue.