Seivan Heidari 2019-12-24 00:04:36 +01:00
parent b21d9337d9
commit 25537d294c
4 changed files with 20 additions and 16 deletions

View file

@ -750,6 +750,11 @@
"esprima": "^4.0.0"
}
},
"jsonc-parser": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-2.2.0.tgz",
"integrity": "sha512-4fLQxW1j/5fWj6p78vAlAafoCKtuBm6ghv+Ij5W2DrDx0qE+ZdEl2c6Ko1mgJNF5ftX1iEWQQ4Ap7+3GlhjkOA=="
},
"lines-and-columns": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz",

View file

@ -26,7 +26,7 @@ function fancify(seed: string, shade: 'light' | 'dark') {
}
function createDecorationFromTextmate(
themeStyle: scopes.TextMateRuleSettings
themeStyle: scopes.TextMateRuleSettings,
): vscode.TextEditorDecorationType {
const decorationOptions: vscode.DecorationRenderOptions = {};
decorationOptions.rangeBehavior = vscode.DecorationRangeBehavior.OpenOpen;
@ -84,7 +84,7 @@ export class Highlighter {
const color = new vscode.ThemeColor(fallBackTag);
const decor = vscode.window.createTextEditorDecorationType({
color,
textDecoration
textDecoration,
});
return [tag, decor];
}

View file

@ -58,10 +58,10 @@ function loadThemeNamed(themeName: string) {
return extension.packageJSON.contributes.themes
.filter(
(element: any) =>
(element.id || element.label) === themeName
(element.id || element.label) === themeName,
)
.map((element: any) =>
path.join(extension.extensionPath, element.path)
path.join(extension.extensionPath, element.path),
)
.concat(list);
}, Array<string>());
@ -71,7 +71,7 @@ function loadThemeNamed(themeName: string) {
const tokenColorCustomizations: [any] = [
vscode.workspace
.getConfiguration('editor')
.get('tokenColorCustomizations')
.get('tokenColorCustomizations'),
];
tokenColorCustomizations
@ -100,7 +100,7 @@ function loadThemeFile(themePath: string) {
function mergeRuleSettings(
defaultSetting: TextMateRuleSettings | undefined,
override: TextMateRuleSettings
override: TextMateRuleSettings,
): TextMateRuleSettings {
if (defaultSetting === undefined) {
return override;
@ -116,7 +116,7 @@ function mergeRuleSettings(
function updateRules(
scope: string,
updatedSettings: TextMateRuleSettings
updatedSettings: TextMateRuleSettings,
): void {
[rules.get(scope)]
.map(settings => mergeRuleSettings(settings, updatedSettings))

View file

@ -10,15 +10,15 @@ const defaultMapping = new Map<string, string[]>([
'comment',
'comment.block',
'comment.line',
'comment.block.documentation'
]
'comment.block.documentation',
],
],
['string', ['string']],
['keyword', ['keyword']],
['keyword.control', ['keyword.control', 'keyword', 'keyword.other']],
[
'keyword.unsafe',
['storage.modifier', 'keyword.other', 'keyword.control', 'keyword']
['storage.modifier', 'keyword.other', 'keyword.control', 'keyword'],
],
['function', ['entity.name.function']],
['parameter', ['variable.parameter']],
@ -28,7 +28,7 @@ const defaultMapping = new Map<string, string[]>([
['text', ['string', 'string.quoted', 'string.regexp']],
['attribute', ['keyword']],
['literal', ['string', 'string.quoted', 'string.regexp']],
['macro', ['support.other']],
['macro', ['entity.name.function', 'keyword.other', 'entity.name.macro']],
['variable', ['variable']],
['variable.mut', ['variable', 'storage.modifier']],
[
@ -37,20 +37,19 @@ const defaultMapping = new Map<string, string[]>([
'variable.object.property',
'meta.field.declaration',
'meta.definition.property',
'variable.other'
]
'variable.other',
],
],
['module', ['entity.name.section', 'entity.other']]
['module', ['entity.name.section', 'entity.other']],
]);
// Temporary exported for debugging for now.
export function find(scope: string): string[] {
return mappings.get(scope) || [];
}
export function toRule(
scope: string,
intoRule: (scope: string) => TextMateRuleSettings | undefined
intoRule: (scope: string) => TextMateRuleSettings | undefined,
): TextMateRuleSettings | undefined {
return find(scope)
.map(intoRule)