nova-rust icon indicating copy to clipboard operation
nova-rust copied to clipboard

Auto-Imports -> use xxxx;

Open hilopenyld opened this issue 2 years ago • 2 comments

In VSCode (yeuchhh), if you add some rust code, and the LSP does not recognize the symbol, it offers a popup to add the use xxxx to the file. If there is more than one match, it offers a list of possible matches to pick from. I suspect it gets this from the installed crates.

For example, typing info! shows Screenshot 2023-09-22 at 11 26 28 AM

Or if you paste code, it offers a "Quick Fix" that adds the use, e.g. Screenshot 2023-09-22 at 11 24 10 AM

Is this something the extension can offer? Or is it related to VSCodes Intellisense?

The benefit of having this is ... with a keystroke you can select and add the use xxx and keep coding instead of jumping around.

Huge thanks for making this extension, I much prefer Nova as my coding editor and this makes it sing.

hilopenyld avatar Sep 22 '23 15:09 hilopenyld

Thanks for submitting an issue!

This looks to me like mostly a duplicate of #41 . Briefly, Rust Analyzer wants to lazily offer auto-imports to improve performance, but the Nova language client doesn't implement the LSP spec for lazy completions. The API for Nova's language client doesn't allow me to handle any of this communication myself, so there's not a feasible way for me to offer auto-imports. Once Nova adds support for this part of the LSP spec, auto-imports will work without needing anything from me!

As far as the Quick Fix feature in VS Code – that makes use of Code Actions offered by Rust Analyzer which is a feature supported by Nova. With your cursor over the unimported symbol, use the Command-Shift-A key combo to see the option to import it. Rust Analyzer has some wonderful Code Actions on offer (e.g., filling any missing enum members in a match statement), so definitely use that key combo anywhere you see red squiggles! You can even remap the keyboard shortcut.

kilbd avatar Oct 10 '23 01:10 kilbd

Thanks for the quick response. I had no idea about the Shift-Commnd-A capability. Thats exceptionally useful.

hilopenyld avatar Oct 10 '23 21:10 hilopenyld