aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/code/package-lock.json5
-rw-r--r--editors/code/src/highlighting.ts4
-rw-r--r--editors/code/src/scopes.ts10
-rw-r--r--editors/code/src/scopes_mapper.ts17
4 files changed, 20 insertions, 16 deletions
diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json
index 4c5c13646..67081f3fd 100644
--- a/editors/code/package-lock.json
+++ b/editors/code/package-lock.json
@@ -750,6 +750,11 @@
750 "esprima": "^4.0.0" 750 "esprima": "^4.0.0"
751 } 751 }
752 }, 752 },
753 "jsonc-parser": {
754 "version": "2.2.0",
755 "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.2.0.tgz",
756 "integrity": "sha512-4fLQxW1j/5fWj6p78vAlAafoCKtuBm6ghv+Ij5W2DrDx0qE+ZdEl2c6Ko1mgJNF5ftX1iEWQQ4Ap7+3GlhjkOA=="
757 },
753 "lines-and-columns": { 758 "lines-and-columns": {
754 "version": "1.1.6", 759 "version": "1.1.6",
755 "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", 760 "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz",
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index 68eae0941..4e224a54c 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -26,7 +26,7 @@ function fancify(seed: string, shade: 'light' | 'dark') {
26} 26}
27 27
28function createDecorationFromTextmate( 28function createDecorationFromTextmate(
29 themeStyle: scopes.TextMateRuleSettings 29 themeStyle: scopes.TextMateRuleSettings,
30): vscode.TextEditorDecorationType { 30): vscode.TextEditorDecorationType {
31 const decorationOptions: vscode.DecorationRenderOptions = {}; 31 const decorationOptions: vscode.DecorationRenderOptions = {};
32 decorationOptions.rangeBehavior = vscode.DecorationRangeBehavior.OpenOpen; 32 decorationOptions.rangeBehavior = vscode.DecorationRangeBehavior.OpenOpen;
@@ -84,7 +84,7 @@ export class Highlighter {
84 const color = new vscode.ThemeColor(fallBackTag); 84 const color = new vscode.ThemeColor(fallBackTag);
85 const decor = vscode.window.createTextEditorDecorationType({ 85 const decor = vscode.window.createTextEditorDecorationType({
86 color, 86 color,
87 textDecoration 87 textDecoration,
88 }); 88 });
89 return [tag, decor]; 89 return [tag, decor];
90 } 90 }
diff --git a/editors/code/src/scopes.ts b/editors/code/src/scopes.ts
index 8f288d761..cb250b853 100644
--- a/editors/code/src/scopes.ts
+++ b/editors/code/src/scopes.ts
@@ -58,10 +58,10 @@ function loadThemeNamed(themeName: string) {
58 return extension.packageJSON.contributes.themes 58 return extension.packageJSON.contributes.themes
59 .filter( 59 .filter(
60 (element: any) => 60 (element: any) =>
61 (element.id || element.label) === themeName 61 (element.id || element.label) === themeName,
62 ) 62 )
63 .map((element: any) => 63 .map((element: any) =>
64 path.join(extension.extensionPath, element.path) 64 path.join(extension.extensionPath, element.path),
65 ) 65 )
66 .concat(list); 66 .concat(list);
67 }, Array<string>()); 67 }, Array<string>());
@@ -71,7 +71,7 @@ function loadThemeNamed(themeName: string) {
71 const tokenColorCustomizations: [any] = [ 71 const tokenColorCustomizations: [any] = [
72 vscode.workspace 72 vscode.workspace
73 .getConfiguration('editor') 73 .getConfiguration('editor')
74 .get('tokenColorCustomizations') 74 .get('tokenColorCustomizations'),
75 ]; 75 ];
76 76
77 tokenColorCustomizations 77 tokenColorCustomizations
@@ -100,7 +100,7 @@ function loadThemeFile(themePath: string) {
100 100
101function mergeRuleSettings( 101function mergeRuleSettings(
102 defaultSetting: TextMateRuleSettings | undefined, 102 defaultSetting: TextMateRuleSettings | undefined,
103 override: TextMateRuleSettings 103 override: TextMateRuleSettings,
104): TextMateRuleSettings { 104): TextMateRuleSettings {
105 if (defaultSetting === undefined) { 105 if (defaultSetting === undefined) {
106 return override; 106 return override;
@@ -116,7 +116,7 @@ function mergeRuleSettings(
116 116
117function updateRules( 117function updateRules(
118 scope: string, 118 scope: string,
119 updatedSettings: TextMateRuleSettings 119 updatedSettings: TextMateRuleSettings,
120): void { 120): void {
121 [rules.get(scope)] 121 [rules.get(scope)]
122 .map(settings => mergeRuleSettings(settings, updatedSettings)) 122 .map(settings => mergeRuleSettings(settings, updatedSettings))
diff --git a/editors/code/src/scopes_mapper.ts b/editors/code/src/scopes_mapper.ts
index 85c791ff5..e738fa239 100644
--- a/editors/code/src/scopes_mapper.ts
+++ b/editors/code/src/scopes_mapper.ts
@@ -10,15 +10,15 @@ const defaultMapping = new Map<string, string[]>([
10 'comment', 10 'comment',
11 'comment.block', 11 'comment.block',
12 'comment.line', 12 'comment.line',
13 'comment.block.documentation' 13 'comment.block.documentation',
14 ] 14 ],
15 ], 15 ],
16 ['string', ['string']], 16 ['string', ['string']],
17 ['keyword', ['keyword']], 17 ['keyword', ['keyword']],
18 ['keyword.control', ['keyword.control', 'keyword', 'keyword.other']], 18 ['keyword.control', ['keyword.control', 'keyword', 'keyword.other']],
19 [ 19 [
20 'keyword.unsafe', 20 'keyword.unsafe',
21 ['storage.modifier', 'keyword.other', 'keyword.control', 'keyword'] 21 ['storage.modifier', 'keyword.other', 'keyword.control', 'keyword'],
22 ], 22 ],
23 ['function', ['entity.name.function']], 23 ['function', ['entity.name.function']],
24 ['parameter', ['variable.parameter']], 24 ['parameter', ['variable.parameter']],
@@ -28,7 +28,7 @@ const defaultMapping = new Map<string, string[]>([
28 ['text', ['string', 'string.quoted', 'string.regexp']], 28 ['text', ['string', 'string.quoted', 'string.regexp']],
29 ['attribute', ['keyword']], 29 ['attribute', ['keyword']],
30 ['literal', ['string', 'string.quoted', 'string.regexp']], 30 ['literal', ['string', 'string.quoted', 'string.regexp']],
31 ['macro', ['support.other']], 31 ['macro', ['entity.name.function', 'keyword.other', 'entity.name.macro']],
32 ['variable', ['variable']], 32 ['variable', ['variable']],
33 ['variable.mut', ['variable', 'storage.modifier']], 33 ['variable.mut', ['variable', 'storage.modifier']],
34 [ 34 [
@@ -37,20 +37,19 @@ const defaultMapping = new Map<string, string[]>([
37 'variable.object.property', 37 'variable.object.property',
38 'meta.field.declaration', 38 'meta.field.declaration',
39 'meta.definition.property', 39 'meta.definition.property',
40 'variable.other' 40 'variable.other',
41 ] 41 ],
42 ], 42 ],
43 ['module', ['entity.name.section', 'entity.other']] 43 ['module', ['entity.name.section', 'entity.other']],
44]); 44]);
45 45
46// Temporary exported for debugging for now.
47export function find(scope: string): string[] { 46export function find(scope: string): string[] {
48 return mappings.get(scope) || []; 47 return mappings.get(scope) || [];
49} 48}
50 49
51export function toRule( 50export function toRule(
52 scope: string, 51 scope: string,
53 intoRule: (scope: string) => TextMateRuleSettings | undefined 52 intoRule: (scope: string) => TextMateRuleSettings | undefined,
54): TextMateRuleSettings | undefined { 53): TextMateRuleSettings | undefined {
55 return find(scope) 54 return find(scope)
56 .map(intoRule) 55 .map(intoRule)