From c04f01e60cbfe17797a8660a94254b00acb26e35 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 21 Jul 2016 19:49:43 +0200 Subject: [PATCH] Add schema for language-configuration.json --- extensions/json/package.json | 4 + src/vs/editor/node/languageConfiguration.ts | 126 ++++++++++++++++++++ 2 files changed, 130 insertions(+) diff --git a/extensions/json/package.json b/extensions/json/package.json index cd9a9c908f1..4cb0227ae7b 100644 --- a/extensions/json/package.json +++ b/extensions/json/package.json @@ -54,6 +54,10 @@ "fileMatch": "package.json", "url": "vscode://schemas/vscode-extensions" }, + { + "fileMatch": "language-configuration.json", + "url": "vscode://schemas/language-configuration" + }, { "fileMatch": "vscode://defaultsettings/keybindings.json", "url": "vscode://schemas/keybindings" diff --git a/src/vs/editor/node/languageConfiguration.ts b/src/vs/editor/node/languageConfiguration.ts index 8b0b55712fe..12c8edab83c 100644 --- a/src/vs/editor/node/languageConfiguration.ts +++ b/src/vs/editor/node/languageConfiguration.ts @@ -11,6 +11,9 @@ import {LanguageConfiguration} from 'vs/editor/common/modes/languageConfiguratio import {IModeService} from 'vs/editor/common/services/modeService'; import {IAutoClosingPair, IAutoClosingPairConditional} from 'vs/editor/common/modes'; import {LanguageConfigurationRegistry} from 'vs/editor/common/modes/languageConfigurationRegistry'; +import {Extensions, IJSONContributionRegistry} from 'vs/platform/jsonschemas/common/jsonContributionRegistry'; +import {Registry} from 'vs/platform/platform'; +import {IJSONSchema} from 'vs/base/common/jsonSchema'; type CharacterPair = [string, string]; @@ -101,3 +104,126 @@ export class LanguageConfigurationFileHandler { }); } } + +const schemaId = 'vscode://schemas/language-configuration'; +const schema: IJSONSchema = { + default: { + comments: { + blockComment: ['/*', '*/'], + lineComment: '//' + }, + brackets: [ [ '(', ')' ], [ '[', ']' ] , [ '{', '}' ]], + autoClosingPairs: [ [ '(', ')' ], [ '[', ']' ] , [ '{', '}' ]], + surroundingPairs: [ [ '(', ')' ], [ '[', ']' ] , [ '{', '}' ]] + }, + definitions: { + openBracket: { + type: 'string', + description: nls.localize('schema.openBracket', 'The opening bracket character or string sequence.') + }, + closeBracket: { + type: 'string', + description: nls.localize('schema.closeBracket', 'The closing bracket character or string sequence.') + }, + bracketPair: { + type: 'array', + items: [{ + $ref: '#definitions/openBracket' + },{ + $ref: '#definitions/closeBracket' + }] + } + }, + properties: { + comments: { + default: { + comments: { + blockComment: ['/*', '*/'], + lineComment: '//' + } + }, + description: nls.localize('schema.comments', 'Defines the comment symbols'), + type: 'object', + properties: { + blockComment: { + type: 'array', + description: nls.localize('schema.blockComments', 'Defines how block comments are marked.'), + items: [{ + type: 'string', + description: nls.localize('schema.blockComment.begin', 'The character sequence that starts a block comment.') + },{ + type: 'string', + description: nls.localize('schema.blockComment.end', 'The character sequence that ends a block comment.') + }] + }, + lineComment: { + type: 'string', + description: nls.localize('schema.lineComment', 'The character sequence that starts a line comment.') + } + } + }, + brackets: { + default: { + brackets: [ [ '(', ')' ], [ '[', ']' ] , [ '{', '}' ]] + }, + description: nls.localize('schema.brackets', 'Defines the bracket symbols that increase or decrease the indentation.'), + type: 'array', + items: { + $ref: '#definitions/bracketPair' + } + }, + autoClosingPairs: { + default: { + autoClosingPairs: [ [ '(', ')' ], [ '[', ']' ] , [ '{', '}' ]] + }, + description: nls.localize('schema.autoClosingPairs', 'Defines the bracket pairs. When a opening bracket is entered, the closing bracket is inserted automatically.'), + type: 'array', + items: { + oneOf: [{ + $ref: '#definitions/bracketPair' + },{ + type: 'object', + properties: { + open: { + $ref: '#definitions/openBracket' + }, + close: { + $ref: '#definitions/closeBracket' + }, + notIn: { + type: 'array', + description: nls.localize('schema.autoClosingPairs.notIn', 'Defines a list of scopes where the auto pairs are disabled.'), + items: { + enum: ['string', 'comment'] + } + } + } + }] + } + }, + surroundingPairs: { + default: { + surroundingPairs: [ [ '(', ')' ], [ '[', ']' ] , [ '{', '}' ]] + }, + description: nls.localize('schema.surroundingPairs', 'Defines the bracket pairs that can be used to surround a selected string.'), + type: 'array', + items: { + oneOf: [{ + $ref: '#definitions/bracketPair' + },{ + type: 'object', + properties: { + open: { + $ref: '#definitions/openBracket' + }, + close: { + $ref: '#definitions/closeBracket' + } + } + }] + } + }, + } +}; +let schemaRegistry = Registry.as(Extensions.JSONContribution); +schemaRegistry.registerSchema(schemaId, schema); -- GitLab