0
votes

I am writing a syntax highlighter for Sublime Text 3, but I am facing problem of find the correct scope for syntax. For example

  constants:
    - match: \b(true|false)\b
      scope: constants.language.boolean
    - match: \b(void|new)\b
      scope: constants.language

# operators
  operators:
    - match: \b(and|or|not)\b
      scope: keyword.operator.logical
    - match: \b(\+=|-=|*=|\/=|%=|==|!=|<=|>=|<|>|\+|-|\*|\/|%|\^)\b
      scope: keyword.operator.arithmetic

How do I know scope of and, +=, true, false etc.

Where are all the available scope syntax present?

Can anyone direct me to it's documentation/source code? Any help will be appreciated.
I found this official page on syntax highlighting https://www.sublimetext.com/docs/3/syntax.html, but it didn't help much.

Thanks

1

1 Answers

2
votes

You should read through the existing .sublime-syntax files, located on Github at sublimehq/Packages, for the standards that are being used. I'd also suggest using the ScopeHunter and ScopeAlways plugins when viewing files in other languages to determine which scopes are active at a given point.

Here are some other resources:

There are no hard-and-fast "standards" as such, but trying to follow the TextMate conventions is a good idea. If the language you're writing the definition for is similar to an existing language, you can also use that as a template. However, every definition is slightly different, so don't be afraid to make up your own unique selectors if necessary.