nvim-metals icon indicating copy to clipboard operation
nvim-metals copied to clipboard

Add support for inlayHints settings

Open perrin4869 opened this issue 1 year ago • 1 comments

Describe the feature

https://scalameta.org/metals/docs/editors/user-configuration#should-display-type-annotations-for-inferred-types Right now we get an error message:

[nvim-metals] "inlayHints" is not a valid setting. It will be ignored.

Potential ways to implement

No response

perrin4869 avatar Apr 16 '24 12:04 perrin4869

Can this be implemented before Neovim 0.10? Afaik the lsp.inlay_hint feature is not stable yet.

KristianAN avatar Apr 25 '24 10:04 KristianAN

I've tried this in Neovim 0.10, and inlay hints already seem to be working. You can enable the inlay hints using vim.lsp.inlay_hints.enable(true). In the metals configuration, you'll have to enable some nvim-metals settings that seem to correspond with the Metals settings from the link in the OP:

  • settings.showInferredType = true seems to match with inlayHints.inferredTypes.enable and inlayHints.typeParameters.enable
  • settings.showImplicitArguments = true seems to match with inlayHints.implicitArguments.enable
  • settings.showImplicitConversionsAndClasses = true seems to match with inlayHints.implicitConversions.enable

There doesn't seem to be one that matches with inlayHints.hintsInPatternMatch.enable.

jqno avatar Jul 10 '24 06:07 jqno

Included in https://github.com/scalameta/nvim-metals/pull/689.

ckipp01 avatar Sep 16 '24 13:09 ckipp01

Adding this to the config does not seem to work for me 🤔

inlayHints = {
  hintsInPatternMatch = { enable = true },
  implicitArguments = { enable = true },
  implicitConversions = { enable = true },
  inferredTypes = { enable = true },
  typeParameters = { enable = true },
}

Metals is latest.snapshot (1.3.5+118-eb2cdb82-SNAPSHOT) and scala version 2.13.12 in the build. No errors in logs either. Is there something else to be done for this to work?

taras-biletskyi avatar Sep 19 '24 09:09 taras-biletskyi