posit-dev / positron

Positron, a next-generation data science IDE
Other
2.5k stars 76 forks source link

R: Excessive highlighting of identifiers #3688

Open lionel- opened 3 months ago

lionel- commented 3 months ago

With a dark theme here is how R code looks like:

Screenshot 2024-06-24 at 20 28 52 (1)

Compare this to the same theme with Rust code:

Screenshot 2024-06-24 at 20 28 47 (1)

The highlighting in the R file seems excessive because every single token is styled with a colour. I think that suggests something is off with our tm grammar?

Here is the tm info (obtained with editor.action.inspectTMScopes) for an R identifier:

Screenshot 2024-06-28 at 11 23 19

And for a Rust one:

Screenshot 2024-06-28 at 11 22 52

I don't know much about these grammars but the keyword.operator scope stands out to me in the R case.

ntluong95 commented 3 months ago

Yes Positron currently highlights normal identifiers as keywords, which is strange

gvelasq commented 2 months ago

Adding here for consideration, as mentioned here, since this issue tracks syntax highlighting for Positron.

It would be great if the 'classic' RStudio themes were available in Positron. A good example is RStudio's Tomorrow Night Bright, which is better suited for R code than Microsoft's VS Code extension.

strengejacke commented 2 months ago

I think some changes should be made to the syntax highlighting in R, to better distinguish tokens/symbols. Take this code for example:

  lapply(l, function(component) {
    unlist(sapply(
      parameters,
      function(pattern) {
        grep(pattern = pattern, x = component, perl = TRUE, value = TRUE)
      },
      simplify = FALSE
    ), use.names = FALSE)
  })

At least I use colored brackets, else these would probably also all be in one color:

image

Here are some suggestions, actually order of importance (for me personally):

  1. I think, argument names should have a different color than reserved words (FALSE, function, if, ...).
  2. Maybe +, -, = etc. should get a different color than the default grey that also get variables
  3. Maybe function definitions / functions names where these are defined could get a separate color, not default grey. image

3rd point is also not found in VSCode, but the first two points can be found in the syntax highlight of VSCode:

Positron

image

VSCode

image

Setup

Positron Version: 2024.07.0 (system setup) build 2024.07.0-89 Code - OSS Version: 1.91.0 Commit: 08b25a7c9a8ce879674850f76728517302bc91e3 Date: 2024-07-23T03:23:04.686Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Windows_NT x64 10.0.22631

Version: 1.91.1 (system setup) Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729 Date: 2024-07-09T22:06:49.809Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Windows_NT x64 10.0.22631

lionel- commented 1 month ago

Tentatively bumping this to the 2024.10 milestone as I think the R experience can be currently quite bad with certain themes.