The autocompletion works (mostly) but for example Vec::new() doesn’t highlight anything at all. I do get errors when not putting a semicolon, but things like passing too many arguments into the println macro doesn’t throw an error. Or how shown in this example, it did not autocomplete the clone method, while also just accepting .clo; at the end of a String (it also didn’t autocomplete “String”). In the video I show how it also gives me a recommendation for setting vec![] as a type, which doesn’t make any sense. It only seems to a very limited selection of methods and some words I already used in the script. Is this how it’s supposed to be, or do I have some very old version perhaps?
EDIT: Look in description for the fix
That’s not how it’s supposed to be.
If I do
Vec::new(foo, bar)
, I getexpected 0 arguments, found 2 (rust-analyzer E0107)
.I don’t get that either, but I’m still running with the Vim configuration I setup on my previous PC from 2011, where I turned off checks that require calling
cargo check
orcargo clippy
in the background. From what I remember, a properly functioning default rust-analyzer config should pick up and display anythingcargo check
will catch and you can switch it tocargo clippy
for even stricter results.I get
clone()
,clone_into()
, andclone_from()
as proposed completions for.clo
on my as-you-type completions forfoo
wherelet foo = String::new();
and it proposed a whole bunch of things, withString
at the top when I typedStri
. (eg. thestringify!
macro,OsString
, mixed in with various results from other crates in the project likeserde
)Turns out, the *.rs file needs to be in some kind of folder structure, like the one provided by cargo when creating a project. I was just editing the loose files in the rustlings program, and because they are not in a proper program folder structure, most of the syntax stuff didn’t show up.
Thank you for sharing your experience though! It was very useful for figuring out if what I had was an issue or normal behavior. Now my neovim works perfectly with all the syntax highlighting I could wish for.