aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/scopes.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/scopes.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/scopes.ts')
-rw-r--r--editors/code/src/scopes.ts18
1 files changed, 9 insertions, 9 deletions
diff --git a/editors/code/src/scopes.ts b/editors/code/src/scopes.ts
index c9c01ba1d..470ee716f 100644
--- a/editors/code/src/scopes.ts
+++ b/editors/code/src/scopes.ts
@@ -16,16 +16,16 @@ export interface TextMateRuleSettings {
16} 16}
17 17
18// Current theme colors 18// Current theme colors
19const colors = new Map<string, TextMateRuleSettings>() 19const rules = new Map<string, TextMateRuleSettings>()
20 20
21export function find(scope: string): TextMateRuleSettings | undefined { 21export function find(scope: string): TextMateRuleSettings | undefined {
22 return colors.get(scope) 22 return rules.get(scope)
23} 23}
24 24
25// Load all textmate scopes in the currently active theme 25// Load all textmate scopes in the currently active theme
26export function load() { 26export function load() {
27 // Remove any previous theme 27 // Remove any previous theme
28 colors.clear() 28 rules.clear()
29 // Find out current color theme 29 // Find out current color theme
30 const themeName = vscode.workspace.getConfiguration('workbench').get('colorTheme') 30 const themeName = vscode.workspace.getConfiguration('workbench').get('colorTheme')
31 31
@@ -95,21 +95,21 @@ function loadColors(textMateRules: TextMateRule[]): void {
95 for (const rule of textMateRules) { 95 for (const rule of textMateRules) {
96 96
97 if (typeof rule.scope === 'string') { 97 if (typeof rule.scope === 'string') {
98 const existingRule = colors.get(rule.scope); 98 const existingRule = rules.get(rule.scope);
99 if (existingRule) { 99 if (existingRule) {
100 colors.set(rule.scope, mergeRuleSettings(existingRule, rule.settings)) 100 rules.set(rule.scope, mergeRuleSettings(existingRule, rule.settings))
101 } 101 }
102 else { 102 else {
103 colors.set(rule.scope, rule.settings) 103 rules.set(rule.scope, rule.settings)
104 } 104 }
105 } else if (rule.scope instanceof Array) { 105 } else if (rule.scope instanceof Array) {
106 for (const scope of rule.scope) { 106 for (const scope of rule.scope) {
107 const existingRule = colors.get(scope); 107 const existingRule = rules.get(scope);
108 if (existingRule) { 108 if (existingRule) {
109 colors.set(scope, mergeRuleSettings(existingRule, rule.settings)) 109 rules.set(scope, mergeRuleSettings(existingRule, rule.settings))
110 } 110 }
111 else { 111 else {
112 colors.set(scope, rule.settings) 112 rules.set(scope, rule.settings)
113 } 113 }
114 } 114 }
115 } 115 }