New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow scope mappings to be refined via match rules #17738

merged 8 commits into from Jul 30, 2018


None yet
1 participant

queerviolet commented Jul 24, 2018

In the TextMate grammars, some tokens are highlighted differently based on their content. For example, document and exports and other common identifiers are colored differently than normal variables (even though they are technically normal variables).

Tree Sitter's highlighting system didn't support this... until now.

This PR adds tooling to TreeSitterLanguageMode enabling match rules on the RHS of a scope mapping in the atom grammar definition:


         'identifier': [
            {exact: 'exports', scopes: 'global'},
            {match: '^[A-Z_]+$', scopes: 'constant'},
            {match: '^[A-Z]', scopes: 'constructor'},

The first rule that matches is applied, so SOME_CONSTANT will resolve to the scope constant even though it also matches /^[A-Z]/. String rules (such as variable above) always match, applying the specified scope (a nicety for default cases).

@asheren asheren referenced this pull request Jul 27, 2018


Iteration Plan: July 23 - August 3, 2018 #17739

10 of 21 tasks complete

@queerviolet queerviolet merged commit bc8e70d into master Jul 30, 2018

3 checks passed

ci/circleci Your tests passed on CircleCI!
continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment