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

Is there a setting to change the color of inlay hints? #4334

Closed
schungx opened this issue May 6, 2020 · 17 comments
Closed

Is there a setting to change the color of inlay hints? #4334

schungx opened this issue May 6, 2020 · 17 comments

Comments

@schungx
Copy link

schungx commented May 6, 2020

The current color is too similar to the code text, making code harder to read. I'd prefer a much lighter color - you only need to read it when you want to know the type.

@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented May 6, 2020

Currently in VSCode, there's a way to change the text color using the rust_analyzer.inlayHint color setting for your theme:
https://github.com/rust-analyzer/rust-analyzer/blob/30eb458b4fa8adcecd8cbf731bd1cfa9a7a8b88b/editors/code/package.json#L504

There's a way to tweak hints' colors more, here are all possible options: https://vshaxe.github.io/vscode-extern/vscode/ThemableDecorationAttachmentRenderOptions.html , but this requires the code changes in here: https://github.com/rust-analyzer/rust-analyzer/blob/30eb458b4fa8adcecd8cbf731bd1cfa9a7a8b88b/editors/code/src/inlay_hints.ts#L46

@schungx
Copy link
Author

schungx commented May 6, 2020

Worked beautifully. Thanks.

Add the following to settings.json:

"workbench.colorCustomizations": {
    "rust_analyzer.inlayHint": "#bbbbbb"
},

Of course, change #bbbbbb to whatever color you fancy.

@schungx schungx closed this as completed May 6, 2020
@dbsxdbsx
Copy link

dbsxdbsx commented Jul 8, 2021

@schungx , just update that the way you mentioned is no longer valid, new way to figure this out is like this:

        "rust_analyzer.inlayHints.foreground": "#2E8B57",
        "rust_analyzer.inlayHints.background": "#3d3d3d48",
        // Overrides for specific kinds of inlay hints
        // "rust_analyzer.inlayHints.foreground.typeHints": "#fdb6fdf0",
        // // "rust_analyzer.inlayHints.foreground.paramHints": "#fdb6fdf0",
        // "rust_analyzer.inlayHints.background.chainingHints": "#6b0c0c81",

referring to : https://rust-analyzer.github.io/manual.html.

@schungx
Copy link
Author

schungx commented Jul 8, 2021

Somehow the new way is not working... The old way with workbench.colorCustomizations works... I suppose it'll be there for the up-coming version?

@schungx schungx reopened this Jul 8, 2021
@Veykril
Copy link
Member

Veykril commented Jul 8, 2021

Make sure your rust-analyzer is up to date, this change should be a bit older no already I believe.

@schungx
Copy link
Author

schungx commented Jul 8, 2021

It is the latest version already.

And it doesn't work, the setting is grayed out... see screenshot:

image

@Veykril
Copy link
Member

Veykril commented Jul 8, 2021

Ah, it should say rust-analyzer.inlayHints.forground instead of rust_analyzer.inlayHints.forground(note the _ vs -).

@schungx
Copy link
Author

schungx commented Jul 8, 2021

Nope... changed it and still not working. Still grayed out.

I think the setting is still not correct...

@lnicola
Copy link
Member

lnicola commented Jul 8, 2021

That preference doesn't exist, it needs to be set in workbench.colorCustomizations, see https://rust-analyzer.github.io/manual.html#color-configurations. What do you mean by "the old way"?

@schungx
Copy link
Author

schungx commented Jul 8, 2021

What do you mean by "the old way"?

The old way is the workbencch.colorCustomizations way...

@schungx schungx closed this as completed Jul 8, 2021
@sgon00
Copy link

sgon00 commented Mar 19, 2022

Screenshot_20220320_013436

Hi, I am running the latest version and copy the setup jsonc code from manuall. It just does NOT work at all. What's the problem?

I have no ideas why this bug is opened and closed several times and nobody really mentioned what the cause is and how to fix it.

@Plasmatium
Copy link

That preference doesn't exist, it needs to be set in workbench.colorCustomizations, see https://rust-analyzer.github.io/manual.html#color-configurations. What do you mean by "the old way"?

This works for me

{
  "workbench.colorTheme": "rustdoc dark",
  //   "editor.inlayHints.fontSize": 11,
  "editor.inlayHints.fontFamily": "Courier New",
  "workbench.colorCustomizations": {
    // Name of the theme you are currently using
    "[rustdoc dark]": {
      "editorInlayHint.foreground": "#888a",
      "editorInlayHint.background": "#0000"
      // Overrides for specific kinds of inlay hints
      // "editorInlayHint.typeForeground": "#fdb6fdf0",
      // "editorInlayHint.parameterForeground": "#fdb6fdf0",
    }
  }
}

image

@leonyu879
Copy link

leonyu879 commented Dec 25, 2022

That preference doesn't exist, it needs to be set in workbench.colorCustomizations, see https://rust-analyzer.github.io/manual.html#color-configurations. What do you mean by "the old way"?

This works for me

{
  "workbench.colorTheme": "rustdoc dark",
  //   "editor.inlayHints.fontSize": 11,
  "editor.inlayHints.fontFamily": "Courier New",
  "workbench.colorCustomizations": {
    // Name of the theme you are currently using
    "[rustdoc dark]": {
      "editorInlayHint.foreground": "#888a",
      "editorInlayHint.background": "#0000"
      // Overrides for specific kinds of inlay hints
      // "editorInlayHint.typeForeground": "#fdb6fdf0",
      // "editorInlayHint.parameterForeground": "#fdb6fdf0",
    }
  }
}
image

hi @Plasmatium what theme and font do you use? it looks nice.

@Plasmatium
Copy link

Hi @yuhongyu879 please refer to the settings below. I remove the [rustdoc dark] block to make all themes affected

{
    "editor.fontFamily": "Cascadia Code PL",
    "editor.fontLigatures": true,
    "editor.fontSize": 14,
    "workbench.colorTheme": "Mariana Pro (Gray)",
    "editor.inlayHints.fontFamily": "Courier New",
    "workbench.colorCustomizations": {
        "editorInlayHint.foreground": "#888a",
        "editorInlayHint.background": "#0000",
    },
    "editor.tokenColorCustomizations": {
        "keywords": {
            "fontStyle": "bold"
        }
    },
}

@yoniamir
Copy link

@Plasmatium This worked for me. Thanks!

@mark-pictor-csec
Copy link

I tried to add @Plasmatium's editorInlayHint lines to a folder's settings.js. They had no effect, and when I moused over the settings I got an incredibly cryptic error, presented as a tooltip:

This setting cannot be applied in this workspace. It will be applied when you open the containing workspace folder directly.

In retrospect, I probably should have interpreted this as meaning to put the settings in the workspace file, as I eventually tried that and it worked.

// workspace file
{
        // ...
	"settings": {
		"workbench.colorCustomizations": {
			"editorInlayHint.foreground":"#bc0a",
			"editorInlayHint.background":"#0000"
		}
	}
}

@piavgh
Copy link

piavgh commented Aug 25, 2023

That preference doesn't exist, it needs to be set in workbench.colorCustomizations, see https://rust-analyzer.github.io/manual.html#color-configurations. What do you mean by "the old way"?

This works in 2023

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

No branches or pull requests