aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/code/src/highlighting.ts9
-rw-r--r--editors/code/src/scopes_mapper.ts12
2 files changed, 10 insertions, 11 deletions
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index bc19fae2f..b7dffaff5 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -66,15 +66,14 @@ export class Highlighter {
66 textDecoration?: string 66 textDecoration?: string
67 ): [string, vscode.TextEditorDecorationType] => { 67 ): [string, vscode.TextEditorDecorationType] => {
68 68
69 const foundRule = scopesMapper.toRule(tag, scopes.find) || scopes.find(tag) 69 const rule = scopesMapper.toRule(tag, scopes.find)
70 70
71 71 if (rule) {
72 72 const decor = createDecorationFromTextmate(rule);
73 if (foundRule) {
74 const decor = createDecorationFromTextmate(foundRule);
75 return [tag, decor]; 73 return [tag, decor];
76 } 74 }
77 else { 75 else {
76 console.log('Missing theme for: ' + tag);
78 const color = new vscode.ThemeColor('ralsp.' + tag); 77 const color = new vscode.ThemeColor('ralsp.' + tag);
79 const decor = vscode.window.createTextEditorDecorationType({ 78 const decor = vscode.window.createTextEditorDecorationType({
80 color, 79 color,
diff --git a/editors/code/src/scopes_mapper.ts b/editors/code/src/scopes_mapper.ts
index 5c3cb8f63..4534d8a32 100644
--- a/editors/code/src/scopes_mapper.ts
+++ b/editors/code/src/scopes_mapper.ts
@@ -8,11 +8,11 @@ let mappings = new Map<string, string[]>()
8 8
9 9
10const defaultMapping = new Map<string, string[]>([ 10const defaultMapping = new Map<string, string[]>([
11 ['comment', ['comment']], 11 ['comment', ['comment', 'comment.block', 'comment.line', 'comment.block.documentation']],
12 ['string', ['string']], 12 ['string', ['string']],
13 ['keyword', ['keyword']], 13 ['keyword', ['keyword']],
14 ['keyword.control', ['keyword.control', 'keyword', 'keyword.other']], 14 ['keyword.control', ['keyword.control', 'keyword', 'keyword.other']],
15 ['keyword.unsafe', ['storage.modifier', 'keyword.other', 'keyword.control']], 15 ['keyword.unsafe', ['storage.modifier', 'keyword.other', 'keyword.control', 'keyword']],
16 ['function', ['entity.name.function']], 16 ['function', ['entity.name.function']],
17 ['parameter', ['variable.parameter']], 17 ['parameter', ['variable.parameter']],
18 ['constant', ['constant', 'variable']], 18 ['constant', ['constant', 'variable']],
@@ -23,9 +23,9 @@ const defaultMapping = new Map<string, string[]>([
23 ['literal', ['string', 'string.quoted', 'string.regexp']], 23 ['literal', ['string', 'string.quoted', 'string.regexp']],
24 ['macro', ['support.other']], 24 ['macro', ['support.other']],
25 ['variable', ['variable']], 25 ['variable', ['variable']],
26 ['variable.mut', ['variable']], 26 ['variable.mut', ['variable', 'storage.modifier']],
27 ['field', ['variable.object.property']], 27 ['field', ['variable.object.property', 'meta.field.declaration', 'meta.definition.property', 'variable.other',]],
28 ['module', ['entity.name.section']] 28 ['module', ['entity.name.section', 'entity.other']]
29] 29]
30) 30)
31function find(scope: string): string[] { 31function find(scope: string): string[] {
@@ -33,7 +33,7 @@ function find(scope: string): string[] {
33} 33}
34 34
35export function toRule(scope: string, intoRule: (scope: string) => TextMateRuleSettings | undefined): TextMateRuleSettings | undefined { 35export function toRule(scope: string, intoRule: (scope: string) => TextMateRuleSettings | undefined): TextMateRuleSettings | undefined {
36 return find(scope).map(intoRule).find(rule => rule !== null) 36 return find(scope).map(intoRule).filter(rule => rule !== undefined)[0];
37} 37}
38 38
39 39