From 0ddf47a7ab9d0f616e7296fa9a0b0eb786e4ee59 Mon Sep 17 00:00:00 2001 From: Seivan Heidari Date: Sun, 27 Oct 2019 17:57:11 +0100 Subject: Introducing a Scopes Mapper to map from RA scopes to TextMate scopes with fallbacks. Current scopes defined: ``` ['keyword.unsafe', ['storage.modifier', 'keyword.other', 'keyword.control']], ['function', ['entity.name.function']], ['parameter', ['variable.parameter']], ['type', ['entity.name.type']], ['builtin', ['variable.language', 'support.type', 'support.type']], ['text', ['string', 'string.quoted', 'string.regexp']], ['attribute', ['keyword']], ['literal', ['string', 'string.quoted', 'string.regexp']], ['macro', ['support.other']], ['variable.mut', ['variable']], ['field', ['variable.object.property']], ['module', ['entity.name.section']] ``` Need to complement with further fallbacks as some themes fail. --- editors/code/src/highlighting.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'editors/code/src/highlighting.ts') diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts index 4b961170b..bc19fae2f 100644 --- a/editors/code/src/highlighting.ts +++ b/editors/code/src/highlighting.ts @@ -2,7 +2,7 @@ import seedrandom = require('seedrandom'); import * as vscode from 'vscode'; import * as lc from 'vscode-languageclient'; import * as scopes from './scopes' - +import * as scopesMapper from './scopes_mapper'; import { Server } from './server'; @@ -65,10 +65,13 @@ export class Highlighter { tag: string, textDecoration?: string ): [string, vscode.TextEditorDecorationType] => { - const scope = scopes.find(tag) - if (scope) { - const decor = createDecorationFromTextmate(scope); + const foundRule = scopesMapper.toRule(tag, scopes.find) || scopes.find(tag) + + + + if (foundRule) { + const decor = createDecorationFromTextmate(foundRule); return [tag, decor]; } else { -- cgit v1.2.3