Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type hints doesnt work with rust-analyzer 25-07-2022 (d.m.Y) #73

Closed
alexzanderr opened this issue Jul 25, 2022 · 14 comments · Fixed by #77
Closed

type hints doesnt work with rust-analyzer 25-07-2022 (d.m.Y) #73

alexzanderr opened this issue Jul 25, 2022 · 14 comments · Fixed by #77

Comments

@alexzanderr
Copy link

hello

i have a really annoying problem and im requesting help.

type hints doesnt work in editor
image

they are enabled:

// Settings in here override those in "LSP-rust-analyzer/LSP-rust-analyzer.sublime-settings"
{
    "settings": {
        "rust-analyzer.inlayHints.enable": true,
        "rust-analyzer.inlayHints.typeHints": true,
        "rust-analyzer.inlayHints.smallerHints": true,

        // "rust-analyzer.experimental.procAttrMacros": true,

        "rust-analyzer.procMacro.enable": true,
        // "rust-analyzer.cargo.loadOutDirsFromCheck": true,

        // "rust-analyzer.diagnostics.disabled": [
        //     "macro-error"
        // ]

        "rust-analyzer.hoverActions.enable": false,

        "rust-analyzer.hoverActions.implementations": false,
        "rust-analyzer.hoverActions.run": false,
        "rust-analyzer.hoverActions.linksInHover": false,

        "rust-analyzer.lens.enable": false,

        "rust-analyzer.checkOnSave.enable": false,


        // https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options
        // Activates all features of all packages selected on the command-line
        "rust-analyzer.cargo.allFeatures": true,


        "rust-analyzer.assist.importPrefix": "plain",

        "rust-analyzer.diagnostics.disabled": [
            "inactive-code",
            "unresolved-macro-call",
            "unresolved-proc-macro",
            "macro-error"
        ],

        // gets rid of auto import of things that i dont want like Write from io::Write or fmt::Write
        "rust-analyzer.completion.autoimport.enable": false,

    }
}

i've tested this issue with these versions of rust analyzer:

i've looked into the configuration json from the repo or rust analyzer. found out that type hints is changed compared to the settings from this sublime package

rust-analyzer.inlayHints.typeHints.enable (default: true)

    Whether to show inlay type hints for variables.

https://github.com/rust-lang/rust-analyzer/blob/master/docs/user/generated_config.adoc

the difference is:

+ rust-analyzer.inlayHints.typeHints.enable 
- rust-analyzer.inlayHints.typeHints

seems to be deprecated from my opinion

anyway, i tried changing config from sublime settings, but i get warning
image
i tried restarting rust analyzer but the type hints doesnt appear, so i guess the flag doesnt apply

also, i saw that with an older version of rust analyzer (22-02-2022) type hints worked.
so my conclusion is that the new versions of rust analyzer changed the type hint config and the old config doesnt apply anymore, leading to disabled feature of type hints.

also, i've found that in your repo the default version for ra is 10-01-2022 ... a really old version of rust analyzer.
i think you should update your repo guys, thats what im suggesting

any ideas ?
thanks in advance.

@rchl
Copy link
Member

rchl commented Jul 25, 2022

Rust analyzer versions newer than 2022-01-10 implement different version of inlay hints (a spec-compatible version) and that's not supported either by this package or the LSP client (see feature request at sublimelsp/LSP#1746).

That's also the reason why this package is stuck at 2022-01-10. The option is to either have support for inlay hints and old version or new version and no inline hints (at least for the time being).

@alexzanderr
Copy link
Author

yeah, but that moves me to the original problem: with 2022-01-10 everything is working, except .iter() and .split() methods and many more methods doesnt appear in autocomplete with the newest rust versions (it was working in 20-02-2022, with rustc from that month), but when i've updated rustc and cargo later, i noticed the .iter and .split where gone with the same 2022-01-10 rust analyzer

@alexzanderr
Copy link
Author

alexzanderr commented Jul 25, 2022

now with latest rust analyzer: .iter() and .split() methods appear again (autocomplete is working properly), but now here we go to this issue.

@alexzanderr
Copy link
Author

alexzanderr commented Jul 25, 2022

yeah, but that moves me to the original problem: with 2022-01-10 everything is working, except .iter() and .split() methods and many more methods doesnt appear in autocomplete with the newest rust versions (it was working in 20-02-2022, with rustc from that month), but when i've updated rustc and cargo later, i noticed the .iter and .split where gone with the same 2022-01-10 rust analyzer

or does it matter the version of the rust toolchain that im using ?

i know that when i was coding in februrary 2022, type hints and completion was fine.
after some months passed i've noticed .iter() and .split() didnt appear anymore in autocomplete overlay.

should i revert back to the rust toolchain that i was using in februrary 2022 (rust 1.58 ? maybe) and use the 10-01-2022 version of rust analyzer ?

would that work ?

@rchl
Copy link
Member

rchl commented Jul 25, 2022

or does it matter the version of the rust toolchain that im using ?

I suggest that you ask that question (whether rust analyzer depends on specific toolchain version) in https://github.com/rust-lang/rust-analyzer/issues. This is just a thin wrapper around rust-analyzer so none of us is probably familiar with such implementation details.

@alexzanderr
Copy link
Author

well. solved the issue.

i just installed

rustup install nightly-2022-02-22

rustup default nightly-2022-02-22-x86_64-unknown-linux-gnu

with the rust analyzer

❱  ./rust-analyzer-type-hint-works-2022-02-22.nightly --version
rust-analyzer c0ee2f23f 2022-02-22 nightly

and i get both type hints and good completion inside sublime text
image

(cant show completion cuz the window disappears on screenshot)

and you said newer rust analyzer than 10-01-2022 wont work with type hints, well, this one works,

how comes that ? and also whether rust analyzer depends on specific toolchain version, this is actually true, it depends, apparently

@alexzanderr
Copy link
Author

but this issue still remains, cuz the problem with type hints isnt solved for newer than 2022-02-22 rust analyzers

@rchl
Copy link
Member

rchl commented Jul 25, 2022

and you said newer rust analyzer than 10-01-2022 wont work with type hints, well, this one works,

I wasn't sure which version exactly dropped support for this legacy implementation. I know 2022-04-04 didn't work with it anymore.

@alexzanderr
Copy link
Author

good to know, then type hints in any rust analyzer newer than 2022-04-04 wont work.

@alexzanderr
Copy link
Author

thanks a lot for your time

@KristonCosta
Copy link

For those looking to upgrade rust-analyzer versions, it looks like sublimelsp/LSP#2018 has been merged upstream that adds a "show_inlay_hints": boolean setting to LSP. I was able to get type hints working using latest LSP with that config set to true and using rust-analyzer 0.3.1178-standalone (a670ff888 2022-08-21).

There's some invalid logging generated by LSP-rust-analyzer since it's still trying to call the old rust-analyzer inlay hints spec, but hints still work just fine.

@minerscale
Copy link

minerscale commented Aug 29, 2022

@KristonCosta

Awesome! We're so close to a solution. I'm coming across a new problem now (rust-analyzer a670ff888 2022-08-21). On the latest master branch version of sublimelsp/LSP some of the inlay hints are broken. An example is as follows:

fn main() {
    let mut jeff = "20";

    println!("{}", jeff);
}

Gives:
image

but

fn main() {
    let mut jeff = 20;

    println!("{}", jeff);
}

Works fine:
image

Any ideas as to what could be going on? I suspect it's a problem with the very new inlay hint feature in sublime text's LSP implementation. I'll submit a bug report there. There's some additional jank when it comes to the cursor as well.

Update: it appears to break when the hint contains an ampersand (&)

@KristonCosta
Copy link

KristonCosta commented Aug 29, 2022

Yeah I'm seeing the & truncation as well

Edit: Oh, nice :) sublimelsp/LSP#2034 + sublimelsp/LSP#2036

@alexzanderr
Copy link
Author

so now can i use latest rust-analyzer with sublime LSP rust analyzer ?

@rchl rchl closed this as completed in #77 Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants