question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add an option not to highlight variable references but only declarations/definitions

See original GitHub issue

Describe what you want In VSCode this theme highlights variable references in the same color (coral red) as variable declarations/definitions. In some cases, such as when variables are referenced many times in a code block, the visual effect is a large area of red on screen and it’s not easy to tell the definitions out of references. Another case is when assigning local variables to keyword arguments in Python, in which both argument names and values are in red and look basically the same, unless Italic options is turned on.

My request is to have an option that disables highlighting variable references, so definitions are in red and references are in plain white color. In this way the definitions/declarations easily stand out at first glance. It would be great to keep function calls blue unchanged.

Additional context The attached screenshot compares the highlighting effects between Emacs and VSCode with one dark pro themes. This SO post shows an Atom screenshot. It looks local variables are not highlighted in Atom either, just obj members are highlighted. As the first answer points out, “The purpose of syntax highlighting in text editors is to make important code structures stand out.” IMHO, variable declarations/definitions are more important than their uses, so they should be made stand out of their references. But for highlighting function calls, this one dark pro theme in VSCode make them blue and it definitely looks better than the Emacs one.

Screenshot_20211207

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
0liucommented, May 18, 2022

@skilkis Thank you for the guide! With the following settings, I got exactly what I want:

    "editor.semanticTokenColorCustomizations": {
        "[One Dark Pro Flat]": {
          "rules": {
            "variable:python": "#ABB2BF",
            "variable.declaration": "#e06c75",
            "property:python": "#ABB2BF"
          }
        }
      }
0reactions
skilkiscommented, May 17, 2022

@0liu it’s possible to differentiate between module constants as well with the following rule, but not between global and local variables 😞

  "variable.readonly:python": "#D19A66"

To customize the semantic token colors further you can use the VS Code command: Developer: Inspect Editor Tokens and Scopes which will bring up a window with token information.

image

Using the above, I had made a configuration for myself that I’ve included below. Feel free to adapt / extend it! Happy hacking 😄

  "editor.semanticTokenColorCustomizations": {
    "[One Dark Pro Flat]": {
      "rules": {
        "variable:python": "#ABB2BF",
        "variable.readonly:python": "#D19A66",
        "property:python": "#ABB2BF",
        "module:python": "#ABB2BF",
        "*.builtin:python": "#56B6C2",
        "intrinsic:python": "#e06c75",
        "module.decorator:python": "#61AFEF",
        "property.decorator:python": "#61AFEF"
      }
    }
  },
Read more comments on GitHub >

github_iconTop Results From Across the Web

Eclipse does not highlight matching variables
Try: window > preferences > java > editor > mark occurrences. Select all options available there. Also go to: Preferences > General >...
Read more >
References not highlighting all instances of the variable
When I place the caret on a reference, I would expect all the instances of that variable to be automatically highlighted, but instead...
Read more >
Service Portal - Catalog item variable reference qualifier ...
So I have a variable called 'u_natural_gas' that is a simple select box. The second choice is 'u_system' and is a lookup select...
Read more >
Bug List - Bugs - Eclipse
ID Product Comp Assignee Status Changed 187173 WTP Sour wst.dtd wst.dtd‑inbox NEW 2013‑06‑19 406093 JDT Text jdt‑text‑inbox ASSI 2015‑12‑22 564955 JDT UI jdt‑ui‑inbox ASSI 2022‑08‑04
Read more >
Referencing Actors
A How To Guide for Referencing Actors in Unreal Engine 4. ... Click the Compile button then return to the Main Editor window...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found