Inlay hints using coc.nvim (neovim) and rust-analyzer?

The screenshot above is from rust-analyzer in VS Code. I'm wondering if there's a way to get those hints (parts rendered in gray) in coc-nvim (neovim HEAD) and rust-analyzer? I searched in rust-analyzer and coc.nvim wiki's bug no luck. Currently my settings file is:

{
    "diagnostic.enable": true,
    "diagnostic.virtualText": false,
    "diagnostic.joinMessageLines": true,
    "diagnostic.checkCurrentLine": true,
    "diagnostic.messageTarget": "float",
    "diagnostic.level": "information",
    "suggest.autoTrigger": "none",
    "signature.enable": false,
    "coc.preferences.snippets.enable": false,
    "rust-analyzer.diagnostics.enable": false,
    "rust-analyzer.inlayHints.chainingHints": true,
    "rust-analyzer.serverPath": "/home/omer/.cargo/bin/rust-analyzer",
}

Thanks!

I can see those hints, bit I don't remember having had to do anything special...

Here's my CoC config for reference:

{
  "coc.preferences.hoverTarget":"float",
  "coc.preferences.colorSupport": true,
  "coc.preferences.bracketEnterImprove": true,
  "suggest.noselect": false,
  "diagnostic.locationlist": false
}

AFAIK, setting rust-analyzer.inlayHints.chainingHints to true should enable this. I actually had the opposite problem, where I was seeing those hints and wanted to disable them. I achieved that by setting rust-analyzer.inlayHints.chainingHints to false: https://twitter.com/burntsushi5/status/1257841917573947392

Looking at the screenshot, especially at the absence of hints for |(b, v)| I have a hypothesis that maybe coc.rust-analyzer supports only chaining hints? We also have "rust-analyzer.inlayHints.typeHints" and "rust-analyzer.inlayHints.parameterHints" which are renderned inline:

image

First two here are "chainingHints", the last two are "typeHints"

Sorry for late response -- this site used to send me emails for responses which
is what I relied on, but for some reason it doesn't now, so I missed the
reponses.

I tried everything but couldn't make this work. I'm using latest rust-analyzer
built from source. My settings is as above, and I also tried this simpler
setting:

{
    "rust-analyzer.inlayHints.chainingHints": true,
    "rust-analyzer.inlayHints.typeHints": true,
    "rust-analyzer.serverPath": "/home/omer/.cargo/bin/rust-analyzer",
}

but no luck.. Anyone know how to debug this? I checked other language-server
functions and they seem to work fine (warnings and errors, renaming, go-to-def
etc.). Screenshot below.

Screenshot_2020-05-25_11-34-59
Thanks again!!

I enabled all of these, currently I have this in my :CocConfig:

    "rust-analyzer.diagnostics.enable": true,
    "rust-analyzer.inlayHints.chainingHints": true,
    "rust-analyzer.inlayHints.typeHints": true,
    "rust-analyzer.inlayHints.parameterHints": true,
    "rust-analyzer.serverPath": "/home/omer/.cargo/bin/rust-analyzer",

I found the issue -- it's really stupid. For some reason (probably because I saw some zulip threads about this) I thought rust-analyzer and rls are the same thing now, and installed coc-rls instead of coc-rust-analyzer. It's working as expected now. Sorry for the noise!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.