Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Interpolation brace style #454

Open
1 task done
blaumeise20 opened this issue Apr 22, 2022 · 5 comments
Open
1 task done

Interpolation brace style #454

blaumeise20 opened this issue Apr 22, 2022 · 5 comments

Comments

@blaumeise20
Copy link

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.

@KapitanOczywisty
Copy link
Contributor

KapitanOczywisty commented Apr 22, 2022

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?

@blaumeise20
Copy link
Author

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).

@KapitanOczywisty
Copy link
Contributor

@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.

@blaumeise20
Copy link
Author

blaumeise20 commented Apr 25, 2022

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).

@KapitanOczywisty
Copy link
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants