Skip to content

Commit

Permalink
No json schema for token color customizations. Fixes #31505
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed Aug 8, 2017
1 parent c7c3ccc commit 674dfc3
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 58 deletions.
91 changes: 49 additions & 42 deletions src/vs/workbench/services/themes/common/colorThemeSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,61 +114,68 @@ let textMateScopes = [
'variable.parameter'
];

export const tokenColorizationSettingSchema = {
export const tokenColorizationSettingSchema: IJSONSchema = {
type: 'object',
description: nls.localize('schema.token.settings', 'Colors and styles for the token.'),
properties: {
foreground: {
type: 'string',
format: 'color'
},
background: {
type: 'string',
format: 'color'
description: nls.localize('schema.token.foreground', 'Foreground color for the token.'),
format: 'color',
defaultSnippets: [{ body: '${1:#FF0000}' }]
},
fontStyle: {
type: 'string',
description: nls.localize('schema.fontStyle', 'Font style of the rule: One or a combination of \'italic\', \'bold\' and \'underline\'')
description: nls.localize('schema.token.fontStyle', 'Font style of the rule: One or a combination of \'italic\', \'bold\' and \'underline\''),
pattern: '^(\\s*\\b(italics|bold|underline))*\\s*$',
patternErrorMessage: nls.localize('schema.fontStyle.error', 'Font style must be a combination of \'italic\', \'bold\' and \'underline\''),
defaultSnippets: [{ body: 'italic' }, { body: 'bold' }, { body: 'underline' }, { body: 'italic bold' }, { body: 'italic underline' }, { body: 'bold underline' }, { body: 'italic bold underline' }]
}
}
},
defaultSnippets: [{ body: { foreground: '${1:#FF0000}', fontStyle: '${2:bold}' } }]
};

export const colorsSchema = themingRegistry.getColorSchema();
export const tokenColorsSchema = {
type: 'array',
description: nls.localize('schema.colors', 'Colors for syntax highlighting'),
items: {
type: 'object',
properties: {
name: {
type: 'string',
description: nls.localize('schema.properties.name', 'Description of the rule')
},
scope: {
anyOf: [
{
enum: textMateScopes
},
{
type: 'string'
},
{
type: 'array',
items: {
export function tokenColorsSchema(description: string): IJSONSchema {
return {
type: 'array',
description,
items: {
type: 'object',
defaultSnippets: [{ body: { scope: '${1:keyword.operator}', settings: { foreground: '${2:#FF0000}' } } }],
properties: {
name: {
type: 'string',
description: nls.localize('schema.properties.name', 'Description of the rule.')
},
scope: {
description: nls.localize('schema.properties.scope', 'Scope selector against which this rule matches.'),
anyOf: [
{
enum: textMateScopes
}
},
{
type: 'array',
items: {
},
{
type: 'string'
},
{
type: 'array',
items: {
enum: textMateScopes
}
},
{
type: 'array',
items: {
type: 'string'
}
}
}
]
},
settings: tokenColorizationSettingSchema
]
},
settings: tokenColorizationSettingSchema
}
}
}
};
};
}

const schemaId = 'vscode://schemas/color-theme';
const schema: IJSONSchema = {
Expand All @@ -178,9 +185,9 @@ const schema: IJSONSchema = {
tokenColors: {
anyOf: [{
type: 'string',
description: nls.localize('schema.tokenColors.path', 'Path to a tmTheme file (relative to the current file)')
description: nls.localize('schema.tokenColors.path', 'Path to a tmTheme file (relative to the current file).')
},
tokenColorsSchema
tokenColorsSchema(nls.localize('schema.colors', 'Colors for syntax highlighting'))
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1021,14 +1021,18 @@ configurationRegistry.registerConfiguration({
}
});

const tokenGroupSettings = {
anyOf: [
{
type: 'string',
format: 'color'
},
colorThemeSchema.tokenColorizationSettingSchema
]
function tokenGroupSettings(description: string) {
return {
description,
anyOf: [
{
type: 'string',
format: 'color',
defaultSnippets: [{ body: '#FF0000' }]
},
colorThemeSchema.tokenColorizationSettingSchema
]
};
};

configurationRegistry.registerConfiguration({
Expand All @@ -1040,14 +1044,14 @@ configurationRegistry.registerConfiguration({
description: nls.localize('editorColors', "Overrides editor colors and font style from the currently selected color theme."),
default: {},
properties: {
comments: tokenGroupSettings,
strings: tokenGroupSettings,
keywords: tokenGroupSettings,
numbers: tokenGroupSettings,
types: tokenGroupSettings,
functions: tokenGroupSettings,
variables: tokenGroupSettings,
[CUSTOM_EDITOR_SCOPE_COLORS_SETTING]: colorThemeSchema.tokenColorsSchema
comments: tokenGroupSettings(nls.localize('editorColors.comments', "Sets the colors and styles for comments")),
strings: tokenGroupSettings(nls.localize('editorColors.strings', "Sets the colors and styles for strings literals.")),
keywords: tokenGroupSettings(nls.localize('editorColors.keywords', "Sets the colors and styles for keywords.")),
numbers: tokenGroupSettings(nls.localize('editorColors.numbers', "Sets the colors and styles for number literals.")),
types: tokenGroupSettings(nls.localize('editorColors.types', "Sets the colors and styles for type declarations and references.")),
functions: tokenGroupSettings(nls.localize('editorColors.functions', "Sets the colors and styles for functions declarations and references.")),
variables: tokenGroupSettings(nls.localize('editorColors.variables', "Sets the colors and styles for variables declarations and references.")),
[CUSTOM_EDITOR_SCOPE_COLORS_SETTING]: colorThemeSchema.tokenColorsSchema(nls.localize('editorColors.textMateRules', 'Sets colors and styles using textmate theming rules (advanced).'))
}
}
}
Expand Down

0 comments on commit 674dfc3

Please sign in to comment.