vscode-R icon indicating copy to clipboard operation
vscode-R copied to clipboard

R syntax highlighting broken: variables not recognized as token, appear as plain white

Open leaves1021 opened this issue 7 months ago • 6 comments

Bug Description

After updating all my VSCode extensions today (including the R extension by REditorSupport), I noticed that R variables are no longer highlighted correctly. All variables appear as plain white text, while other elements (e.g., strings, functions, comments) are highlighted properly.

Using Developer: Inspect Editor Tokens and Scopes, I found that variables are only assigned the scope source.r, with no variable.other.r or other fine-grained scopes. As a result, my theme does not apply any color to variables.

Environment

  • VSCode version: 1.102.2.0
  • R extension version: R 2.8.6
  • R Syntax extension version: 0.1.3
  • Operating system: Windows 11 Pro (build 26100.4770)
  • Color theme: Pink Cat Boo

Steps to Reproduce

  1. Install the latest R and R Syntax extensions
  2. Open any .R file in VSCode
  3. Highlight any variable and run Developer: Inspect Editor Tokens and Scopes
  4. Observe that the scope is only source.r, with no variable-specific token
  5. Variable remains white regardless of theme
Image

Additional Info

  • Reinstalling / downgrading the R extension does not help
  • Changing color themes does not solve the issue
  • This issue did not occur before I updated all extensions today
  • Other users have reported similar issues recently

Expected Behavior

Variables in R files should be recognized with appropriate token scopes like variable.other.r, so that themes can apply custom colors.

Please let me know if I can help test or trace further.

Thank you for maintaining this extension!

leaves1021 avatar Jul 23 '25 18:07 leaves1021

I encountered similar problem, but its function syntax hightlight. The base R got function syntax highlight, but the the definied function and tidyverse functions are no syntax highlight.

Environment

  • VSCode version: 1.103.0
  • R extension version: R 2.8.6
  • R Syntax extension version: 0.1.3
  • Operating system: Windows 11 Enterprise, 24H2, 26100.4770, WSL2 Ubuntu 24.04.1 LTS
  • Color theme: Github Dark
Image

grgrzhong avatar Aug 08 '25 02:08 grgrzhong

I encountered the same problem, have you found a solution?I currently only use the following statement in the setting.json

Image Image

rxz1l avatar Aug 15 '25 14:08 rxz1l

I encountered the same problem, have you found a solution?I currently only use the following statement in the setting.json

Image Image

Unfortunately, the issue still persists for me. I’ve already updated both VSCode and the relevant extensions (R and R Syntax) to their latest versions, but variables are still not being highlighted — they only appear as plain white text. So far, I haven’t found a workaround that restores the previous variable highlighting.

leaves1021 avatar Aug 15 '25 15:08 leaves1021

I think this is duplicate of REditorSupport/languageserver#692

eitsupi avatar Aug 15 '25 15:08 eitsupi

I encountered the same problem, have you found a solution?I currently only use the following statement in the setting.json Image Image

I mostly copy-pasted from @rxz1l and tweaked a little, and finally got the following that seems to be working (and seems to be roughly replicating RStudio function coloring):

  "editor.tokenColorCustomizations": {
    "textMateRules": [
      {
        "scope": [
          "support.function.r",
          "entity.name.function.r",
          "meta.function-call.r",
        ],
        "settings": {
          "foreground": "#61AFEF",
          "fontStyle": "",
        },
      },
      {
        "scope": "meta.function-call.arguments.r",
        "settings": { "foreground": "#ABB2BF" },
      },
    ],
  },

Here's the result (with Atom One Dark theme): Image

The second scope for "meta.function-call.arguments.r" is to set the foreground color back to the default foreground color for the arguments, because those arguments are both "meta.function-call.arguments.r" and "meta.function-call.r". Without this override, the arguments will be colored in the same way as the function calls. If you have other default foreground colors, you might need to change it.

Hope it helps.

fangzhou-xie avatar Dec 06 '25 20:12 fangzhou-xie

Why not revert to the original behavior and wait for the language server to implement semanticTokens? This kind of breaking change is quite frustrating to use.

Yunuuuu avatar Dec 10 '25 03:12 Yunuuuu