kilbd / nova-rust

A Rust extension for the Nova text editor, using the Rust Analyzer language server.
MIT License
29 stars 5 forks source link

add suggestions out of scope that automatically add a use when selected #18

Closed laralove143 closed 2 years ago

laralove143 commented 2 years ago

this is the biggest reason im considering not to switch to nova, both vscode and jetbrains has this

it'd work something like

fn foo() {
  Conte| // suggestion pops up: Context - use crate::Context;
}

when the suggestion is selected (enter pressed), the code would now be

use crate::Context;

fn foo() {
  Context|
}

right now you'd have to:

  1. start typing
  2. realize you need to add a use
  3. either
    1. move all the way up
    2. figure out where the item is
    3. add the use
    4. go back to where you were and continue coding
  4. or
    1. finish typing the item's whole name
    2. save
    3. wait for the "add a use for this item" lint to pop up
    4. press cmd shift a to apply the suggestion
    5. save again
    6. wait for the errors to disappear
    7. continue coding
kilbd commented 2 years ago

Hi Lara! Wonderful to hear from you again! Thank you for continuing to find ways to make this extension better.

I'm sorry to report that I looked into this, and it's not currently possible. 😞 It's an LSP spec version 3.16 feature which isn't implemented by Nova. Based on the configuration Nova passes to Rust Analyzer, RA doesn't even try to offer these completions. I wouldn't be able to listen for them and handle requests within this extension.

These auto-import completions are implemented similarly in other language servers, and very much something others want. I bumped the forum thread to +1 the feature request. We can only hope Panic will prioritize better LSP support.