4

I'm working on my first compiler as a bit of training project. I'd also like to create a small syntax highlighting project.

Looking at the default tmLanguage file, it's unclear to me what triggers a color. For example, I see the string type does in fact trigger string coloring when I debug, but what causes this? The 'strings' name of the repo? How does that connect to the coloring theme? Where can I see a list of names for default themes, etc.?

Looking at the examples, they seem to jump over a lot of info, so I'm not sure where to start on some things.

{
    "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
    "name": "N",
    "patterns": [
        {
            "include": "#keywords"
        },
        {
            "include": "#strings"
        }
    ],
    "repository": {
        "keywords": 
        {
            "patterns":
             [{
                "name": "keyword.control.n",
                "match": "\\b(if|while|for|return)\\b"
            }]
        },
        "strings": 
        {
            "name": "string.quoted.double.n",
            "begin": "\"",
            "end": "\"",
            "patterns": [
                {
                    "name": "constant.character.escape.n",
                    "match": "\\\\."
                }
            ]
        }
    },
    "scopeName": "source.N"
}
Michael
  • 8,362
  • 6
  • 61
  • 88
Chase R Lewis
  • 2,119
  • 1
  • 22
  • 47
  • 2
    Possible duplicate of [Where can I find a list of all possible keys for tm-themes for syntax highlighting?](https://stackoverflow.com/questions/42116486/where-can-i-find-a-list-of-all-possible-keys-for-tm-themes-for-syntax-highlighti) – Gama11 Jun 08 '18 at 08:10
  • i would say no. i want to know how to link a grammar item to a color. not just link a new theme. – Chase R Lewis Jun 08 '18 at 16:22
  • 4
    You can't really directly "link a grammar item to a color" - you can only specify "scopes", and then a _theme_ does the coloring based on those. If you could do that, that would break theming support. – Gama11 Jun 08 '18 at 16:40
  • No offense linking to a scope that links to a color is still linking to a color. How are these scopes defined? That is the entirety of the question how does one know what 'scopes' or names are linked to default theme colors. – Chase R Lewis Jun 11 '18 at 16:52
  • 1
    Have you read my StackOverflow answer I linked to? I answer that exact question there and even link to the default theme color definitions in the VSCode repo. – Gama11 Jun 11 '18 at 17:56
  • Ah I see, 100% my bad. Thank you very much. I only went to the answer I didn't continue onto the git where the actual names are. I didn't see the answer in that post and thought it wasn't what I was looking for. Much appreciated! – Chase R Lewis Jun 11 '18 at 18:02
  • No worries, glad the answer helped. – Gama11 Jun 11 '18 at 20:16

0 Answers0