Where to find a list of scopes for Sublime2 (or textMate?)

前端 未结 7 906
栀梦
栀梦 2021-01-29 23:11

in .tmTheme files the scope key defines how a element is highlighted:

    
        name
        HTML: Attribute          


        
7条回答
  •  无人及你
    2021-01-29 23:34

    Each syntax can name their own scopes, but they are based off of this list. For instance your syntax might specify that function is storage.type.function.js scope. If your theme supports that directly it will use that color, otherwise it will fallback to storage.type.function then storage.type then finally storage trying to find a color in your theme.

    Since you are creating your own style, I would recommend installing ScopeStatus (CTRL+SHIFT+P, then Install Package, then ScopeStatus). Looking at a file using the syntax you want to concentrate on, do CTRL+SHIFT+P, then "Scope: Show in Status Bar". Now you can move the cursor to various elements to see what scope they give and you can use those to define colors.

    You can check your themes to see what they do, go to "Preferences->Browse Packages" to open the folder where your packages are stored. I installed "Theme - Phoenix" which has a folder and a "Color Scheme" folder underneath. In one of the theme files I found 16 colors that were used for various scopes:

    keyword.operator.class, constant.other, source.php.embedded.line
    variable, support.other.variable, string.other.link, entity.name.tag, entity.other.attribute-name, meta.tag, declaration.tag
    constant.numeric, constant.language, support.constant, constant.character, variable.parameter, punctuation.section.embedded, keyword.other.unit
    entity.name.class, entity.name.type.class, support.type, support.class
    string, constant.other.symbol, entity.other.inherited-class, markup.heading
    keyword.operator, constant.other.color
    entity.name.function, meta.function-call, support.function, keyword.other.special-method, meta.block-level
    keyword, storage, storage.type, entity.name.tag.css
    invalid
    meta.separator
    invalid.deprecated
    markup.inserted.diff, markup.deleted.diff, meta.diff.header.to-file, meta.diff.header.from-file
    markup.inserted.diff, meta.diff.header.to-file
    markup.deleted.diff, meta.diff.header.from-file
    meta.diff.header.from-file, meta.diff.header.to-file
    meta.diff.range
    

    Different themes might have different settings, for keyword.operator.class in the first group might have its own color or be the same as meta.diff.range.

提交回复
热议问题