Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ugovaretto/8d29530fa26ec67cbe31b55ee5956db1 to your computer and use it in GitHub Desktop.
Save ugovaretto/8d29530fa26ec67cbe31b55ee5956db1 to your computer and use it in GitHub Desktop.

Rust-Analyzer Customization Tips

Customize mutable style

Video - Rust Tip - Customize Mutable Colors in VSCode

In the settings.json add the following:

    "editor.semanticTokenColorCustomizations": {
        "enabled": true,
        "rules": {
            "*.mutable": {
                "underline": false,
                "foreground": "#d9bbfc"
            }
        }		
    },

Note: If you already have one or more "editor.semanticTokenColorCustomizations" rules already, just add the rule above.

Toggle inlay

Video - Rust Tip - Rust Analyzer Toggle Inlays

  1. Install Settings Cycler VSCode extension.

  2. In the user keybindings.json add the following key mapping to the array.

	{
		"key": "cmd+y", // key to press to activate command
		"command": "settings.cycle", // `settings.cycle` is the command that's actually being run, from the extension `hoovercj.vscode-settings-cycler`
		"when": "editorTextFocus && editorLangId == 'rust'", // this keybinding is only active when (editor is in focus) and (the language is `rust`)
		"args": { // these are the arguments passed to `settings.cycle`
			"id": "rust-toggle-inlay-hints", // must be unique
			"overrideWorkspaceSettings": true,
			"values": [ // Note: use the same settings in each values object
				{
					"rust-analyzer.inlayHints.enable": false // sets the inlay hints off
				},
				{
					"rust-analyzer.inlayHints.enable": true // sets the inlay hints on
				}
			]
		}
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment