atom/language-php

Interpolation brace style

Opened this issue · 5 comments

Prerequisites

Description

I am comming from the VS Code repository, and I have some problems with syntax highlighting. When writing this code:

<?php
$example = "example";
$somevar = "{$example}_{$example}";
echo $somevar;

Most things are highlighted correctly, but the {} symbols don't look right.

Bildschirmfoto 2022-04-22 um 15 34 19

Steps to Reproduce

Copy the above code snippet into an editor using this repository's syntax for highlighting.

Expected behavior:

The braces should be blue like in most other languages.

Example JavaScript:
Bildschirmfoto 2022-04-22 um 15 36 34

Actual behavior:

The braces have string color which looks weird.

Braces have punctuation.definition.variable.php token, which seems to be correct. But themes are using only variable.other.php (probably variable) which starts at $. I could probably extend variable scope to include braces, especially since " ${example} " is correctly colored.

You can make temporary fix using:

  "editor.tokenColorCustomizations": {
    "textMateRules": [
      {
        "scope": [
          "string.quoted.double.php punctuation.definition.variable.php",
          "string.unquoted.heredoc.php punctuation.definition.variable.php"
        ],
        "settings": {
          "foreground": "#9CDCFE"
        }
      }
    ]
  },

Edit: Extending scope might be problematic with complex syntax like: " {$example->foo()} ". Which theme are you using?

I tried the configuration you provided, but for some reason it doesn't only change the braces, but also every dollar symbol in the file:
Bildschirmfoto 2022-04-25 um 07 18 44

Also I am using Dark+ (default in VS Code).

@blaumeise20 Yes, but I've edited to do this only in strings, and with the correct color (#9CDCFE) it doesn't matter. Try edited configuration.

Oh, ok, I tried the new configuration, it works better, but still makes the dollar sign blue inside strings (also I want to have that dark blue color like in JS, not the variable color).

but still makes the dollar sign blue inside strings

I don't understand that, shouldn't dollar sign be blue there?

You can make 2 rules, one to make braces colored, second one to restore dollar color:

      {
        "scope": [
          "string.quoted.double.php punctuation.definition.variable.php",
          "string.unquoted.heredoc.php punctuation.definition.variable.php"
        ],
        "settings": {
          "foreground": "#569CD6"
        }
      },
      {
        "scope": [
          "string variable punctuation.definition.variable.php",
          "string variable punctuation.definition.variable.php"
        ],
        "settings": {
          "foreground": "#9CDCFE"
        }
      },

With Commands (ctrl+shift+p) -> Developer: Inspect Editor Tokens and Scopes you can check names of tokens under the cursor.