aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/highlighting.ts
diff options
context:
space:
mode:
authorSeivan Heidari <[email protected]>2019-10-27 16:57:11 +0000
committerSeivan Heidari <[email protected]>2019-10-27 16:57:11 +0000
commit0ddf47a7ab9d0f616e7296fa9a0b0eb786e4ee59 (patch)
tree80234db0e3af0d5f0b428a18f1b66f8fa2ba3bea /editors/code/src/highlighting.ts
parent5957b851e4451050151722598fa1ff9d41ccf0ff (diff)
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.
Diffstat (limited to 'editors/code/src/highlighting.ts')
-rw-r--r--editors/code/src/highlighting.ts11
1 files changed, 7 insertions, 4 deletions
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');
2import * as vscode from 'vscode'; 2import * as vscode from 'vscode';
3import * as lc from 'vscode-languageclient'; 3import * as lc from 'vscode-languageclient';
4import * as scopes from './scopes' 4import * as scopes from './scopes'
5 5import * as scopesMapper from './scopes_mapper';
6 6
7import { Server } from './server'; 7import { Server } from './server';
8 8
@@ -65,10 +65,13 @@ export class Highlighter {
65 tag: string, 65 tag: string,
66 textDecoration?: string 66 textDecoration?: string
67 ): [string, vscode.TextEditorDecorationType] => { 67 ): [string, vscode.TextEditorDecorationType] => {
68 const scope = scopes.find(tag)
69 68
70 if (scope) { 69 const foundRule = scopesMapper.toRule(tag, scopes.find) || scopes.find(tag)
71 const decor = createDecorationFromTextmate(scope); 70
71
72
73 if (foundRule) {
74 const decor = createDecorationFromTextmate(foundRule);
72 return [tag, decor]; 75 return [tag, decor];
73 } 76 }
74 else { 77 else {