Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes fix a number of syntax higlighting issues caused by our TextMate grammar for R. Addresses #3688.
We are currently styling most of R variables as keywords or constants, which looks jarring with many themes. With the following changes we now style R variables with the conventional
variable.parameter
andvariable.object
scopes:The scopes of identifiers are renamed from
constant.other
tovariable.object
and fromentity.name.tag
tovariable.parameter
.To ensure these scopes are not overridden by a larger entity scope, we no longer use
keyword.operator
for bracket scopes, butmeta.bracket
. This is the appropriate scope prefix for large components in the code, see https://macromates.com/manual/en/language_grammars. This particular scope,meta.bracket
, is not as popular as the ones discussed above but is used in the ObjC and Julia grammars.Similarly, we no longer scope function definitions as
keyword
but asmeta.function.definition
, the convention scope for these entities.These changes allow colour themes to style R code much more consistently as they do other languages.
Before with Material:
After with Material:
Before with Monokai:
After with Monokai:
Note how these are less heavily styled.
We see kind of the opposite pattern with the default themes because they surprisingly seem to weigh more heavily regular text as opposed to keyword:
Before with Positron Light:
After with Positron Light:
Before with Positron Dark:
After with Positron Dark:
That said, this makes R styling consistent with how the theme works with other languages, here is how Positron Light and Dark style a C file for comparison: